Re: Added MDI support to Pythoncard (was MDI - childwindows within a window)
Kael Fischer <[email protected]> Sat, 2 Apr 2011 11:11:43 -0600
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
Python card is great. But I caution people stating out on large computationally or database intensive projects that while pythoncard makes the easy stuff very easy, it makes that hard stuff harder. Note that even using wxPython getting the process-based and thread-based multitasking working properly can be hard and is essential in any program that uses the cpu, disk and network intensively and still needs wx to be responsive, draw progress bars, etc. I'm warning about big data here (for a GUI anyway): trees with 1000's-10,000's of nodes, grid data stores with ~1M cells. I've written some cool programs in python card, but they never scaled well. -Kael On Sat, Apr 2, 2011 at 8:53 AM, John Henry <[email protected]> wrote: > To give others an idea how simple Pythoncard is, I'll show you the code > necessary to produce the MDI example with Sashwindow that I posted earlie= r. > To create that ap, use the layout editor and create 2 resource files (the > widget childwindow is from the standard samples), one for the main window, > and one for the sash window (the one with a tree control and a button), a= nd > then write the following (ridiculously=A0simple) code: > ################################## > #!/usr/bin/python > """ > __version__ =3D "$Revision: 1.5 $" > __date__ =3D "$Date: 2004/04/30 16:26:12 $" > """ > import sys > from PythonCard import model > # Resource for the main window > from testMDI_rsrc import rsrc as testMDI_rsrc > # The widget example > from widgets import WidgetsTest > from widgets_rsrc import rsrc as widgets_rsrc > # Resource for the sash window > from sashLayoutWindow_rsrc import rsrc as SashWindow_rsrc > class wxMDIParentFrame(model.MDISashParentBackground): > def on_initialize(self, event): > # Pass the resource to the parent of the sash window > model.MDISashParentBackground.on_initialize(self, event, SashWindow_rsrc) > self.on_openNew_command(None) > # Need this for the sash contents to show up > self.resize(event) > # Opens a new widget window everytime the openNew option is selected > def on_openNew_command(self, event): > child1 =3D model.childWindow(self, WidgetsTest, rsrc=3Dwidgets_rsrc) > child1.Show(True) > > class MyBackground(model.Application): > def __init__(self, parent, rsrc): > model.Application.__init__(self, wxMDIParentFrame, rsrc=3DtestMDI_rsrc) > def on_initialize(self, event): > # if you have any initialization > # including sizer setup, do it here > pass > if __name__ =3D=3D '__main__': > app =3D model.Application(MyBackground) > app.MainLoop() > ################################# > I rest my case. > I attached the screen shot for completeness. Once I fix one more issue (w= hen > I drag the sash window bar, the widget windows don't repaint unless I res= ize > the main), I am going to package up the MDI mod and upload to the Pythonc= ard > upload area. > -- > John Henry > > From: Teuvo Eloranta <[email protected]> > To: John Henry <[email protected]> > Cc: John Henry <[email protected]>; Mark Carter <[email protected]>; > [email protected] > Sent: Sat, April 2, 2011 2:29:06 AM > Subject: Re: [Pythoncard-users] Added MDI support to Pythoncard (was MDI - > childwindows within a window) > > Hi there! > > It's so nice to hear people using Pythoncard, not to mention someone is > (willing to) developing it. > I think Pythoncard is an absolute superb tool for making GUI programs. > Amazingly fast method and produces code more readable (and short) than any > other (at least that i know of). > I've done something earlier with wxPython, but usually it's "too much" for > what I need, Pythoncard is definitely the nbr one tool I use for GUI > programs. > And when necessary, the missing pieces can be coded with wxPython still. > > For the developer, and everyone involved somehow for making pythoncard wh= at > it is today - thank you! > > Just wanted to add=A0 my 5 cents too :) > > -Teuvo > > > 2011/4/2 John Henry <[email protected]> >> >> I couldn't agree with you more. =A0Earlier there was a post claiming tha= t he >> prefers wxPython over Pythoncard. =A0I assume he's using a different ani= mal >> than the one I am looking at. =A0Pythoncard is simple, feature rich - an= d very >> stable. =A0I've done numerous projects using Pythoncard. >> I've long suggested that somebody release a 1.0 version of Pythoncard. = =A0So >> far, it has fallen to death ears. =A0 If we can all convince the owner t= o do >> that, I can package up what I have done and contribute to the release. >> I've hecked together the following controls: >> pdfwindow, flashwindow, tree control, minimizable window (minimize to >> Windows lauch bar), MDI parent and child windows, sashwindows, ... >> I have to stress heck because I did all these kind of blind folded becau= se >> I really don't know what's going on most of the time. =A0Wing debugger i= s my >> friend. >> Controls I tried but unable to get it to work: >> matplotlib window, a graphic file viewer widget (works but not behaving >> properly), a MDI widget (not window). >> >> >> -- >> John Henry >> >> From: Mark Carter <[email protected]> >> To: [email protected] >> Sent: Fri, April 1, 2011 9:13:02 AM >> Subject: [Pythoncard-users] Added MDI support to Pythoncard (was MDI - >> childwindows within a window) >> >> Hi John. >> >> Awesome!=A0 Good to know someone is still developing PythonCard!=A0 Pyth= onCard >> is really a super project, for infrequent programmers like myself looking >> for a Visual Basic-like development experience on Python, PythonCard does >> the job. >> >> I don't suppose you could shepherd through a new release?=A0 The current >> release is several years old IIRC, and the installer has issues (either = with >> Vista and/or latest Python, can't recall).=A0 Most people who research >> PythonCard these days just assume it's a dead project. >> >> Mark >> >> >> On Fri, Apr 1, 2011 at 10:53 AM, John Henry <[email protected]> wrote: >>> >>> I am happy to report that I've succeeded in Pythoncardize >>> the wx.SashLayoutWindow control of wxPython >>> =A0using similar technique to the MDI support I reported previously. = =A0 Not >>> sure if >>> the screen capture attachment to this email will get stripped or not. = =A0If >>> you >>> don't see the screen shot, shout and I'll try to upload that somewhere. >>> >>> ########## mod to model.py ####################### >>> class Background(BackgroundBase, wx.Frame): >>> =A0 =A0def __init__(self, aParent, aBgRsrc, init=3DNone): >>> =A0 =A0 =A0 =A0return BackgroundBase.__init__(self, aParent, aBgRsrc, >>> frameclass=3Dwx.Frame, init=3Dinit) >>> >>> class MDIChildBackground(BackgroundBase, wx.MDIChildFrame): >>> =A0 =A0def __init__(self, aParent, aBgRsrc, init=3DNone): >>> =A0 =A0 =A0 =A0return BackgroundBase.__init__(self, aParent, aBgRsrc, >>> frameclass=3Dwx.MDIChildFrame, init=3Dinit) >>> >>> class MDIParentBackground(BackgroundBase, wx.MDIParentFrame): >>> =A0 =A0def __init__(self, aParent, aBgRsrc, init=3DNone): >>> =A0 =A0 =A0 =A0return BackgroundBase.__init__(self, aParent, aBgRsrc, >>> frameclass=3Dwx.MDIParentFrame, init=3Dinit) >>> >>> class SashWindow(BackgroundBase, wx.SashLayoutWindow): >>> =A0 =A0def __init__(self, aParent, aBgRsrc, init=3DNone): >>> =A0 =A0 =A0 =A0rsrc =3D resource.Resource(aBgRsrc).application.backgrou= nds[0] >>> =A0 =A0 =A0 =A0return BackgroundBase.__init__(self, aParent, rsrc, >>> frameclass=3Dwx.SashLayoutWindow, init=3Dinit) >>> =A0# Dummy routine >>> =A0 =A0def SetMenuBar(self, child): >>> =A0 =A0 =A0 =A0return >>> =A0 =A0# Dummy routine >>> =A0 =A0def GetStatusBar(self): >>> =A0 =A0 =A0 =A0return >>> ########## end of mod to model.py #######################-- >>> John Henry >>> >>> >>> >>> ----- Original Message ---- >>> > From: John Henry <[email protected]> >>> > To: [email protected] >>> > Sent: Wed, March 9, 2011 10:08:39 AM >>> > Subject: Added MDI support to Pythoncard (was MDI - childwindows with= in >>> > a >>> >window) >>> > >>> > I am happy to let you know that I succeeded in adding MDI support to >>> > Pythoncard >>> > >>> > with only a few lines of modifications to the Background class in >>> > model.py >>> > >>> > I made the Background =A0class into a BackgroundBase class, and have = the >>> >Background >>> > >>> > class subclass =A0from the BackgroundBase class. >>> > >>> > Then I added a MDIParentBackground =A0and MDIChildBackground which si= mply >>> > force >>> > Background to subclass from =A0wxMDIParentFrame and wxMDIChildFrame >>> > respectively, >>> > >>> > instead of the wx.Frame =A0class. =A0 Once I've done that, wxPython d= oes >>> > the rest >>> >of >>> > >>> > the =A0work. >>> > >>> > ################ mod to model.py ###################### >>> > >>> > from =A0wxPython.wx import wxMDIParentFrame, wxMDIChildFrame >>> > >>> > # Used to say: >>> > # =A0class BackgroundBase(Scriptable, wx.Frame, =A0event.EventSource): >>> > class =A0BackgroundBase(Scriptable, event.EventSource): >>> > =A0 =A0 """ >>> > =A0 =A0 =A0A window that contains Widgets. >>> > =A0 =A0 """ >>> > =A0 =A0 def =A0__init__(self, aParent, aBgRsrc, frameclass=3Dwx.Frame= ): >>> > =A0 =A0 =A0...<original code>... >>> > #Changed original code from invoking wx.Frame =A0here to a method pas= sed >>> > down >>> > =A0 =A0 =A0 =A0 # First, call the =A0base class' __init__ method to c= reate the >>> > frame >>> > =A0 =A0 =A0 =A0 =A0frameclass.__init__(self, aParent, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.id, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#self.name, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 aBgRsrc.t= itle, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0position, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 aBgRsrc.s= ize, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0style | = =A0wx.NO_FULL_REPAINT_ON_RESIZE, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0aBgRsrc.na= me) >>> > =A0 =A0...<rest of original =A0code>... >>> > >>> > >>> > class Background(BackgroundBase, wx.Frame): >>> > =A0 =A0 =A0def __init__(self, aParent, aBgRsrc): >>> > =A0 =A0 =A0 =A0 =A0return BackgroundBase.__init__(self, aParent, aBgR= src, >>> > frameclass=3Dwx.Frame) >>> > >>> > class MDIParentBackground(BackgroundBase, =A0wxMDIParentFrame): >>> > =A0 =A0 def __init__(self, aParent, =A0aBgRsrc): >>> > =A0 =A0 =A0 =A0 return BackgroundBase.__init__(self, =A0aParent, aBgR= src, >>> > frameclass=3DwxMDIParentFrame) >>> > >>> > class =A0MDIChildBackground(BackgroundBase, wxMDIChildFrame): >>> > =A0 =A0 def =A0__init__(self, aParent, aBgRsrc): >>> > =A0 =A0 =A0 =A0 return =A0BackgroundBase.__init__(self, aParent, aBgR= src, >>> > frameclass=3DwxMDIChildFrame) >>> > >>> > ############## end =A0of mod to model.py ######################### >>> > >>> > To use these two new =A0classes, the code is remarkably unremarkable. >>> > =A0The parent >>> > >>> > code: >>> > >>> > ############# Parent =A0###################### >>> > #!/usr/bin/python >>> > >>> > """ >>> > __version__ =3D =A0"$Revision: 1.5 $" >>> > __date__ =3D "$Date: 2004/04/30 16:26:12 =A0$" >>> > """ >>> > >>> > from PythonCard import =A0model >>> > >>> > MDI_rsrc=3D\ >>> > {'application':{'type':'Application', >>> > =A0 =A0 =A0 =A0 =A0 =A0'name':'Template', >>> > =A0 =A0 'backgrounds': =A0[ >>> > =A0 =A0 {'type':'Background', >>> > =A0 =A0 =A0 =A0 =A0 =A0'name':'bgTemplate', >>> > =A0 =A0 =A0 =A0 =A0 'title':'Testing MDI =A0Controls', >>> > =A0 =A0 =A0 =A0 =A0 'size':(400, 300), >>> > =A0 =A0 =A0 =A0 =A0 =A0'style':['resizeable'], >>> > >>> > =A0 =A0 =A0 =A0 =A0'menubar': {'type':'MenuBar', >>> > =A0 =A0 =A0 =A0 =A0'menus': =A0[ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0{'type':'Menu', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuFile', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'&File', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'items': [ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{'type':'MenuItem', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuFileExit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'E&xit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'command':'exit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 {'type':'Menu', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuOptions', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'Options', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'items': [ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{'type':'MenuItem', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuOptionsOpenNew', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'Open New\tAlt+N', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'command':'openNew', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 }, >>> > =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 'components': [ >>> > >>> > ] # end components >>> > } # end =A0background >>> > ] # end backgrounds >>> > } =A0} >>> > >>> > MyCW_rsrc=3D\ >>> > {'application':{'type':'Application', >>> > =A0 =A0 =A0 =A0 =A0 =A0'name':'Template', >>> > =A0 =A0 'backgrounds': =A0[ >>> > =A0 =A0 {'type':'Background', >>> > =A0 =A0 =A0 =A0 =A0 =A0'name':'bgTemplate', >>> > =A0 =A0 =A0 =A0 =A0 'title':'Standard =A0Template with File->Exit men= u', >>> > =A0 =A0 =A0 =A0 =A0 =A0'size':(698, 517), >>> > =A0 =A0 =A0 =A0 =A0 =A0'style':['resizeable'], >>> > >>> > =A0 =A0 =A0 =A0 'menubar': =A0{'type':'MenuBar', >>> > =A0 =A0 =A0 =A0 =A0'menus': [ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 {'type':'Menu', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuFile', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'&File', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0'items': =A0[ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{'type':'MenuItem', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuFileExit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'E&xit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'command':'exit', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 {'type':'Menu', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuOptions', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'Options', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 'items': [ >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{'type':'MenuItem', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'name':'menuOptionsOpenNew', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'label':'Open New\tAlt+N', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'command':'openNew', >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 }, >>> > =A0 =A0 =A0 =A0 =A0] >>> > =A0 =A0 =A0}, >>> > =A0 =A0 =A0 =A0 =A0 'components': [ >>> > >>> > {'type':'TextArea', >>> > =A0 =A0 =A0'name':'TextArea1', >>> > =A0 =A0 'position':(20, 20), >>> > =A0 =A0 =A0'size':(651, 333), >>> > =A0 =A0 }, >>> > >>> > {'type':'Button', >>> > =A0 =A0 =A0'name':'Button1', >>> > =A0 =A0 'position':(559, 376), >>> > =A0 =A0 =A0'label':'Button1', >>> > =A0 =A0 }, >>> > >>> > ] # end components >>> > } # =A0end background >>> > ] # end backgrounds >>> > } } >>> > >>> > class =A0MyBackground(model.MDIParentBackground): >>> > >>> > def on_initialize(self, =A0event): >>> > # if you have any initialization >>> > # including sizer setup, do it =A0here >>> > #MDI.on_initialize(self, event) >>> > pass >>> > def on_openNew_command ( =A0self, event ): >>> > # Create a child window >>> > child =3D model.childWindow(self, =A0MyCW, rsrc=3DMyCW_rsrc) >>> > >>> > if __name__ =3D=3D '__main__': >>> > app =3D =A0model.Application(MyBackground, None, =A0MDI_rsrc) >>> > app.MainLoop() >>> > ############# End of Parent =A0###################### >>> > >>> > ############# Child =A0###################### >>> > class MyCW(model.MDIChildBackground): >>> > >>> > =A0 =A0 def on_initialize(self, event): >>> > =A0 =A0 =A0 self.parent =3D =A0self.getParent() >>> > =A0 =A0 =A0 self.components.TextArea1.text=3D'I am =A0only a child.' >>> > =A0 =A0def on_openNew_command ( self, event ): >>> > =A0 =A0 =A0 =A0return self.parent.on_openNew_command ( event ) >>> > ############# =A0End of Child ###################### >>> > >>> > That's it!!! >>> > >>> > Now I have =A0to play around with resizer to see how that would work >>> > here. >>> > >>> > =A0-- >>> > John =A0Henry >>> > >>> >>> -----------------------------------------------------------------------= ------- >>> Create and publish websites with WebMatrix >>> Use the most popular FREE web apps or write code yourself; >>> WebMatrix provides all the features you need to develop and >>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf >>> >>> _______________________________________________ >>> Pythoncard-users mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/pythoncard-users >>> >> >> >> >> -- >> Mark Carter, OCT >> markcarter.tel >> >> >> >> -- >> Mark Carter, OCT >> markcarter.tel >> >> >> ------------------------------------------------------------------------= ------ >> Create and publish websites with WebMatrix >> Use the most popular FREE web apps or write code yourself; >> WebMatrix provides all the features you need to develop and >> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf >> >> _______________________________________________ >> Pythoncard-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/pythoncard-users >> > > > -------------------------------------------------------------------------= ----- > Create and publish websites with WebMatrix > Use the most popular FREE web apps or write code yourself; > WebMatrix provides all the features you need to develop and > publish your website. http://p.sf.net/sfu/ms-webmatrix-sf > > _______________________________________________ > Pythoncard-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > ---------------------------------------------------------------------------= --- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; = WebMatrix provides all the features you need to develop and = publish your website. http://p.sf.net/sfu/ms-webmatrix-sf