[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