Added some info panels that show size and colour attributes about the widget
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -52,6 +52,7 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
self.testPanel.SetDefaultBackgroundColour((205, 183, 181)) # mistyrose3
|
self.testPanel.SetDefaultBackgroundColour((205, 183, 181)) # mistyrose3
|
||||||
self.testWidget = None
|
self.testWidget = None
|
||||||
|
|
||||||
|
self.infoPane = InfoPane(p)
|
||||||
|
|
||||||
# setup event bindings
|
# setup event bindings
|
||||||
self.Bind(wx.EVT_TEXT, self.OnUpdate, self.moduleName)
|
self.Bind(wx.EVT_TEXT, self.OnUpdate, self.moduleName)
|
||||||
@@ -81,9 +82,6 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
|
|
||||||
topSizer.Add(self.testHistory, 0, wx.RIGHT, 30)
|
topSizer.Add(self.testHistory, 0, wx.RIGHT, 30)
|
||||||
|
|
||||||
ctlsSizer.Add((1,25))
|
|
||||||
ctlsSizer.Add((1,25))
|
|
||||||
|
|
||||||
ctlsSizer.Add(wx.StaticText(p, -1, "Module name:"),
|
ctlsSizer.Add(wx.StaticText(p, -1, "Module name:"),
|
||||||
0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
|
0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
|
||||||
mcSizer = wx.BoxSizer(wx.HORIZONTAL)
|
mcSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
@@ -103,7 +101,7 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
ctlsSizer.Add(self.postCreate, 0, wx.EXPAND)
|
ctlsSizer.Add(self.postCreate, 0, wx.EXPAND)
|
||||||
ctlsSizer.Add(wx.StaticText(p, -1, "DocString:"), 0, wx.ALIGN_RIGHT)
|
ctlsSizer.Add(wx.StaticText(p, -1, "DocString:"), 0, wx.ALIGN_RIGHT)
|
||||||
ctlsSizer.Add(self.docstring, 0, wx.EXPAND)
|
ctlsSizer.Add(self.docstring, 0, wx.EXPAND)
|
||||||
ctlsSizer.AddGrowableRow(5)
|
ctlsSizer.AddGrowableRow(4)
|
||||||
topSizer.Add(ctlsSizer, 1, wx.EXPAND)
|
topSizer.Add(ctlsSizer, 1, wx.EXPAND)
|
||||||
|
|
||||||
btnSizer.Add((5,5))
|
btnSizer.Add((5,5))
|
||||||
@@ -122,6 +120,8 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
##mainSizer.Add(wx.StaticLine(p, -1), 0, wx.EXPAND)
|
##mainSizer.Add(wx.StaticLine(p, -1), 0, wx.EXPAND)
|
||||||
mainSizer.Add(bottomPanel, 1, wx.EXPAND)
|
mainSizer.Add(bottomPanel, 1, wx.EXPAND)
|
||||||
|
|
||||||
|
mainSizer.Add(self.infoPane, 0, wx.EXPAND)
|
||||||
|
|
||||||
self.bottomSizer = sz = wx.BoxSizer(wx.VERTICAL)
|
self.bottomSizer = sz = wx.BoxSizer(wx.VERTICAL)
|
||||||
sz.Add((0,0), 1)
|
sz.Add((0,0), 1)
|
||||||
sz.Add(self.testPanel, 0, wx.ALIGN_CENTER)
|
sz.Add(self.testPanel, 0, wx.ALIGN_CENTER)
|
||||||
@@ -308,6 +308,8 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
# make the destroy button be default now
|
# make the destroy button be default now
|
||||||
self.destroyBtn.SetDefault()
|
self.destroyBtn.SetDefault()
|
||||||
|
|
||||||
|
self.infoPane.Update(w, testPanel)
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
print 'w size', w.GetSize()
|
print 'w size', w.GetSize()
|
||||||
print 'w minsize', w.GetMinSize()
|
print 'w minsize', w.GetMinSize()
|
||||||
@@ -337,6 +339,9 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
# make the create button be default now
|
# make the create button be default now
|
||||||
self.createBtn.SetDefault()
|
self.createBtn.SetDefault()
|
||||||
|
|
||||||
|
self.infoPane.Clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def OnClear(self, evt):
|
def OnClear(self, evt):
|
||||||
self.moduleName.SetValue("")
|
self.moduleName.SetValue("")
|
||||||
@@ -348,6 +353,155 @@ class LayoutTestFrame(wx.Frame):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
self._fgtxt.SetValue( clr2hex(win.GetForegroundColour(), self._fgclr) )
|
||||||
|
self._bgtxt.SetValue( clr2hex(win.GetBackgroundColour(), self._bgclr) )
|
||||||
|
|
||||||
|
|
||||||
|
def Clear(self):
|
||||||
|
self._fgtxt.SetValue("")
|
||||||
|
self._bgtxt.SetValue("")
|
||||||
|
self._fgclr.SetBackgroundColour(self.GetBackgroundColour())
|
||||||
|
self._bgclr.SetBackgroundColour(self.GetBackgroundColour())
|
||||||
|
self._fgclr.Refresh()
|
||||||
|
self._bgclr.Refresh()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app = wx.PySimpleApp(redirect=True)
|
app = wx.PySimpleApp(redirect=True)
|
||||||
frame = LayoutTestFrame()
|
frame = LayoutTestFrame()
|
||||||
app.SetTopWindow(frame)
|
app.SetTopWindow(frame)
|
||||||
|
Reference in New Issue
Block a user