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):
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)
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)
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):
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
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)
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):
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()
self.infoPane.Clear()
-
def OnClear(self, evt):
self.moduleName.SetValue("")
self.className.SetValue("")
self._fgtxt.SetValue( clr2hex(win.GetForegroundColour(), self._fgclr) )
self._bgtxt.SetValue( clr2hex(win.GetBackgroundColour(), self._bgclr) )
+## f = win.GetFont()
+## print f.GetNativeFontInfo().ToString()
+
def Clear(self):
self._fgtxt.SetValue("")
-app = wx.PySimpleApp(redirect=True)
+app = wx.PySimpleApp(redirect=False)
frame = LayoutTestFrame()
app.SetTopWindow(frame)
frame.Show()