From: Kevin A. <al...@se...> - 2001-10-28 19:20:51
|
I had an import conflict problem with putting the GenericDialog class into dialog.py that I was unable to track down, so I just checked it in as dialognew.py. The example code below should work without changes. ka > -----Original Message----- > From: pyt...@li... > [mailto:pyt...@li...]On Behalf Of Kevin > Altis > Sent: Monday, October 15, 2001 4:21 PM > To: pythoncard-Users > Subject: [Pythoncard-users] modal dialogs for PythonCard > > > I am pleased to say that after some false starts yesterday and today, some > email exchanges with Robin, a bit of inspiration, and a generous > donation to > the god of kludge, we are close to having generic modal dialogs in > PythonCard. I've included an example below. > > The nice thing about the modal dialogs is that they work almost > identically > to the Background class. They don't have a menubar or a background image, > but all of the widgets that we have now should work in the modal > dialog and > the attribute and event handlers work identically. > > Well not quite identically. Both the default button and the cancel buttons > need to call event.skip() and you have to add an id attribute to the > resource > > I'm going to mull over this tonight before putting the code into cvs, but > I'll post when I do. I have some other issues I want to address on this > topic, but I have to run right now, so I'll post on those issues later as > well. > > ka > --- > > class FindDialog(PythonCardPrototype.dialognew.GenericDialog): > def __init__(self, aBg, searchText='', wholeWordsOnly=0, > caseSensitive=0) : > # load the resource > aDialogRsrc = > PythonCardPrototype.res.ResourceFile('find.rsrc.py').getResource() > > PythonCardPrototype.dialognew.GenericDialog.__init__(self, aBg, > aDialogRsrc) > > # if some special setup is necessary, do it here > self.components.fldFind.text = searchText > self.components.chkMatchWholeWordOnly.checked = wholeWordsOnly > self.components.chkMatchCase.checked = caseSensitive > > print "init done" > > def on_btnFindNext_mouseClick(self, target, event): > print "btnFindNext" > print self.components.fldFind.text > event.skip() > > def on_btnCancel_mouseClick(self, target, event): > print "btnCancel" > event.skip() > > class Minimal(PythonCardPrototype.model.Background): > > def on_btnFind_mouseClick(self, target, event): > dlg = FindDialog(self) > dlg.showModal() > print "fldFind", dlg.components.fldFind.text > print "chkMatchWholeWordOnly", > dlg.components.chkMatchWholeWordOnly.checked > print "chkMatchCase", dlg.components.chkMatchCase.checked > print "FindDialog result:\naccepted: %s\nreturned: %s\n" % > (dlg.accepted(), dlg.returned()) > dlg.destroy() > > > --- > > {'type':'GenericDialog', > #'file':'find.py', > 'classname':'Find', > 'name':'dlgFind', > 'title':'Find dialog', > 'position':(5, 5), > 'size':(370, 120), > 'components': [ > > {'type':'StaticText', > 'name':'stcFindWhat', > 'position':(7, 10), > 'text':'Find What:', > }, > > {'type':'TextField', > 'name':'fldFind', > 'position':(70, 7), > 'size':(195, -1), > }, > > {'type':'Button', > 'name':'btnFindNext', > 'position':(280, 5), > 'label':'Find Next', > 'id':5100, > }, > > {'type':'Button', > 'name':'btnCancel', > 'position':(280, 35), > 'label':'Cancel', > 'id':5101, > }, > > {'type':'CheckBox', > 'name':'chkMatchWholeWordOnly', > 'position':(7, 35), > 'label':'Match whole word only', > }, > > {'type':'CheckBox', > 'name':'chkMatchCase', > 'position':(7, 55), > 'label':'Match case', > }, > > ] # end components > } # end GenericDialog > > > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > |