Re: Tkinter app=App(root) problem
- From: Steve Holden <steve@xxxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 11:11:06 -0400
snoylr@xxxxxxxxx wrote:
This is my first day working with Tkinter. I'm using python2.3 on WindowsXP. I found this program and entered it.
from Tkinter import *
class App: def _init_(self,master):
^^^^^^
This should be __init__ (the underscores should be doubled). Python "magic methods" are all named in this way.
That's not strictly true. Nothing *appears* to happen, because the same error message is produced but there's no windows console to display it in.frame = Frame(master) frame.pack()
self.button = Button(frame, text = "Quit", fg = "red", command =frame.quit) self.button.pack(side=LEFT)
self.hi_there = Button(frame, text = "Hello", command = self.say_hi) self.hi_there.pack(side=LEFT)
def say_hi(self): print "hi there, everyone!"
root = Tk() app = App(root) root.mainloop()
When I run the code in IDLE I get the initial frame but no buttons with the following error:
Traceback (most recent call last): File "C:\Documents and Settings\INTERNET\Desktop\hello2.py", line 18, in ? app = App(root) TypeError: this constructor takes no arguments
I have also tried to save the program as with a pyw extension. Nothing happens when I try to run it with that extension.
regards Steve -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/
.
- References:
- Tkinter app=App(root) problem
- From: snoylr
- Tkinter app=App(root) problem
- Prev by Date: Re: Fwd: how to find the drive in python/cygwin?
- Next by Date: Re: large dictionary creation takes a LOT of time.
- Previous by thread: Tkinter app=App(root) problem
- Next by thread: mbx repair script: Python vs perl
- Index(es):