--- /dev/null
+from wxPython.wx import *
+from wxPython.lib.grids import wxFlexGridSizer
+
+class aFrame(wxFrame):
+ def __init__(self, parent=NULL, id=-1, title="test"):
+ wxFrame.__init__(self, parent, id, title)
+ s =wxBoxSizer(wxVERTICAL)
+ gs =wxFlexGridSizer(2, 2, 2, 2)
+ for label in ('one', 'two', 'tree', 'four'):
+ gs.Add(wxButton(self, -1, label, size=(100,100)), 1, wxEXPAND)
+ s.Add(gs, 1, wxEXPAND|wxALL, 50)
+ self.SetSizer(s)
+ self.SetAutoLayout(TRUE)
+ s.Fit(self)
+
+class MyApp(wxApp):
+ def OnInit(self):
+ frame =aFrame()
+ self.SetTopWindow(frame)
+ frame.Show(TRUE)
+ return TRUE
+
+app=MyApp(0)
+app.MainLoop()
--- /dev/null
+
+
+from wxPython.wx import *
+from wxPython.ste import wxStyledTextEditorCtrl
+
+
+app = wxPySimpleApp()
+frame = wxFrame(None, -1, "Testing...", (0,0), (320,480))
+ed = wxStyledTextEditorCtrl(frame, -1)
+ed.AddText(open('test7.py').read())
+
+#ed.AddText("This is a test\nThis is only a test.\n\nHere we go cowboys, here we go!!!\nThe End")
+#ed.SetBufferedDraw(false)
+
+#ed.StyleSetFontAttr(1, 14, "Times New Roman", true, false)
+#ed.StyleSetForeground(1, wxBLUE)
+#ed.StyleSetFont(2, wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, false))
+
+#ed.StartStyling(48, 0xff)
+#ed.SetStyleFor(7, 1)
+
+
+frame.Show(true)
+app.MainLoop()
--- /dev/null
+from wxPython.wx import *
+import string
+
+
+class floatValidator(wxPyValidator):
+
+ def __init__(self, obj=None, attrName=""):
+ wxPyValidator.__init__(self)
+ self.numList = ['1','2','3','4','5','6','7','8','9','0','.']
+ EVT_CHAR(self, self.OnChar)
+ self.obj = obj
+ self.attrName = attrName
+
+ def Clone(self):
+ return floatValidator(self.obj, self.attrName)
+
+ def TransferToWindow(self):
+ if self.obj and hasattr(self.obj, self.attrName):
+ tc = wxPyTypeCast(self.GetWindow(), "wxTextCtrl")
+ tc.SetValue(str(getattr(self.obj, self.attrName)))
+ return true
+
+ def TransferFromWindow(self):
+ if self.obj and self.attrName:
+ tc = wxPyTypeCast(self.GetWindow(), "wxTextCtrl")
+ text = tc.GetValue()
+ setattr(self.obj, self.attrName, string.atof(text))
+ return true
+
+
+ def Validate(self, win):
+ tc = wxPyTypeCast(self.GetWindow(), "wxTextCtrl")
+ val = tc.GetValue()
+
+ for x in val:
+ if x not in self.numList:
+ return false
+
+ return true
+
+ def OnChar(self, event):
+ key = event.KeyCode()
+ if key < WXK_SPACE or key == WXK_DELETE or key > 255:
+ event.Skip()
+ return
+
+ if chr(key) in self.numList:
+ event.Skip()
+ return
+
+ if not wxValidator_IsSilent():
+ wxBell()
+
+ # Returning without calling even.Skip eats the event before it
+ # gets to the text control
+ return
+
+
+
+class MyDialog(wxDialog):
+ def __init__(self, parent):
+ wxDialog.__init__(self, parent, -1, "hello")
+
+ self.theValue = 555.12
+ fltValidator = floatValidator(self, "theValue")
+
+ Vbox = wxBoxSizer(wxVERTICAL)
+ Tbox = wxBoxSizer(wxHORIZONTAL)
+ Tbox.Add(wxStaticText(self, -1, "Initial Balance"), 0, wxALL,5)
+ Tbox.Add(wxTextCtrl(self, 13, "123.45", validator = fltValidator,
+ size=(100, -1)), 0, wxALL,5)
+
+ Vbox.Add(Tbox, 0, 0)
+
+ Tbox = wxBoxSizer(wxHORIZONTAL)
+ Tbox.Add(wxButton(self, wxID_OK, "Ok"), 0, wxALL,5)
+ Tbox.Add(wxButton(self, wxID_CANCEL, "Cancel"), 0, wxALL,5)
+
+ Vbox.Add(Tbox, 0, 0)
+
+ self.SetAutoLayout(true)
+ self.SetSizer(Vbox)
+ Vbox.Fit(self)
+
+
+class TestFrame(wxFrame):
+ def __init__(self, parent):
+ wxFrame.__init__(self, parent, -1, "Testing...", size=(150,75))
+ wxButton(self, 25, "Click Me")
+ EVT_BUTTON(self, 25, self.OnClick)
+
+
+ def OnClick(self, event):
+ dlg = MyDialog(self)
+ dlg.ShowModal()
+ print dlg.theValue
+ dlg.Destroy()
+
+
+
+app = wxPySimpleApp()
+frame = TestFrame(None)
+frame.Show(true)
+app.MainLoop()
+
+
+
+