Tkinter menu

#!/usr/bin/python

from tkinter import *
from tkinter.filedialog import *
import Pmw
import os

def FileOpen():
 r = askopenfilename(title = 'Python Tkinter')
 return r
 #print (os.path.abspath(r))

 
def About_button():
 Pmw.aboutversion('1.0')
 Pmw.aboutcopyright('Copyright My Company 2012\nAll rights reserved')
 Pmw.aboutcontact(

            'For information about this application contact:\n' +

            '  My Help Desk\n' +

            '  Phone: +61 2 9876 5432\n' +

            '  Email: [email protected]'

        )

 about = Pmw.AboutDialog(applicationname = 'Build Tools')
 about.withdraw()
 about.show()
 
root =Tk()
menu = Menu(root)

submenu = Menu(menu,tearoff=0)
submenu.add_command(label='Open',command = FileOpen)
submenu.add_command(label='Save')
submenu.add_command(label='Close',underline=0,command=root.quit)
menu.add_cascade(label='File',menu=submenu)

submenu1 = Menu(menu,tearoff=0)
submenu1.add_command(label='Copy')
submenu1.add_command(label='Paste')
submenu1.add_separator()
submenu1.add_command(label='Cut')
menu.add_cascade(label='Edit',menu=submenu1)

submenu2 = Menu(menu,tearoff=0)
submenu2.add_command(label='About',command = About_button)
menu.add_cascade(label='Help',menu=submenu2)

root.config(menu=menu)

lan=('Python','Perl','Ruby','Java','C','C++','VB','Makefile','PHP','.NET','GO','PL/SQL','Delphi')
combox=Pmw.ComboBox(root,label_text='Play:',labelpos='wn',scrolledlist_items=lan)
combox.selectitem(lan[0])
combox.pack(side = RIGHT)

root.mainloop()

你可能感兴趣的:(menu)