# HG changeset patch # User Andrey Skvortsov # Date 1505491291 -10800 # Node ID 5562f34f2fc2b2bdee16dfae00db0a969b440b38 # Parent 6b4d0f4f2fbcef20d7071340c546b43072db2b44 lazy initialization of highlight pens and brushes for DebugVariableViewer Constructors wx.Pen() and wx.Brush() require wx.App to exist already. That causes crash during import of the control, because import is done before calling main application code. diff -r 6b4d0f4f2fbc -r 5562f34f2fc2 controls/DebugVariablePanel/DebugVariableViewer.py --- a/controls/DebugVariablePanel/DebugVariableViewer.py Fri Sep 15 18:57:20 2017 +0300 +++ b/controls/DebugVariablePanel/DebugVariableViewer.py Fri Sep 15 19:01:31 2017 +0300 @@ -41,10 +41,10 @@ HIGHLIGHT_RESIZE] = range(6) # Viewer highlight styles -HIGHLIGHT_DROP_PEN = wx.Pen(wx.Colour(0, 128, 255)) -HIGHLIGHT_DROP_BRUSH = wx.Brush(wx.Colour(0, 128, 255, 128)) -HIGHLIGHT_RESIZE_PEN = wx.Pen(wx.Colour(200, 200, 200)) -HIGHLIGHT_RESIZE_BRUSH = wx.Brush(wx.Colour(200, 200, 200)) +HIGHLIGHT_DROP_PEN = None +HIGHLIGHT_DROP_BRUSH = None +HIGHLIGHT_RESIZE_PEN = None +HIGHLIGHT_RESIZE_BRUSH = None # ------------------------------------------------------------------------------- # Base Debug Variable Viewer Class @@ -72,6 +72,7 @@ self.Highlight = HIGHLIGHT_NONE # List of buttons self.Buttons = [] + self.InitHighlightPensBrushes() def __del__(self): """ @@ -80,6 +81,16 @@ # Remove reference to Debug Variable Panel self.ParentWindow = None + def InitHighlightPensBrushes(self): + """ + Init global pens and brushes + """ + if HIGHLIGHT_DROP_PEN is None: + HIGHLIGHT_DROP_PEN = wx.Pen(wx.Colour(0, 128, 255)) + HIGHLIGHT_DROP_BRUSH = wx.Brush(wx.Colour(0, 128, 255, 128)) + HIGHLIGHT_RESIZE_PEN = wx.Pen(wx.Colour(200, 200, 200)) + HIGHLIGHT_RESIZE_BRUSH = wx.Brush(wx.Colour(200, 200, 200)) + def GetIndex(self): """ Return position of Viewer in Debug Variable Panel