RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 1818 | Replies: 2
Reply
Join Date: Aug 2005
Location: Bosnia and Herzegovina
Posts: 147
Reputation: Micko is on a distinguished road 
Rep Power: 4
Solved Threads: 1
Micko Micko is offline Offline
Junior Poster

Tkinter exception

  #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:
from Tkinter import *

root = Tk ( ) 

my_container = Frame ( root )

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

and Exception message is:
AttributeError: __nonzero__

Traceback (innermost last):

File "c:\PythonProjects\GUILearning\SimpleGUI2.py", line 1, in ?
  from Tkinter import *
File "c:\PythonProjects\GUILearning\SimpleGUI2.py", line 5, in ?
  my_container = Frame(root)
File "C:\Python24\Lib\lib-tk\Tkinter.py", line 2374, in __init__
  Widget.__init__(self, master, 'frame', cnf, {}, extra)
File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1855, in __init__
  BaseWidget._setup(self, master, cnf)
File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1828, in _setup
  if not master:
File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1647, in __getattr__
  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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 2,536
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Tkinter exception

  #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 ...
from Tkinter import *

root = Tk()

my_container = Frame(root, width=100, height=100, bg='red')
my_container.pack()

root.mainloop()
May 'the Google' be with you!
Reply With Quote  
Join Date: Aug 2005
Location: Bosnia and Herzegovina
Posts: 147
Reputation: Micko is on a distinguished road 
Rep Power: 4
Solved Threads: 1
Micko Micko is offline Offline
Junior Poster

Re: Tkinter exception

  #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:

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

- Micko
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:14 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC