[Tutor] Tkinter mainloop (was Re: tkFileDialog.Directory)

K.Weinert@gmx.net K.Weinert at gmx.net
Wed Nov 16 10:55:24 CET 2005


Hello Michael, hello list,

thanks for the info that pmw displays exceptions.
What I don't understand is

>> --- snip ---  
>> import Tix
>> 
>> def raise_exception():
>>   print 1/0
>>   
>> if __name__ == '__main__':
>>     root = Tix.Tk()
>>     root.title("Exception demo")
>> 
>>     Tix.Button(root, text = "Don't press", command =
raise_exception).pack()
>> 
>>     try:
>>       root.mainloop()
>>     except:
>>       print "An error has occured."
>> --- snip ---
>> 
>> The except part gets never executed.

> That's because the error isn't in the mainloop() method

I thought the mainloop() function is something like

def mainloop():
  e= get_event()
  if e:
    for w in widgets: w.handle(e)

but apparently it is not.

It's not bad that the Tkinter windows don't destroy upon an exception,
since it gives me the option to display an error window, but I feel unsafe
unless I understand why it does not.

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie


More information about the Tutor mailing list