本文整理汇总了Python中tkinter.Menu.add_radiobutton方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.add_radiobutton方法的具体用法?Python Menu.add_radiobutton怎么用?Python Menu.add_radiobutton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Menu
的用法示例。
在下文中一共展示了Menu.add_radiobutton方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self):
menubar = Menu(self._top)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label='Print to Postscript', underline=0,
command=self._cframe.print_to_file,
accelerator='Ctrl-p')
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-x')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
zoommenu = Menu(menubar, tearoff=0)
zoommenu.add_radiobutton(label='Tiny', variable=self._size,
underline=0, value=10, command=self.resize)
zoommenu.add_radiobutton(label='Small', variable=self._size,
underline=0, value=12, command=self.resize)
zoommenu.add_radiobutton(label='Medium', variable=self._size,
underline=0, value=14, command=self.resize)
zoommenu.add_radiobutton(label='Large', variable=self._size,
underline=0, value=28, command=self.resize)
zoommenu.add_radiobutton(label='Huge', variable=self._size,
underline=0, value=50, command=self.resize)
menubar.add_cascade(label='Zoom', underline=0, menu=zoommenu)
self._top.config(menu=menubar)
示例2: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self, parent):
menubar = Menu(parent)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Exit", underline=1, command=self.destroy, accelerator="q")
menubar.add_cascade(label="File", underline=0, menu=filemenu)
actionmenu = Menu(menubar, tearoff=0)
actionmenu.add_command(label="Next", underline=0, command=self.next, accelerator="n, Space")
actionmenu.add_command(label="Previous", underline=0, command=self.prev, accelerator="p, Backspace")
menubar.add_cascade(label="Action", underline=0, menu=actionmenu)
optionmenu = Menu(menubar, tearoff=0)
optionmenu.add_checkbutton(
label="Remove Duplicates",
underline=0,
variable=self._glue.remove_duplicates,
command=self._toggle_remove_duplicates,
accelerator="r",
)
menubar.add_cascade(label="Options", underline=0, menu=optionmenu)
viewmenu = Menu(menubar, tearoff=0)
viewmenu.add_radiobutton(label="Tiny", variable=self._size, underline=0, value=10, command=self.resize)
viewmenu.add_radiobutton(label="Small", variable=self._size, underline=0, value=12, command=self.resize)
viewmenu.add_radiobutton(label="Medium", variable=self._size, underline=0, value=14, command=self.resize)
viewmenu.add_radiobutton(label="Large", variable=self._size, underline=0, value=18, command=self.resize)
viewmenu.add_radiobutton(label="Huge", variable=self._size, underline=0, value=24, command=self.resize)
menubar.add_cascade(label="View", underline=0, menu=viewmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="About", underline=0, command=self.about)
menubar.add_cascade(label="Help", underline=0, menu=helpmenu)
parent.config(menu=menubar)
示例3: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self, parent):
menubar = Menu(parent)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='q')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
actionmenu = Menu(menubar, tearoff=0)
actionmenu.add_command(label='Next', underline=0,
command=self.next, accelerator='n, Space')
actionmenu.add_command(label='Previous', underline=0,
command=self.prev, accelerator='p, Backspace')
menubar.add_cascade(label='Action', underline=0, menu=actionmenu)
optionmenu = Menu(menubar, tearoff=0)
optionmenu.add_checkbutton(label='Remove Duplicates', underline=0,
variable=self._glue.remove_duplicates,
command=self._toggle_remove_duplicates,
accelerator='r')
menubar.add_cascade(label='Options', underline=0, menu=optionmenu)
viewmenu = Menu(menubar, tearoff=0)
viewmenu.add_radiobutton(label='Tiny', variable=self._size,
underline=0, value=10, command=self.resize)
viewmenu.add_radiobutton(label='Small', variable=self._size,
underline=0, value=12, command=self.resize)
viewmenu.add_radiobutton(label='Medium', variable=self._size,
underline=0, value=14, command=self.resize)
viewmenu.add_radiobutton(label='Large', variable=self._size,
underline=0, value=18, command=self.resize)
viewmenu.add_radiobutton(label='Huge', variable=self._size,
underline=0, value=24, command=self.resize)
menubar.add_cascade(label='View', underline=0, menu=viewmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label='About', underline=0,
command=self.about)
menubar.add_cascade(label='Help', underline=0, menu=helpmenu)
parent.config(menu=menubar)
示例4: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self):
self._result_size = IntVar(self.top)
menubar = Menu(self.top)
filemenu = Menu(menubar, tearoff=0, borderwidth=0)
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-q')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
rescntmenu = Menu(editmenu, tearoff=0)
rescntmenu.add_radiobutton(label='20', variable=self._result_size,
underline=0, value=20, command=self.set_result_size)
rescntmenu.add_radiobutton(label='50', variable=self._result_size,
underline=0, value=50, command=self.set_result_size)
rescntmenu.add_radiobutton(label='100', variable=self._result_size,
underline=0, value=100, command=self.set_result_size)
rescntmenu.invoke(1)
editmenu.add_cascade(label='Result Count', underline=0, menu=rescntmenu)
menubar.add_cascade(label='Edit', underline=0, menu=editmenu)
self.top.config(menu=menubar)
示例5: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self):
self._result_size = IntVar(self.top)
self._cntx_bf_len = IntVar(self.top)
self._cntx_af_len = IntVar(self.top)
menubar = Menu(self.top)
filemenu = Menu(menubar, tearoff=0, borderwidth=0)
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-q')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
rescntmenu = Menu(editmenu, tearoff=0)
rescntmenu.add_radiobutton(label='20', variable=self._result_size,
underline=0, value=20,
command=self.set_result_size)
rescntmenu.add_radiobutton(label='50', variable=self._result_size,
underline=0, value=50,
command=self.set_result_size)
rescntmenu.add_radiobutton(label='100', variable=self._result_size,
underline=0, value=100,
command=self.set_result_size)
rescntmenu.invoke(1)
editmenu.add_cascade(label='Result Count', underline=0, menu=rescntmenu)
cntxmenu = Menu(editmenu, tearoff=0)
cntxbfmenu = Menu(cntxmenu, tearoff=0)
cntxbfmenu.add_radiobutton(label='60 characters',
variable=self._cntx_bf_len,
underline=0, value=60,
command=self.set_cntx_bf_len)
cntxbfmenu.add_radiobutton(label='80 characters',
variable=self._cntx_bf_len,
underline=0, value=80,
command=self.set_cntx_bf_len)
cntxbfmenu.add_radiobutton(label='100 characters',
variable=self._cntx_bf_len,
underline=0, value=100,
command=self.set_cntx_bf_len)
cntxbfmenu.invoke(1)
cntxmenu.add_cascade(label='Before', underline=0, menu=cntxbfmenu)
cntxafmenu = Menu(cntxmenu, tearoff=0)
cntxafmenu.add_radiobutton(label='70 characters',
variable=self._cntx_af_len,
underline=0, value=70,
command=self.set_cntx_af_len)
cntxafmenu.add_radiobutton(label='90 characters',
variable=self._cntx_af_len,
underline=0, value=90,
command=self.set_cntx_af_len)
cntxafmenu.add_radiobutton(label='110 characters',
variable=self._cntx_af_len,
underline=0, value=110,
command=self.set_cntx_af_len)
cntxafmenu.invoke(1)
cntxmenu.add_cascade(label='After', underline=0, menu=cntxafmenu)
editmenu.add_cascade(label='Context', underline=0, menu=cntxmenu)
menubar.add_cascade(label='Edit', underline=0, menu=editmenu)
self.top.config(menu=menubar)
示例6: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self, parent):
menubar = Menu(parent)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label='Reset Parser', underline=0,
command=self.reset, accelerator='Del')
filemenu.add_command(label='Print to Postscript', underline=0,
command=self.postscript, accelerator='Ctrl-p')
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-x')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label='Edit Grammar', underline=5,
command=self.edit_grammar,
accelerator='Ctrl-g')
editmenu.add_command(label='Edit Text', underline=5,
command=self.edit_sentence,
accelerator='Ctrl-t')
menubar.add_cascade(label='Edit', underline=0, menu=editmenu)
rulemenu = Menu(menubar, tearoff=0)
rulemenu.add_command(label='Step', underline=1,
command=self.step, accelerator='Space')
rulemenu.add_separator()
rulemenu.add_command(label='Match', underline=0,
command=self.match, accelerator='Ctrl-m')
rulemenu.add_command(label='Expand', underline=0,
command=self.expand, accelerator='Ctrl-e')
rulemenu.add_separator()
rulemenu.add_command(label='Backtrack', underline=0,
command=self.backtrack, accelerator='Ctrl-b')
menubar.add_cascade(label='Apply', underline=0, menu=rulemenu)
viewmenu = Menu(menubar, tearoff=0)
viewmenu.add_checkbutton(label="Show Grammar", underline=0,
variable=self._show_grammar,
command=self._toggle_grammar)
viewmenu.add_separator()
viewmenu.add_radiobutton(label='Tiny', variable=self._size,
underline=0, value=10, command=self.resize)
viewmenu.add_radiobutton(label='Small', variable=self._size,
underline=0, value=12, command=self.resize)
viewmenu.add_radiobutton(label='Medium', variable=self._size,
underline=0, value=14, command=self.resize)
viewmenu.add_radiobutton(label='Large', variable=self._size,
underline=0, value=18, command=self.resize)
viewmenu.add_radiobutton(label='Huge', variable=self._size,
underline=0, value=24, command=self.resize)
menubar.add_cascade(label='View', underline=0, menu=viewmenu)
animatemenu = Menu(menubar, tearoff=0)
animatemenu.add_radiobutton(label="No Animation", underline=0,
variable=self._animation_frames,
value=0)
animatemenu.add_radiobutton(label="Slow Animation", underline=0,
variable=self._animation_frames,
value=10, accelerator='-')
animatemenu.add_radiobutton(label="Normal Animation", underline=0,
variable=self._animation_frames,
value=5, accelerator='=')
animatemenu.add_radiobutton(label="Fast Animation", underline=0,
variable=self._animation_frames,
value=2, accelerator='+')
menubar.add_cascade(label="Animate", underline=1, menu=animatemenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label='About', underline=0,
command=self.about)
helpmenu.add_command(label='Instructions', underline=0,
command=self.help, accelerator='F1')
menubar.add_cascade(label='Help', underline=0, menu=helpmenu)
parent.config(menu=menubar)
示例7: BuildMainFrame
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def BuildMainFrame(self):
from tkinter import Menu, IntVar, StringVar, Toplevel, Listbox, Frame, PanedWindow, Text, Scrollbar, Entry
from tkinter import X, N, S, W, E, VERTICAL, TOP, END, DISABLED, RAISED
menu = Menu(self.master,activeborderwidth=0,bd=0)
self.master.config(menu=menu)
filemenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
menu.add_cascade(label="File", underline=0, menu=filemenu)
filemenu.add_command(label="New", accelerator='Ctrl+N',command=self.NewCommand)
filemenu.add_command(label="Open...",accelerator='Ctrl+O', command=self.OpenCommand)
filemenu.add_command(label="Save as...",accelerator='Ctrl+S', command=self.SaveCommand)
filemenu.add_separator()
filemenu.add_command(label="Quit",accelerator='Ctrl+Q', command=self.QuitCommand)
self.log_on = IntVar()
self.log_on.set(1)
self.output_to_file = StringVar()
self.output_to_file.set('n')
scriptmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
modulenames = ['vmtkscripts']
for modulename in modulenames:
scriptsubmenu = self.BuildScriptMenu(menu,modulename)
if scriptsubmenu:
scriptmenu.add_cascade(label=modulename,menu=scriptsubmenu)
editmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
menu.add_cascade(label="Edit",underline=0, menu=editmenu)
editmenu.add_cascade(label="Insert script",menu=scriptmenu)
editmenu.add_command(label="Insert file name", accelerator='Ctrl+F',command=self.InsertFileName)
editmenu.add_separator()
editmenu.add_command(label="Clear input", command=self.ClearInputCommand)
editmenu.add_command(label="Clear output", command=self.ClearOutputCommand)
editmenu.add_command(label="Clear all", command=self.ClearAllCommand)
editmenu.add_separator()
editmenu.add_checkbutton(label="Log", variable=self.log_on)
editmenu.add_separator()
editmenu.add_radiobutton(label="No output to file", variable=self.output_to_file,value='n')
editmenu.add_radiobutton(label="Write output to file", variable=self.output_to_file,value='w')
editmenu.add_radiobutton(label="Append output to file", variable=self.output_to_file,value='a')
editmenu.add_command(label="Output file...", command=self.OutputFileCommand)
runmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
menu.add_cascade(label="Run", underline=0, menu=runmenu)
runmenu.add_command(label="Run all", command=self.RunAllCommand)
runmenu.add_command(label="Run current line", command=self.RunLineCommand)
runmenu.add_command(label="Run selection", command=self.RunSelectionCommand)
helpmenu = Menu(menu,tearoff=0,bd=1,activeborderwidth=0)
menu.add_cascade(label="Help", underline=0, menu=helpmenu)
helpmenu.add_command(label="Help", underline=0, accelerator='F1',command=self.ShowHelpCommand)
helpmenu.add_command(label="About", underline=0, command=self.AboutCommand)
self.master.bind("<Control-KeyPress-q>", self.QuitHandler)
self.master.bind("<Control-KeyPress-n>", self.NewHandler)
self.master.bind("<Control-KeyPress-o>", self.OpenHandler)
self.master.bind("<Control-KeyPress-s>", self.SaveHandler)
self.master.bind("<Control-KeyPress-f>", self.InsertFileNameHandler)
self.master.bind("<KeyPress-F1>", self.ShowHelpHandler)
self.master.bind("<KeyPress>", self.KeyPressHandler)
self.wordIndex = ['1.0','1.0']
self.suggestionswindow = Toplevel(bg='#ffffff',bd=0,height=50,width=600,highlightthickness=0,takefocus=True)
self.suggestionswindow.overrideredirect(1)
self.suggestionslist = Listbox(self.suggestionswindow,bg='#ffffff',bd=1,fg='#336699',activestyle='none',highlightthickness=0,height=9)
self.suggestionslist.insert(END,"foo")
self.suggestionslist.pack(side=TOP,fill=X)
self.suggestionswindow.bind("<KeyPress>", self.TopKeyPressHandler)
self.suggestionswindow.withdraw()
self.master.rowconfigure(0,weight=1)
self.master.columnconfigure(0,weight=1)
content = Frame(self.master,bd=0,padx=2,pady=2)
content.grid(row=0,column=0,sticky=N+S+W+E)
content.rowconfigure(0,weight=1,minsize=50)
content.rowconfigure(1,weight=0)
content.columnconfigure(0,weight=1)
panes = PanedWindow(content,orient=VERTICAL,bd=1,sashwidth=8,sashpad=0,sashrelief=RAISED,showhandle=True)
panes.grid(row=0,column=0,sticky=N+S+W+E)
frame1 = Frame(panes,bd=0)
frame1.grid(row=0,column=0,sticky=N+S+W+E)
frame1.columnconfigure(0,weight=1)
frame1.columnconfigure(1,weight=0)
frame1.rowconfigure(0,weight=1)
panes.add(frame1,height=300,minsize=20)
frame2 = Frame(panes,bd=0)
frame2.grid(row=1,column=0,sticky=N+S+W+E)
frame2.columnconfigure(0,weight=1)
frame2.columnconfigure(1,weight=0)
frame2.rowconfigure(0,weight=1)
panes.add(frame2,minsize=20)
#.........这里部分代码省略.........
示例8: _init_menubar
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
def _init_menubar(self, parent):
menubar = Menu(parent)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Reset Parser", underline=0, command=self.reset, accelerator="Del")
filemenu.add_command(label="Print to Postscript", underline=0, command=self.postscript, accelerator="Ctrl-p")
filemenu.add_command(label="Exit", underline=1, command=self.destroy, accelerator="Ctrl-x")
menubar.add_cascade(label="File", underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Edit Grammar", underline=5, command=self.edit_grammar, accelerator="Ctrl-g")
editmenu.add_command(label="Edit Text", underline=5, command=self.edit_sentence, accelerator="Ctrl-t")
menubar.add_cascade(label="Edit", underline=0, menu=editmenu)
rulemenu = Menu(menubar, tearoff=0)
rulemenu.add_command(label="Step", underline=1, command=self.step, accelerator="Space")
rulemenu.add_separator()
rulemenu.add_command(label="Shift", underline=0, command=self.shift, accelerator="Ctrl-s")
rulemenu.add_command(label="Reduce", underline=0, command=self.reduce, accelerator="Ctrl-r")
rulemenu.add_separator()
rulemenu.add_command(label="Undo", underline=0, command=self.undo, accelerator="Ctrl-u")
menubar.add_cascade(label="Apply", underline=0, menu=rulemenu)
viewmenu = Menu(menubar, tearoff=0)
viewmenu.add_checkbutton(
label="Show Grammar", underline=0, variable=self._show_grammar, command=self._toggle_grammar
)
viewmenu.add_separator()
viewmenu.add_radiobutton(label="Tiny", variable=self._size, underline=0, value=10, command=self.resize)
viewmenu.add_radiobutton(label="Small", variable=self._size, underline=0, value=12, command=self.resize)
viewmenu.add_radiobutton(label="Medium", variable=self._size, underline=0, value=14, command=self.resize)
viewmenu.add_radiobutton(label="Large", variable=self._size, underline=0, value=18, command=self.resize)
viewmenu.add_radiobutton(label="Huge", variable=self._size, underline=0, value=24, command=self.resize)
menubar.add_cascade(label="View", underline=0, menu=viewmenu)
animatemenu = Menu(menubar, tearoff=0)
animatemenu.add_radiobutton(label="No Animation", underline=0, variable=self._animate, value=0)
animatemenu.add_radiobutton(
label="Slow Animation", underline=0, variable=self._animate, value=20, accelerator="-"
)
animatemenu.add_radiobutton(
label="Normal Animation", underline=0, variable=self._animate, value=10, accelerator="="
)
animatemenu.add_radiobutton(
label="Fast Animation", underline=0, variable=self._animate, value=4, accelerator="+"
)
menubar.add_cascade(label="Animate", underline=1, menu=animatemenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="About", underline=0, command=self.about)
helpmenu.add_command(label="Instructions", underline=0, command=self.help, accelerator="F1")
menubar.add_cascade(label="Help", underline=0, menu=helpmenu)
parent.config(menu=menubar)
示例9: createInterface
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
#.........这里部分代码省略.........
self.hprR = self.createcomponent('hprR', (), None,
AngleDial, (hprInterior,),
style = 'mini',
text = 'R', value = 0.0,
relief = tkinter.FLAT,
label_foreground = '#00A000')
self.hprR['commandData'] = ['r']
self.hprR['preCallback'] = self.xformStart
self.hprR['postCallback'] = self.xformStop
self.hprR['callbackData'] = ['r']
self.hprR.pack(expand=1,fill='both')
# Create and pack the Scale Controls
# The available scaling modes
self.scalingMode = StringVar()
self.scalingMode.set('Scale Uniform')
# The scaling widgets
scaleGroup = Pmw.Group(interior,
tag_text = 'Scale Uniform',
tag_pyclass = Menubutton,
tag_font=('MSSansSerif', 14),
tag_activebackground = '#909090',
ring_relief = tkinter.RIDGE)
self.scaleMenubutton = scaleGroup.component('tag')
self.bind(self.scaleMenubutton, 'Scale menu operations')
self.scaleMenubutton['textvariable'] = self.scalingMode
# Scaling menu
scaleMenu = Menu(self.scaleMenubutton, tearoff = 0)
scaleMenu.add_command(label = 'Set to unity',
command = self.unitScale)
scaleMenu.add_command(label = 'Reset initial',
command = self.resetScale)
scaleMenu.add_radiobutton(label = 'Scale Free',
variable = self.scalingMode)
scaleMenu.add_radiobutton(label = 'Scale Uniform',
variable = self.scalingMode)
scaleMenu.add_radiobutton(label = 'Scale Proportional',
variable = self.scalingMode)
self.scaleMenubutton['menu'] = scaleMenu
# Pack group widgets
scaleGroup.pack(side='left',fill = 'both', expand = 1)
scaleInterior = scaleGroup.interior()
# Create the dials
self.scaleX = self.createcomponent('scaleX', (), None,
Floater, (scaleInterior,),
text = 'X Scale',
relief = tkinter.FLAT,
min = 0.0001, value = 1.0,
resetValue = 1.0,
label_foreground = 'Red')
self.scaleX['commandData'] = ['sx']
self.scaleX['callbackData'] = ['sx']
self.scaleX['preCallback'] = self.xformStart
self.scaleX['postCallback'] = self.xformStop
self.scaleX.pack(expand=1,fill='both')
self.scaleY = self.createcomponent('scaleY', (), None,
Floater, (scaleInterior,),
text = 'Y Scale',
relief = tkinter.FLAT,
min = 0.0001, value = 1.0,
resetValue = 1.0,
label_foreground = '#00A000')
self.scaleY['commandData'] = ['sy']
示例10: CimApp
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
class CimApp(Frame):
def __init__(self):
Frame.__init__(self)
self.file = None;
self.master.title("Tiborcim")
self.master.iconphoto(True, PhotoImage(file=ICON_PNG))
self.files = []
self.current_tab = StringVar()
self.pack(expand=1, fill="both")
self.master.minsize(300,300)
self.master.geometry("500x500")
self.menubar = Menu(self.master)
self.fileMenu = Menu(self.master, tearoff=0)
self.fileMenu.add_command(label="New", command=self.new_file,
underline=0, accelerator="Ctrl+N")
self.fileMenu.add_command(label="Open...", command=self.load_file,
underline=0, accelerator="Ctrl+O")
self.fileMenu.add_command(label="Save", command=self.file_save,
underline=0, accelerator="Ctrl+S")
self.fileMenu.add_command(label="Save As...", command=self.file_save_as,
underline=5, accelerator="Ctrl+Alt+S")
self.fileMenu.add_command(label="Close", command=self.close_file,
underline=0, accelerator="Ctrl+W")
self.fileMenu.add_separator()
self.fileMenu.add_command(label="Exit", command=self.file_quit, underline=1)
self.menubar.add_cascade(label="File", menu=self.fileMenu, underline=0)
self.edit_program = Menu(self.master, tearoff=0)
self.edit_program.add_command(label="Undo", command=self.edit_undo,
underline=0, accelerator="Ctrl+Z")
self.edit_program.add_command(label="Redo", command=self.edit_redo,
underline=0, accelerator="Ctrl+Y")
self.edit_program.add_separator()
self.edit_program.add_command(label="Cut",
command=self.edit_cut,
underline=2,
accelerator="Ctrl+X")
self.edit_program.add_command(label="Copy",
command=self.edit_copy,
underline=0,
accelerator="Ctrl+C")
self.edit_program.add_command(label="Paste",
command=self.edit_paste,
underline=0,
accelerator="Ctrl+V")
self.menubar.add_cascade(label="Edit", menu=self.edit_program, underline=0)
self.menu_program = Menu(self.master, tearoff=0)
self.menu_program.add_command(label="Convert",
command=self.convert_file,
underline=0,
accelerator="Ctrl+T")
self.menu_program.add_command(label="Flash",
command=self.flash_file,
underline=0,
accelerator="Ctrl+B")
self.menu_program.add_separator()
self.menubar.add_cascade(label="Program", menu=self.menu_program, underline=0)
self.menu_view = Menu(self.master,
tearoff=0)
self.viewmode = StringVar()
self.viewmode.set("tiborcim")
self.menu_view.add_radiobutton(label="Tiborcim",
command=self.view_tiborcim,
variable=self.viewmode,
value="tiborcim",
underline=0)
self.menu_view.add_radiobutton(label="Python",
command=self.view_python,
variable=self.viewmode,
value="python",
underline=0)
self.menubar.add_cascade(label="View",
menu=self.menu_view,
underline=0)
self.menu_help = Menu(self.master,
tearoff=0)
self.menu_samples = Menu(self.master, tearoff=0)
samples = tiborcim.resources.samples_list()
def add_sample (sample):
self.menu_samples.add_command(label=sample,
command=lambda: self.help_sample(sample))
for sample in samples:
add_sample(sample)
self.menu_help.add_cascade(label="Samples",
menu=self.menu_samples,
underline=0)
self.menu_help.add_separator()
self.menu_help.add_command(label="README",
command=self.help_readme,
underline=0)
self.menu_help.add_separator()
self.menu_help.add_command(label="About",
command=self.help_about,
underline=0)
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_radiobutton [as 别名]
#.........这里部分代码省略.........
menu_levels = Menu(menu_nouveau, tearoff=0)
menu_levels.add_command(label=_("Easy"), command=self.new_easy)
menu_levels.add_command(label=_("Medium"), command=self.new_medium)
menu_levels.add_command(label=_("Difficult"), command=self.new_difficult)
menu_nouveau.add_cascade(label=_("Level"), menu=menu_levels)
menu_nouveau.add_command(label=_("Generate a puzzle"),
command=self.genere_grille,
accelerator="Ctrl+G")
menu_nouveau.add_command(label=_("Empty grid"),
command=self.grille_vide,
accelerator="Ctrl+N")
menu_ouvrir = Menu(menu, tearoff=0)
menu_ouvrir.add_command(label=_("Game"), command=self.import_partie,
accelerator="Ctrl+O")
menu_ouvrir.add_command(label=_("Puzzle"), command=self.import_grille,
accelerator="Ctrl+Shift+O")
menu_game = Menu(menu, tearoff=0)
menu_game.add_command(label=_("Restart"), command=self.recommence)
menu_game.add_command(label=_("Solve"), command=self.resolution)
menu_game.add_command(label=_("Save"), command=self.sauvegarde,
accelerator="Ctrl+S")
menu_game.add_command(label=_("Export"), command=self.export_impression,
accelerator="Ctrl+E")
menu_game.add_command(label=_("Evaluate level"),
command=self.evaluate_level)
menu_language = Menu(menu, tearoff=0)
self.langue = StringVar(self)
self.langue.set(cst.LANGUE[:2])
menu_language.add_radiobutton(label="Français",
variable=self.langue,
value="fr", command=self.translate)
menu_language.add_radiobutton(label="English", variable=self.langue,
value="en", command=self.translate)
menu_help = Menu(menu, tearoff=0)
menu_help.add_command(label=_("Help"), command=self.aide, accelerator='F1')
menu_help.add_command(label=_("About"), command=self.about)
menu.add_cascade(label=_("New"), menu=menu_nouveau)
menu.add_cascade(label=_("Open"), menu=menu_ouvrir)
menu.add_cascade(label=_("Game"), menu=menu_game)
menu.add_cascade(label=_("Language"), menu=menu_language)
menu.add_command(label=_("Statistics"), command=self.show_stat)
menu.add_cascade(label=_("Help"), menu=menu_help)
self.configure(menu=menu)
# --- clavier popup
self.clavier = None
# --- cases
self.nb_cases_remplies = 0
self.blocs = np.zeros((9, 9), dtype=object)
for i in range(9):
for j in range(9):
self.blocs[i, j] = Case(self.frame_puzzle, i, j, self.update_nbs, width=50, height=50)
px, py = 1, 1
if i % 3 == 2 and i != 8:
py = (1, 3)
if j % 3 == 2 and j != 8:
px = (1, 3)