From: Kevin A. <al...@se...> - 2002-01-03 23:36:57
|
I've modified the Background class in model.py so that it accepts a parent window as its second parameter rather than an id. We weren't using the id and this simple change makes it possible to use existing backgrounds as child windows of the main window without any big modifications to the rest of the framework. For example, I only had to change one line in the example below, passing self instead of -1. > self.doodleWindow = doodle.Doodle(self.stack, > -1, > rsrc, > rsrc.stack.backgrounds[0]) is now: self.doodleWindow = doodle.Doodle(self.stack, self, rsrc, rsrc.stack.backgrounds[0]) The initialization of the background used by the samples isn't changed; they all use the openBackground event to do initialization, rather than relying on __init__. This is not the final solution to the multi-window problem, just a simple way for us to start experimenting. I know Andy wanted multiple backgrounds for dbBrowser. The Message Watcher correctly shows events for all backgrounds. The Property Editor will only show components of the main background window. ka > -----Original Message----- > From: pyt...@li... > [mailto:pyt...@li...]On Behalf Of Kevin > Altis > Sent: Sunday, December 30, 2001 11:09 PM > To: pythoncard-Users > Subject: [Pythoncard-users] tentative multi-window success > > > I was playing around tonight and decided to try an experiment. I > duplicated > the minimal directory and renamed it to 'multiwindow', then I copied the > doodle.py and doodle.rsrc.py sample files into the 'multiwindow' > directory. > I added some imports to the minimal.py source file and an openBackground > handler to load the resource file for doodle and code to create another > background window. The source is below. Absolutely no changes were made to > the doodle files. > > Get this, it worked the first time! The minimal window came up along with > the doodle window and all the events worked fine. Exiting is a problem > because the doodle window was not really a child of the minimal window, so > both windows have to be closed separately, but I know how to fix that. I > love being surprised. > > There are a number of places where the Background class needs to > be tweaked > and of course there are other issues, especially with the runtime debug > windows, but it looks very promising. So just imagine that any > 'background' > can easily be used as part of your own program. Not a bad way to start the > new year. > > We're more or less already doing this kind of thing with the GenericDialog > windows and it makes me think that perhaps it might be better if each > background resource was put in its own file. We also need to move the > menubar as an attribute of the background instead of the stack, but that's > another easy change. > > I just want to say that Rowland Smith's original framework is still pretty > excellent kung fu! Kudos to Robin Dunn as well for wxPython and his other > contributions as well as everyone else on the mailing list that has helped > get PythonCard this far. This is so cool. > > Happy New Year, > > ka > --- > > from PythonCardPrototype import model, res > import doodle > > class Minimal(model.Background): > def on_openBackground(self, target, event): > rsrc = res.ResourceFile('doodle.rsrc.py').getResource() > self.doodleWindow = doodle.Doodle(self.stack, > -1, > rsrc, > rsrc.stack.backgrounds[0]) > self.doodleWindow.Show() > > def on_menuFileExit_select(self, menu, event): > self.Close() > > if __name__ == '__main__': > app = model.PythonCardApp(Minimal) > app.MainLoop() > > > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > |