[Tutor] help

2005-08-08 Thread Dan Deternova
i am making a simple script to get the hang of Tkinter. i want to use the input of the user from a Entry and calcuate the area. i have tryied many way... as you can see in my script.   the Entry is under def area():  and the output i want is under def cal():  ... please help me fix my code and explain to me what you did.. thanks in advance.
[EMAIL PROTECTED]
#program made and maintained by Dan Deternova
#start of program

from Tkinter import *   
# tells computer we are using Tkinter modual
from tkMessageBox import *
def cal():
win4 = Toplevel
print 'area = ', 'w'*'h'
def notyet():
showerror('not yet avalable')

win = Tk()  
# makes windows and has value for Tk
def makemenu(Tk):
top = Menu(win)
win.config(menu=top)

file = Menu(top)
file.add_command(label='save your name', command=newwin, underline=0)
file.add_command(label='quit', command=win.destroy, underline=0)
file.add_command(label='quit all', command=win.quit, underline=0)
top.add_cascade(label='file', menu=file, underline=0)
edit = Menu(top, tearoff=0)
edit.add_command(label='copy', command=notyet, underline=0)
edit.add_command(label='paste', command=notyet, underline=0)
edit.add_command(label='quit', command=win.destroy, underline=0)
top.add_cascade(label='edit', menu=edit, underline=0)


def newwin():   
# callback to define button newwin.
win2 = Toplevel()   
# makes new window when button is pressed. named win2
widget = Label(win2, text='your name here').pack()  
# line 'type your name here' is printed on top of entry
name = StringVar()
widget = Entry(win2, textvariable=name).pack()  
# makes entry in new window at the top.
widget = Label(win2, text='age here').pack()
# prints the line 'age here'
age = StringVar()
widget = Entry(win2, textvariable=age).pack()   
# makes entry
widget = Label(win2, text='type your address here').pack()
address = StringVar()
widget = Entry(win2, textvariable=address).pack()
def save():
 f=file('fname','a')
 f.write(name.get()+'\n')
 f.write(age.get()+'\n')
 f.write(address.get()+'\n')

widget = Button(win2, text='save', command=save).pack(side=LEFT)
widget = Button(win2, text='quit', command=win2.destroy).pack(side=RIGHT)
def area():
win3 = Toplevel()
widget = Label(win3, text='type hieght here: ').pack()
h = StringVar()
widget = Entry(win3, textvariable=h).pack()
widget = Label(win3, text='type width here:  ').pack()
w = StringVar()
widget = Entry(win3, textvariable=w).pack()
widget = Button(win3, text=' calculate ', command=cal).pack(side=BOTTOM, 
expand=YES, fill=BOTH)
fontentry = ('times', 20, 'bold')   
# (font, size, style) defonision for fontentry. will be used later 
on in the program
widget = Entry(win, text='type here')   
# makes entry point in 'win'
makemenu(win)
widget.config(font=fontentry)   
# makes the font of entry equal to 'fontentry'
widget.config(bg='black', fg='yellow')  
# makes the background (bg) black and the forground (text) yellow
widget.pack(side=TOP, expand=YES, fill=BOTH)
# 'packs' the entry on top of win and expands and fill the Y axes
widget = Button(win, text="your name", command=newwin).pack(side=LEFT, 
expand=YES, fill=BOTH)# creates button that says 'your name'. see newwin 
callback for output.
widget = Button(win, text='quit all', command=win.quit).pack(side=BOTTOM, 
expand=YES, fill=BOTH)
widget = Button(win, text='quit', command=win.destroy).pack(side=RIGHT, 
expand=YES, fill=BOTH)
widget = Button(win, text='area', command=area).pack(side=LEFT, expand=YES, 
fill=BOTH)
win.title('my program')

#end of program

 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help

2005-08-09 Thread Dan Deternova
ok. i know python and want to turn all my programs i made when i was learning python into Tkinter programs. i dont know how to make if satments and display the output  like this in python: 
if cmd == quit:
 print "press exit to quit"
 
i have no idea how to do that in Tkinter please help.  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor