944,052 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 2783
  • Python RSS
Nov 28th, 2005
0

Tkinter exception

Expand Post »
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:
Python Syntax (Toggle Plain Text)
  1. from Tkinter import *
  2.  
  3. root = Tk ( )
  4.  
  5. my_container = Frame ( root )

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

and Exception message is:
Python Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 55
Solved Threads: 6
Junior Poster
Micko is offline Offline
148 posts
since Aug 2005
Nov 28th, 2005
0

Re: Tkinter exception

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 ...
Python Syntax (Toggle Plain Text)
  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()
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Nov 29th, 2005
0

Re: Tkinter exception

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:

Python Syntax (Toggle Plain Text)
  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
Reputation Points: 55
Solved Threads: 6
Junior Poster
Micko is offline Offline
148 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: TKinter tough time
Next Thread in Python Forum Timeline: using distutils to install a python module





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC