Re: Tkinter app=App(root) problem

2005-04-30 Thread Steve Holden
[EMAIL PROTECTED] 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.

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.
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.

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/
--
http://mail.python.org/mailman/listinfo/python-list


Tkinter app=App(root) problem

2005-04-30 Thread snoylr
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):
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.

-- 
http://mail.python.org/mailman/listinfo/python-list