+
+
+
+
+
+
+class InfoPane(wx.Panel):
+ """
+ This class is used to display details of various properties of the
+ widget and the testPanel to aid with debugging.
+ """
+ def __init__(self, parent):
+ wx.Panel.__init__(self, parent)
+
+ # create subwidgets
+ self.wPane = SizeInfoPane(self, "Widget")
+ self.tpPane= SizeInfoPane(self, "testPanel")
+ self.cPane = ColourInfoPanel(self, "Widget colours")
+
+ # Setup the layout
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(self.wPane, 0, wx.EXPAND|wx.ALL, 5)
+ sizer.Add(self.tpPane, 0, wx.EXPAND|wx.ALL, 5)
+ sizer.Add(self.cPane, 0, wx.EXPAND|wx.ALL, 5)
+
+ self.SetSizer(sizer)
+
+
+ def Update(self, w, tp):
+ self.wPane.Update(w)
+ self.tpPane.Update(tp)
+ self.cPane.Update(w)
+
+ def Clear(self):
+ self.wPane.Clear()
+ self.tpPane.Clear()
+ self.cPane.Clear()
+
+
+
+class SizeInfoPane(wx.Panel):
+ """
+ A component of the InfoPane that shows vaious window size attributes.
+ """
+ def __init__(self, parent, label):
+ wx.Panel.__init__(self, parent)
+
+ # create subwidgets
+ sb = wx.StaticBox(self, -1, label)
+ self._size = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+ self._minsize = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+ self._bestsize = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+ self._adjbstsize = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+
+ # setup the layout
+ fgs = wx.FlexGridSizer(2, 2, 5, 5)
+ fgs.AddGrowableCol(1)
+
+ fgs.Add(wx.StaticText(self, -1, "Size:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._size, 0, wx.EXPAND)
+
+ fgs.Add(wx.StaticText(self, -1, "MinSize:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._minsize, 0, wx.EXPAND)
+
+ fgs.Add(wx.StaticText(self, -1, "BestSize:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._bestsize, 0, wx.EXPAND)
+
+ fgs.Add(wx.StaticText(self, -1, "AdjustedBestSize:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._adjbstsize, 0, wx.EXPAND)
+
+ sbs = wx.StaticBoxSizer(sb, wx.VERTICAL)
+ sbs.Add(fgs, 0, wx.EXPAND|wx.ALL, 4)
+
+ self.SetSizer(sbs)
+
+
+ def Update(self, win):
+ self._size.SetValue( str(win.GetSize()) )
+ self._minsize.SetValue( str(win.GetMinSize()) )
+ self._bestsize.SetValue( str(win.GetBestSize()) )
+ self._adjbstsize.SetValue( str(win.GetAdjustedBestSize()) )
+
+
+ def Clear(self):
+ self._size.SetValue("")
+ self._minsize.SetValue("")
+ self._bestsize.SetValue("")
+ self._adjbstsize.SetValue("")
+
+
+
+class ColourInfoPanel(wx.Panel):
+ """
+ A component of the InfoPane that shows fg and bg colour attributes.
+ """
+ def __init__(self, parent, label):
+ wx.Panel.__init__(self, parent)
+
+ # create subwidgets
+ sb = wx.StaticBox(self, -1, label)
+ self._fgtxt = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+ self._fgclr = wx.Panel(self, style=wx.SIMPLE_BORDER)
+ self._fgclr.SetSizeHints((20,20))
+ self._bgtxt = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+ self._bgclr = wx.Panel(self, style=wx.SIMPLE_BORDER)
+ self._bgclr.SetSizeHints((20,20))
+
+ # setup the layout
+ fgs = wx.FlexGridSizer(2, 3, 5, 5)
+ fgs.AddGrowableCol(1)
+
+ fgs.Add(wx.StaticText(self, -1, "FG colour:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._fgtxt, 0, wx.EXPAND)
+ fgs.Add(self._fgclr)
+
+ fgs.Add(wx.StaticText(self, -1, "BG colour:"),
+ 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+ fgs.Add(self._bgtxt, 0, wx.EXPAND)
+ fgs.Add(self._bgclr)
+
+ sbs = wx.StaticBoxSizer(sb, wx.VERTICAL)
+ sbs.Add(fgs, 0, wx.EXPAND|wx.ALL, 4)
+
+ self.SetSizer(sbs)
+
+
+ def Update(self, win):
+ def clr2hex(c, cp):
+ cp.SetBackgroundColour(c)
+ cp.Refresh()
+ return "#%02X%02X%02X" % c.Get()