From 93c5b036ca342b1cd9f4ce74012d161b2bf9c282 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 25 May 2025 23:58:20 +0200 Subject: [PATCH] added wx debug mode (enable by setting WXDEBUG env var) --- slic/__init__.py | 3 +++ slic/gui/wxdebug.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 slic/gui/wxdebug.py 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) + ) + + +