diff --git a/slic/__init__.py b/slic/__init__.py index bb5d8fbe..c570156a 100644 --- a/slic/__init__.py +++ b/slic/__init__.py @@ -1,3 +1,6 @@ +from slic.gui.wxdebug import wxdebug as _wxdebug +_wxdebug() + from . import core diff --git a/slic/gui/wxdebug.py b/slic/gui/wxdebug.py new file mode 100644 index 00000000..81e47f4a --- /dev/null +++ b/slic/gui/wxdebug.py @@ -0,0 +1,31 @@ +import os +from random import randint + +import wx + + +original_add = wx.Sizer.Add + + +def wxdebug(): + if "WXDEBUG" in os.environ: + wx.Sizer.Add = debug_add + + +def debug_add(self, item, *args, **kwargs): + try: + item.SetBackgroundColour(random_color()) + except: + pass + return original_add(self, item, *args, **kwargs) + + +def random_color(): + return wx.Colour( + randint(100, 255), + randint(100, 255), + randint(100, 255) + ) + + +