472,119 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Tkinter error

Finally started trying to build a simple gui form for inserting text
data into a mysql db of quotations.

I found this nice Tkinter tutorial,

http://www.ibiblio.org/obp/py4fun/gui/tkPhone.html

but midway I'm getting an error.

from Tkinter import *
>>win = Tk()
f = Frame(win)
b1 = Button(f, "One")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1936, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1859, in __init__
BaseWidget._setup(self, master, cnf)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1839, in _setup
if cnf.has_key('name'):
AttributeError: 'str' object has no attribute 'has_key'

May 28 '07 #1
2 2002
BartlebyScrivener wrote:
Finally started trying to build a simple gui form for inserting text
data into a mysql db of quotations.

I found this nice Tkinter tutorial,

http://www.ibiblio.org/obp/py4fun/gui/tkPhone.html

but midway I'm getting an error.

from Tkinter import *
>>win = Tk()
f = Frame(win)
b1 = Button(f, "One")

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1936, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1859, in __init__
BaseWidget._setup(self, master, cnf)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1839, in _setup
if cnf.has_key('name'):
AttributeError: 'str' object has no attribute 'has_key'
Hmm, there must have been an update to that tutorial after you read it:

"""
>>b1 = Button(win,text="One")
b2 = Button(win,text="Two")

The class Button takes the parent window as the first argument. As we will
see later other objects, such as frames, may also act as parents. The rest
of the arguments are passed by keyword and are all optional.
"""

Peter
May 28 '07 #2
On May 28, 4:57 pm, Peter Otten <__pete...@web.dewrote:
>b1 = Button(win,text="One")
b2 = Button(win,text="Two")
That worked. Thank you.

Rick

May 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mickel Grönroos | last post: by
2 posts views Thread by codecraig | last post: by
4 posts views Thread by Peter G Carswell | last post: by
1 post views Thread by Michael Yanowitz | last post: by
5 posts views Thread by Ben Kovitz | last post: by
4 posts views Thread by Kevin Walzer | last post: by
2 posts views Thread by Kevin Walzer | last post: by
1 post views Thread by vijayca | last post: by
8 posts views Thread by karthikbalaguru | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.