From Dabo Wiki
Jump to: navigation, search

Normally, you make the value an attribute of the form, or, in the alternative, create a method that returns the value(s) you need. Then when the form is closed, instead of releasing it, simply hide() it. This will end the modal state, and allow processing to continue from the point at which the form was originally shown. You then query the form for the desired values, and when you have them, release the form.

NOTE: - as of Feb. 2007, wxPython still does not support modal forms. Please use dialog classes if you need modal behavior.

If you are using the dOkCancelDialog class as your base, it has a property called Accepted that is set to True if they click OK, and False if they click Cancel. That way you know whether to process the results or not. It is generally easier to work with dialogs when you need modal states, as wxPython doesn't handle modal forms very well.



class ExampleDialog(dabo.ui.dOkCancelDialog):
   def addControls(self):
      # add your controls here

dlg = ExampleDialog()
if dlg.Accepted:
   self.doSomethingWithNames(dlg.firstname, dlg.lastname)

Modal Form:

frm = dabo.ui.dForm(None)
# NOTE: this doesn't show modally (yet)
firstname, lastname = frm.getNames()
if firstname is not None:
   self.doSomethingWithNames(firstname, lastname)