Yes, apply is invoked when I click OK. apply has one statement, and
returns to the caller, which then checks the validity (try-except) of
values passed back to it. It seems like apply should do all the
try-except work instead. The code spends quite a few lines setting
things up to pass back. I've thought this setup was odd when I first
looked at it, and think the author went to too much trouble to put the
try-except back to the caller to the dialog.
What I really need are checks like is lat (latitude) from -90 to +90,
and not -700, say. That is bound checking.
I have implemented the config file stuff from weeks ago without need of
any config libraries. I did that just to get on with matters, but I may
have to use, say, ObjectConfig (or Parse-whatever) to do bound
checking. I have no idea those config modules would help in this
matter. If not, I'll just do it the old fashioned way -- if statements.
Alan Gauld wrote:
"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.
--
Signature.html
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
“Life is one damn thing after another."
-- Mark Twain
|
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor