"Wayne Watson" <sierra_mtnv...@sbcglobal.net> wrote

The program I'm modifying uses something of a primitive way
to check the validity of values entered into widgets on a larger dialog.

You can bind events to the individual entry widgets to check values
when you navigate away from the widget. Or even on each keypress...

...Isn't this supposed to be done in the apply method for the dialog?

I believe so. That is where you would check the data consisterncy/integrity
across all the widgets in the dialog. From your question it seems you
don't think the apply() is getting called?

A typical data widget inside the  set operations dialog class is:

class OperationalSettingsDialog(tkSimpleDialog.Dialog):

   def __init__(self, parent, sdict):
       self.sdict = sdict
       tkSimpleDialog.Dialog.__init__(self, parent)

   def body(self,master):
       self.title("Operational Settings")
            ...
        # data widget
Label( master, text="Max Hourly Event Rate: ").grid(row=5, sticky=W)
       self.rateVar = StringVar()
Entry(master, width=10, textvariable=self.rateVar).grid(row=5, column=1)
       self.rateVar.set( "%s" % self.sdict["hourly_rate"] )
            ...
   def apply(self):
       self.sdict["ok"] = True
   #END of class

Furthermore, doesn't the use of tkSimpleDialog.Dialog provide an OK
and Cancel button, which upon use causes the the invocation of the
apply method to depart?

Again I believe so but I'm no expert on SimpleDialog. I usually just write
my own dialogs based on Toplevel... Just habit.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to