X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/49bffb1482cd2a6a30b38280f6c9bffc72dbfe42..f78e4942ec0f3f6abd2992502e2d6c5c2e8e55f6:/wxPython/misc/widgetLayoutTest.py?ds=inline diff --git a/wxPython/misc/widgetLayoutTest.py b/wxPython/misc/widgetLayoutTest.py index 22706ac42f..bcb463e87c 100644 --- a/wxPython/misc/widgetLayoutTest.py +++ b/wxPython/misc/widgetLayoutTest.py @@ -9,6 +9,10 @@ import wx import sys import os +# stuff for debugging +print "wx.VERSION_STRING = ", wx.VERSION_STRING +print "pid:", os.getpid() +##raw_input("Press Enter...") class LayoutTestFrame(wx.Frame): def __init__(self): @@ -45,11 +49,11 @@ class LayoutTestFrame(wx.Frame): self.destroyBtn = destroyBtn bottomPanel = wx.Panel(p, style=wx.SUNKEN_BORDER, name="bottomPanel") - bottomPanel.SetSizeHints((640,240)) - bottomPanel.SetDefaultBackgroundColour("light blue") + bottomPanel.SetMinSize((640,240)) + bottomPanel.SetOwnBackgroundColour("light blue") self.testPanel = wx.Panel(bottomPanel, name="testPanel") - self.testPanel.SetDefaultBackgroundColour((205, 183, 181)) # mistyrose3 + self.testPanel.SetOwnBackgroundColour((205, 183, 181)) # mistyrose3 self.testWidget = None self.infoPane = InfoPane(p) @@ -72,6 +76,9 @@ class LayoutTestFrame(wx.Frame): self.Bind(wx.EVT_LISTBOX, self.OnHistorySelect, self.testHistory) self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnHistoryActivate, self.testHistory) + if 'wxMac' in wx.PlatformInfo or 'wxGTK' in wx.PlatformInfo: + self.testHistory.Bind(wx.EVT_KEY_DOWN, self.OnHistoryKey) + # setup the layout mainSizer = wx.BoxSizer(wx.VERTICAL) @@ -87,7 +94,7 @@ class LayoutTestFrame(wx.Frame): mcSizer = wx.BoxSizer(wx.HORIZONTAL) mcSizer.Add(self.moduleName, 0, 0) mcSizer.Add(wx.StaticText(p, -1, "Class name:"), - 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL |wx.LEFT, 10) + 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL |wx.LEFT|wx.RIGHT, 10) mcSizer.Add(self.className, 1, 0) ctlsSizer.Add(mcSizer, 0, wx.EXPAND) @@ -213,13 +220,16 @@ class LayoutTestFrame(wx.Frame): def OnHistorySelect(self, evt): - idx = self.testHistory.GetSelection() + #idx = self.testHistory.GetSelection() + idx = evt.GetInt() if idx != wx.NOT_FOUND: item = self.history[idx] self.moduleName.SetValue(item[0]) self.className.SetValue(item[1]) self.parameters.SetValue(item[2]) self.postCreate.SetValue(item[3]) + if 'wxMac' in wx.PlatformInfo: + self.OnUpdate(None) def OnHistoryActivate(self, evt): @@ -229,6 +239,13 @@ class LayoutTestFrame(wx.Frame): btn.Command(e) + def OnHistoryKey(self, evt): + key = evt.GetKeyCode() + if key == wx.WXK_RETURN: + self.OnHistoryActivate(None) + else: + evt.Skip() + def OnUpdate(self, evt): # get the details from the form @@ -239,13 +256,15 @@ class LayoutTestFrame(wx.Frame): expr = "w = %s.%s( testPanel, %s )" % (moduleName, className, parameters) self.expression.SetValue(expr) - docstring = "" + docstring = None try: docstring = eval("%s.%s.__init__.__doc__" % (moduleName, className)) except: pass - self.docstring.SetValue(docstring) - + if docstring is not None: + self.docstring.SetValue(docstring) + else: + self.docstring.SetValue("") def OnEnableDestroy(self, evt): evt.Enable(self.testWidget is not None) @@ -266,6 +285,8 @@ class LayoutTestFrame(wx.Frame): parameters = self.parameters.GetValue() expr = self.expression.GetValue()[4:] postCreate = self.postCreate.GetValue() + if 'wxMac' in wx.PlatformInfo: + postCreate = postCreate.replace('\r', '\n') # make sure the module is imported already if not sys.modules.has_key(moduleName): @@ -310,20 +331,6 @@ class LayoutTestFrame(wx.Frame): self.infoPane.Update(w, testPanel) - if False: - print 'w size', w.GetSize() - print 'w minsize', w.GetMinSize() - print 'w bestsize', w.GetBestSize() - print 'w abstsize', w.GetAdjustedBestSize() - - tp = self.testPanel - #print tp.GetSizer() - print 'tp size', tp.GetSize() - print 'tp minsize', tp.GetMinSize() - print 'tp bestsize', tp.GetBestSize() - print 'tp abstsize', tp.GetAdjustedBestSize() - - def OnDestroyWidget(self, evt): self.testWidget.Destroy() @@ -331,10 +338,10 @@ class LayoutTestFrame(wx.Frame): self.testPanel.SetSizer(None, True) self.testPanel.Refresh() - # ensure the panel shrinks again - self.testPanel.SetSizeHints((20,20)) + # ensure the panel shrinks again now that it has no sizer + self.testPanel.SetMinSize((20,20)) self.bottomSizer.Layout() - self.testPanel.SetSizeHints(wx.DefaultSize) + self.testPanel.SetMinSize(wx.DefaultSize) # make the create button be default now self.createBtn.SetDefault() @@ -342,7 +349,6 @@ class LayoutTestFrame(wx.Frame): self.infoPane.Clear() - def OnClear(self, evt): self.moduleName.SetValue("") self.className.SetValue("") @@ -403,6 +409,7 @@ class SizeInfoPane(wx.Panel): 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) + self._bestfit = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) # setup the layout fgs = wx.FlexGridSizer(2, 2, 5, 5) @@ -424,6 +431,10 @@ class SizeInfoPane(wx.Panel): 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) fgs.Add(self._adjbstsize, 0, wx.EXPAND) + fgs.Add(wx.StaticText(self, -1, "BestFittingSize:"), + 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) + fgs.Add(self._bestfit, 0, wx.EXPAND) + sbs = wx.StaticBoxSizer(sb, wx.VERTICAL) sbs.Add(fgs, 0, wx.EXPAND|wx.ALL, 4) @@ -435,13 +446,14 @@ class SizeInfoPane(wx.Panel): self._minsize.SetValue( str(win.GetMinSize()) ) self._bestsize.SetValue( str(win.GetBestSize()) ) self._adjbstsize.SetValue( str(win.GetAdjustedBestSize()) ) - + self._bestfit.SetValue( str(win.GetBestFittingSize()) ) def Clear(self): self._size.SetValue("") self._minsize.SetValue("") self._bestsize.SetValue("") self._adjbstsize.SetValue("") + self._bestfit.SetValue("") @@ -456,10 +468,10 @@ class ColourInfoPanel(wx.Panel): 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._fgclr.SetMinSize((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)) + self._bgclr.SetMinSize((20,20)) # setup the layout fgs = wx.FlexGridSizer(2, 3, 5, 5) @@ -502,7 +514,7 @@ class ColourInfoPanel(wx.Panel): -app = wx.PySimpleApp(redirect=True) +app = wx.PySimpleApp(redirect=False) frame = LayoutTestFrame() app.SetTopWindow(frame) frame.Show()