Tkinter problem

Benson Ngai benson123456 at yahoo.com
Sun Nov 3 20:51:42 EST 2002


Hi all,
I run into a little problem when I am try to wrtie a Tkinter
interface.
I am trying to have a "About" option on a Menu bar. once the user
click on it. a subwindow will pop up and display a message. and in
this sub windows I wanna have a "OK" Button so when the user click on
it it would close itself. I tried to use the .quit command, it closes
the whole program instead. Is there another command that I can use so
that it just close that 1 sub windows? here is the code!

Thank you very much.

Benson


def PopAboutWin():
  aboutText = "Mastermind ver 1.0 "
  msgWin=Toplevel(root)
  msg=Message(msgWin,text=aboutText)
  okButton=Button(msgWin,text="OK",command=msgWin.quit,justify=CENTER)
  #^^^^^^ Problem on this line^^^^^^^^^^^^^^^^^^^^^######
  msg.pack()
  okButton.pack()


root=Tk()
frame=Frame(root,width=640,height=640)#main Screen

menuBar=Menu(root)#menuBar on top of the screen
fileMenu=Menu(menuBar,tearoff=0)
#fileMenu.add_command(label="File",command=FileMenu)#item in the
menuBar
fileMenu.add_command(label="New Game",command=FileMenu)#ResetTheGame
fileMenu.add_command(label="Exit",command=root.quit)
menuBar.add_cascade(label="File",menu=fileMenu)
menuBar.add_command(label="Help",command=PopHelpWin)
menuBar.add_command(label="About",command=PopAboutWin)
root.config(menu=menuBar)

frame.pack()
root.mainloop()



More information about the Python-list mailing list