Tkinter menu crash
Nicholas Cannon
nicholascannon1 at gmail.com
Tue Aug 5 08:15:35 EDT 2014
Ok so the first part of the program(until the start of the menu) worked fine. It ran and did what I wanted it to do. I wanted to then implement a new menu(for practise) and then it crashes. Don't know why but it just crashes. (also tips on the code will be appreciated and I gave just started Tkinter programming)
Here is the code:
from Tkinter import *
import tkMessageBox as tm
def submit():
#message box with yes no
tm.askyesno(title='Submit Text', message='Are you sure....')
def info():
tm.showinfo(title='About', message='Just a test Tkinter UI sample')
#getting the text from the entrybox and
#packs it into a label
mtext = text.get()
label1 = Label(app, text=mtext)
label1.pack()
#root window setup
root = Tk()
root.geometry('480x480+200+200')
root.title('Basic Tk UI')
#frame set up
app = Frame(root)
app.pack()
#variable and entry box set up
text = StringVar()
entry = Entry(app, textvariable=text)
entry.pack()
#button set up
button1 = Button(app, text='Submit text', command= submit)
button1.pack()
#menu construction
menubar = Menu(root)
filemenu = Menu(menubar)
filemenu.add_command(label='About', command= info)
filemenu.add_command(label='Quit', command= root.destroy)
filemenu.add_cascade(label='TK UI Sample', menu=filemenu)
root.config(menu=menubar)
#loop to listen for events
root.mainloop()
More information about the Python-list
mailing list