Help Pliz ! stuck on page 4 of tutorial

A

Adolfo

Hello everyone, I am a newbie starting Fredrik Lundh .pdf tutorial. Running W2000.

I am stuck in page four "Hello Again" program:
When I try running it, it shows the root Python window very fast and
dissapears. The intended Tk window with buttons: either does not
show, or dissapears fast before I can tell it is there. The first
program on the tutorial did run fine.

Here's the program as shown on the tutorial:

====================================================
from Tkinter import *

class App:

def_init-(self, master):

frame = Frame(master)
frame.pack()

self.button = Button(frame, text="QUIT", fg="red", comand=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()
===================================================

Any help will be much appreciated,

Adofo Aguirre
Santa Barbara, CA
 
P

Peter Otten

Adolfo said:
Hello everyone, I am a newbie starting Fredrik Lundh .pdf tutorial.
Running W2000.

I am stuck in page four "Hello Again" program:
When I try running it, it shows the root Python window very fast and
dissapears. The intended Tk window with buttons: either does not
show, or dissapears fast before I can tell it is there. The first
program on the tutorial did run fine.

Here's the program as shown on the tutorial:

====================================================
from Tkinter import *

class App:

def_init-(self, master):

frame = Frame(master)
frame.pack()

self.button = Button(frame, text="QUIT", fg="red",
comand=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()
===================================================

Any help will be much appreciated,

Adofo Aguirre
Santa Barbara, CA

If you have cut and pasted here exactly what you fed to the Python,
proofreading should help. (Hint: def_init- and comand)

Peter
 
L

Logan

Hello everyone, I am a newbie starting Fredrik Lundh .pdf tutorial. Running W2000.

I am stuck in page four "Hello Again" program:
When I try running it, it shows the root Python window very fast and
dissapears. The intended Tk window with buttons: either does not
show, or dissapears fast before I can tell it is there. The first
program on the tutorial did run fine.

Here's the program as shown on the tutorial:

You had a lot of typos in your code;
here's a corrected version which should work.

HTH, Thomas.


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()
 
P

Patrick Useldinger

Try this:

from Tkinter import *

class App:
def __init__(self, master): <========= name of constructor
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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top