Tkinter exception

Reply

Join Date: Aug 2005
Posts: 148
Reputation: Micko is on a distinguished road 
Solved Threads: 6
Micko Micko is offline Offline
Junior Poster

Tkinter exception

 
0
  #1
Nov 28th, 2005
Hello,
I start learning Python GUI using Tkinter
as IDE I'm using wing IDE 2.0.3 trial.
I'm using Tkinter mainly because of very good debugger.
Belive it or not I get exception in this code:
  1. from Tkinter import *
  2.  
  3. root = Tk ( )
  4.  
  5. my_container = Frame ( root )

Exception is generated in file Tkinter.py in line:
  1. def __getattr__(self, attr):
  2. "Delegate attribute access to the interpreter object"
  3. return getattr(self.tk, attr)

and Exception message is:
  1. AttributeError: __nonzero__
  2.  
  3. Traceback (innermost last):
  4.  
  5. File "c:\PythonProjects\GUILearning\SimpleGUI2.py", line 1, in ?
  6. from Tkinter import *
  7. File "c:\PythonProjects\GUILearning\SimpleGUI2.py", line 5, in ?
  8. my_container = Frame(root)
  9. File "C:\Python24\Lib\lib-tk\Tkinter.py", line 2374, in __init__
  10. Widget.__init__(self, master, 'frame', cnf, {}, extra)
  11. File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1855, in __init__
  12. BaseWidget._setup(self, master, cnf)
  13. File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1828, in _setup
  14. if not master:
  15. File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1647, in __getattr__
  16. return getattr(self.tk, attr)

However, if I just execute file everything seems to work, I tried in IDLE and there
are no exceptions there. What could that be, maybe it's an IDE bug?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,003
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 928
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Tkinter exception

 
0
  #2
Nov 28th, 2005
Since the frame is empty and you are not packing it into the root, my IDE ignores it, no errors. Your IDE may have a lint filter built in and looks at this as uncompleted code!

This would be the more normal way to do something with a frame ...
  1. from Tkinter import *
  2.  
  3. root = Tk()
  4.  
  5. my_container = Frame(root, width=100, height=100, bg='red')
  6. my_container.pack()
  7.  
  8. root.mainloop()
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 148
Reputation: Micko is on a distinguished road 
Solved Threads: 6
Micko Micko is offline Offline
Junior Poster

Re: Tkinter exception

 
0
  #3
Nov 29th, 2005
It's same exception again!
in line:
my_container = Frame(root, width=100, height=100, bg='red')
so to get rid off it I write:

  1. try:
  2. my_container = Frame(root, width=100, height=100, bg='red')
  3. except: pass
What is interesting is that exception is raised only in Debug mode...

- Micko
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC