from menu_frm import makemenu from tkinter import * root = Tk() for i in range(3): frm = Frame() mnu = makemenu(frm) mnu.config(bd=2, relief=RAISED) frm.pack(expand=YES, fill=BOTH) Label(frm, bg='black', height=5, width=25).pack(expand=YES, fill=BOTH) Button(root, text='Bye', command=root.quit).pack() root.mainloop()
from menu_frm import makemenu # can't use menu_win here--one window from tkinter import * # but can attach frame menus to windows root = Tk() for i in range(2): # 2 menus nested in one window mnu = makemenu(root) mnu.config(bd=2, relief=RAISED) Label(root, bg='black', height=5, width=25).pack(expand=YES, fill=BOTH) Button(root, text="Bye", command=root.quit).pack() root.mainloop()
from menu_frm import makemenu # can't use menu_win here--one window from Tkinter import * # but can attach from menus to windows root = Tk( ) for i in range(2): # 2 menus nested in one window mnu = makemenu(root) mnu.config(bd=2, relief=RAISED) Label(root, bg='black', height=5, width=15).pack(expand=YES, fill=BOTH) Button(root, text="Bye", command=root.quit).pack( ) root.mainloop( )
from menu_frm import makemenu # can't use menu_win here--root=Frame from Tkinter import * root = Tk( ) for i in range(3): # Three menus nested in the containers frm = Frame( ) mnu = makemenu(frm) mnu.config(bd=2, relief=RAISED) frm.pack(expand=YES, fill=BOTH) Label(frm, bg='black', height=5, width=15).pack(expand=YES, fill=BOTH) Button(root, text="Bye", command=root.quit).pack( ) root.mainloop( )
#!python3 # menu_frm_multi.py - 基于框架的菜单,可以作为其它部件的组件包 from menu_frm import makemenu from tkinter import * root = Tk() for i in range(3): frm = Frame() menubar = makemenu(frm) menubar.config(bd=2, relief=RAISED) frm.pack(expand=YES, fill=BOTH) Label(frm, text='Menu %s based on Frame' % i, bg='black', fg='yellow', height=5, width=25).pack(expand=YES, fill=BOTH) Button(root, text='Bye', command=root.quit).pack() root.mainloop()