From: Kevin A. <al...@se...> - 2002-12-29 19:04:55
|
In the questionnaire responses I've received so far, a few people have asked about adding controls to PythonCard. They didn't mention specific controls, but I'm assuming they probably mean wxListCtrl, wxTreeCtrl, and wxGrid. The Tree (wxTreeCtrl) and MultiColumnList (wxListCtrl) components are already in PythonCard, but they are very simplistic wrappers and not listed in the resourceEditor component menu. The CodeEditor (wxStyledTextCtrl or wxSTC) component is also already in PythonCard, which is what the codeEditor tool uses. You can put the MultiColumnList and Tree components in a .rsrc.py file and use them now. Not all events are bound and if you want some other default window style you would need to modify the component source. You can easily do that by just making your own appcomponents directory with an __init__.py file (to make the dir a package) in your application directory. The resourceEditor does that so that it can provide its own StaticText component. There is a simplistic example of using the Tree component referenced at: http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/1284318 The MultiColumnList example is at: http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/1197833 In both cases, the methods will be identical to the ones for the corresponing wxPython control (wxTreeCtrl, wxListCtrl). If you wanted to manually add a wxPython control to a PythonCard window, you would probably want to do that in the openBackground handler. Here is an example of manually a wxButton control to the minimal sample: from PythonCardPrototype import model from wxPython import wx class Minimal(model.Background): def on_openBackground(self, event): self.btnTest = wx.wxButton(self.panel, -1, 'Test Button', (0, 30)) # now manually bind an event # the event method could have a different name # I just decided to follow PythonCard event handler naming # conventions wx.EVT_BUTTON(self.panel, self.btnTest.GetId(), self.on_btnTest_mouseClick) def on_btnTest_mouseClick(self, event): self.components.field1.text = "hello world" def on_menuFileExit_select(self, event): self.Close() if __name__ == '__main__': app = model.PythonCardApp(Minimal) app.MainLoop() You should also be able to load a layout from a wxXmlResource that you created with wxDesigner or another wxXMLResource tool. The catch is that none of the controls would be in self.components and you would manually have to bind all of the events you're interested in. I haven't tried this myself, so there might be a gotcha or two. Keep the comments coming. ka |