本文整理汇总了Python中tkinter.Frame.columnconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.columnconfigure方法的具体用法?Python Frame.columnconfigure怎么用?Python Frame.columnconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.columnconfigure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showPlotTools
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def showPlotTools(self):
f2= Frame(self.frame, relief=FLAT,bg='#FADC46')
f2.grid(row=1,column=0,rowspan=2,columnspan=3,sticky=N+S+E+W,padx=10,pady =10)
b1 = Button(f2,text='3D K',relief=RAISED,command= lambda:self.plotButtonPressed(1))
b1.grid(row=0, column=0,sticky=N+S+E+W,padx=5,pady =5)
b2 = Button(f2,text='3D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(2))
b2.grid(row=0, column=1,sticky=N+S+E+W,padx=5,pady =5)
b3 = Button(f2,text='3D DP',relief=RAISED,command=lambda:self.plotButtonPressed(3))
b3.grid(row=0, column=2,sticky=N+S+E+W,padx=5,pady =5)
b4 = Button(f2,text='2D K',relief=RAISED,command=lambda:self.plotButtonPressed(4))
b4.grid(row=1, column=0,sticky=N+S+E+W,padx=5,pady =5)
b5 = Button(f2,text='2D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(5))
b5.grid(row=1, column=1,sticky=N+S+E+W,padx=5,pady =5)
b6 = Button(f2,text='2D DP',relief=RAISED,command=lambda:self.plotButtonPressed(6))
b6.grid(row=1, column=2,sticky=N+S+E+W,padx=5,pady =5)
f2.columnconfigure(0, weight=1)
f2.columnconfigure(1, weight=1)
f2.columnconfigure(2, weight=1)
f2.rowconfigure(0, weight=1)
f2.rowconfigure(1, weight=1)
示例2: addPathFrame
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def addPathFrame(self):
frame=Frame(self)
frame.pack(fill=tk.X,expand=0,side=tk.TOP,padx=8,pady=5)
frame.columnconfigure(1,weight=1)
#------------------Database file------------------
label=tk.Label(frame,text=dgbk('ting.sqlite文件:'),\
bg='#bbb')
label.grid(row=0,column=0,\
sticky=tk.W,padx=8)
self.db_entry=tk.Entry(frame)
self.db_entry.grid(row=0,column=1,sticky=tk.W+tk.E,padx=8)
self.db_button=tk.Button(frame,text=dgbk('打开'),command=self.openFile)
self.db_button.grid(row=0,column=2,padx=8,sticky=tk.E)
#--------------------Output dir--------------------
label2=tk.Label(frame,text=dgbk('导出到文件夹:'),\
bg='#bbb')
label2.grid(row=2,column=0,\
sticky=tk.W,padx=8)
self.out_entry=tk.Entry(frame)
self.out_entry.grid(row=2,column=1,sticky=tk.W+tk.E,padx=8)
self.out_button=tk.Button(frame,text=dgbk('选择'),command=self.openDir)
self.out_button.grid(row=2,column=2,padx=8,sticky=tk.E)
示例3: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def __init__(self, root, title):
self.root = root
self.root.title(title)
# Variable that stores file handle (may be unnecessary)
self.file_handle = ""
master_frame = Frame(root)
master_frame.pack(expand="yes", fill="both")
# Create left button frame and buttons
button_frame = Frame(master_frame)
self.open_button = Button(button_frame, text="Choose File", command=self.load_file)
self.open_button.pack(expand="yes", fill="both")
self.apply_button = Button(button_frame, text="Apply", command=self.apply_consistent, state="disabled")
self.apply_button.pack(expand="yes", fill="both")
self.save_button = Button(button_frame, text="Save File", command=self.save_file, state="disabled")
self.save_button.pack(expand="yes", fill="both")
# Create text frame and initialize text widget
text_frame = Frame(master_frame)
self.text_box = Text(text_frame, height=10, width=50, state="disabled")
self.text_box.pack(side="top", expand="yes", fill="both")
# Configure weights for grid elements
master_frame.columnconfigure(0, weight=1)
master_frame.columnconfigure(1, weight=5)
for i in range(3):
master_frame.rowconfigure(i, weight=1)
# Position button and text frames
button_frame.grid(row=0, column=0, rowspan=3, sticky="nsew")
text_frame.grid(row=0, column=1, rowspan=3, sticky="nsew")
self.root.minsize(500, 200)
示例4: addActionFrame
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def addActionFrame(self):
frame=Frame(self,relief=tk.RAISED,borderwidth=1)
frame.pack(fill=tk.X,side=tk.TOP,\
expand=0,padx=8,pady=5)
#label=tk.Label(frame,text='Actions:',bg='#bbb')
#label.grid(row=0,column=0,sticky=tk.W,padx=8)
#---------------Action checkbuttons---------------
frame.columnconfigure(0,weight=1)
#---------------------2nd row---------------------
subframe=Frame(frame)
subframe.grid(row=1,column=0,columnspan=6,sticky=tk.W+tk.E,\
pady=5)
#-------------------Album options-------------------
albumlabel=tk.Label(subframe,text=dgbk('专辑:'),\
bg='#bbb')
albumlabel.pack(side=tk.LEFT, padx=8)
self.album=tk.StringVar()
self.albumnames=['All',]
self.albummenu=Combobox(subframe,textvariable=\
self.album,values=self.albumnames,state='readonly')
self.albummenu.current(0)
self.albummenu.bind('<<ComboboxSelected>>',self.setAlbum)
self.albummenu.pack(side=tk.LEFT,padx=8)
#-------------------Quit button-------------------
quit_button=tk.Button(subframe,text=dgbk('退出'),\
command=self.quit)
quit_button.pack(side=tk.RIGHT,padx=8)
#-------------------Stop button-------------------
'''
self.stop_button=tk.Button(subframe,text='Stop',\
command=self.stop)
self.stop_button.pack(side=tk.RIGHT,padx=8)
'''
#-------------------Start button-------------------
self.start_button=tk.Button(subframe,text=dgbk('开始'),\
command=self.start,state=tk.DISABLED)
self.start_button.pack(side=tk.RIGHT,pady=8)
#-------------------Help button-------------------
self.help_button=tk.Button(subframe,text=dgbk('帮助'),\
command=self.showHelp)
self.help_button.pack(side=tk.RIGHT,padx=8)
示例5: _build_cell
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def _build_cell(self, row: int, col: int) -> Frame:
cell = Frame(self._content, borderwidth=5, relief=const.SUNKEN, height=50, width=50)
cell._canvas = Canvas(master=cell, height=50, width=50)
cell.row = row
cell.col = col
cell.bound = False
cell.grid(row=row, column=col, sticky="nsew")
cell.columnconfigure(0, weight=1)
cell.rowconfigure(0, weight=1)
cell._canvas.grid(row=0, column=0, sticky="nsew")
return cell
示例6: _init_game
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def _init_game(self) -> None:
# Make some game constants more easily accessible
self.rows = self.game.board.rows
self.columns = self.game.board.cols
#
# Main window
#
self._root = Tk()
self._root.title("Othello")
self._root.columnconfigure(0, weight=1)
self._root.rowconfigure(2, weight=1)
self._root.minsize(50 * self.columns + 100, 50 * self.rows + 100)
#
# Score Label
#
score_frame = Frame(self._root)
self._score_label = ttk.Label(score_frame, background="white", foreground="black", text="TEMPORARY LABEL") #TODO: compute label text
score_frame.grid(row=0, column=0, sticky="ew")
self._score_label.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
score_frame.columnconfigure(0, weight=1)
#
# Info Label
#
info_frame = Frame(self._root)
self._info_label = ttk.Label(info_frame, text="", background="white", foreground="black")
info_frame.grid(row=1, column=0, sticky="ew")
self._info_label.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
info_frame.columnconfigure(0, weight=1)
#
# Game content (Othello board)
#
self._content = Frame(self._root)
self._content.grid(row=2, column=0, sticky="nsew")
self.cells = []
for row in range(self.rows):
for col in range(self.columns):
self.cells.append(self._build_cell(row, col))
self._content.columnconfigure(col, weight=1)
self._content.rowconfigure(row, weight=1)
示例7: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def __init__(self, runner):
self.runner = runner
self.messages = {}
Screen.destroy()
Screen.reinit()
super().__init__()
Screen.title("NaOH: PocketMine-MP Console")
# GUI initialization
fstframe = Frame(Screen.root)
fstframe.grid(row=0, rowspan=1, columnspan=8)
sndframe = Frame(Screen.root)
sndframe.grid(row=0, rowspan=1, column=8, columnspan=2)
self.scrollbar = Scrollbar(fstframe)
self.listbox = Listbox(fstframe, yscrollcommand=self.scrollbar.set, width=120, height=25)
self.listbox.grid(row=0, column=0, rowspan=1, columnspan=7, sticky='nswe')
self.scrollbar.config(command=self.listbox.yview)
self.scrollbar.grid(row=0, column=7, rowspan=1, sticky='nse')
self.scrolllock = False
Button(fstframe, text='나가기 (주의: 강제 종료됩니다)', command=self.runner.killAll).grid(row=1, column=0, sticky='nwse')
self.slbutton = Button(fstframe, text='ScrollLock Off', command=self.togglesl)
self.slbutton.grid(row=1, column=1, sticky='new')
Label(fstframe, text='명령어: /', justify='right').grid(row=1, column=2)
self.cmdentry = Entry(fstframe)
self.cmdentry.bind('<Return>', self.put_cmd)
self.cmdentry.grid(row=1, column=3, columnspan=5, sticky='nwe')
fstframe.rowconfigure(1, weight=1)
fstframe.columnconfigure(3, weight=1)
fstframe.columnconfigure(4, weight=20)
sndframe.rowconfigure(0, weight=1)
Button(sndframe, text='서버 상태', command=lambda: statusScreen(self)).grid(row=0, sticky='n')
Button(sndframe, text='설정 편집', command=lambda: propertiesScreen(self.runner.workdir + sep + 'server.properties')).grid(row=1, sticky='n')
Button(sndframe, text='덤프 삭제', command=self.removeDumps).grid(row=2, sticky='n')
self.cmdentry.focus()
Screen.root.focus_force()
# GUI initialization done
self.thread = threading.Thread(target=lambda: asyncStream(self)).start()
Screen.root.protocol("WM_DELETE_WINDOW", self.runner.killAll)
Screen.root.mainloop()
try:
Screen.root.destroy()
except:
self.runner.killAll()
示例8: generic_func
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def generic_func(parent: tk.Frame, values: List[Tuple[str, tk.StringVar]], conf: Property):
"""Generically make a set of labels."""
for row, (timer, var) in enumerate(values):
if timer == 'inf':
timer_disp = INF
else:
timer_disp = timer
parent.columnconfigure(1, weight=1)
label = ttk.Label(parent, text=timer_disp + ':')
label.grid(row=row, column=0)
widget = widget_func(
parent,
var,
conf,
)
widget.grid(row=row, column=1, sticky='ew')
示例9: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def __init__(self, game, stats=DEFAULT_STATS, buttons=DEFAULT_BUTTONS_CONTINUE):
self.action = None
self.root = root = Tk()
root.title("Iä! Shub-Niggurath! The Black Goat of the Woods with a Thousand Young!")
root.protocol("WM_DELETE_WINDOW", self.close)
root.pack_propagate(True)
self.grid_canvas = Canvas(root, bd=5, relief=tkinter.SUNKEN)
self.grid_canvas.pack(expand=True, fill=tkinter.BOTH, side=tkinter.LEFT)
button_frame = Frame(root)
button_frame.pack(fill=tkinter.BOTH, side=tkinter.LEFT)
stat_frame = Frame(button_frame, bd=1)
stat_frame.pack(fill=tkinter.BOTH)
stat_frame.columnconfigure(1, weight=1)
self.stat_textboxes = stat_textboxes = []
for row, (text, callback) in enumerate(stats):
label = Label(stat_frame, text=text + ":", anchor="e")
label.grid(row=row, column=0, sticky="wens")
textbox = Label(stat_frame, bd=1, relief=tkinter.SUNKEN)
textbox.callback = callback # for our own use.
textbox.grid(row=row, column=1, sticky="wens")
stat_textboxes.append(textbox)
for name, bindings, action in buttons:
def callback(event, action=action):
if self.action is not None:
log.error("Action already set: %r when processing %r", self.action, action)
self.action = action
root.quit()
text = name + (" ({})".format(bindings) if bindings else "")
button = Button(button_frame, text=text, command=lambda: callback(None))
button.pack()
for it in bindings.split():
root.bind(it, callback)
if game is not None:
self.update(game)
示例10: showPlotTools
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def showPlotTools(self):
f2= Frame(self.selectPlotFrame, relief=FLAT,bg='#FADC46')
f2.grid(row=1,column=0,sticky=N+S+E+W,padx=10,pady =10)
b1 = Button(f2,text='3D K',relief=RAISED,command= lambda:self.plotButtonPressed(1))
b1.grid(row=0, column=0,sticky=N+S+E+W,padx=5,pady =5)
b2 = Button(f2,text='3D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(2))
b2.grid(row=0, column=1,sticky=N+S+E+W,padx=5,pady =5)
b3 = Button(f2,text='3D DP',relief=RAISED,command=lambda:self.plotButtonPressed(3))
b3.grid(row=0, column=2,sticky=N+S+E+W,padx=5,pady =5)
b4 = Button(f2,text='2D K',relief=RAISED,command=lambda:self.plotButtonPressed(4))
b4.grid(row=1, column=0,sticky=N+S+E+W,padx=5,pady =5)
b5 = Button(f2,text='2D Dist',relief=RAISED,command=lambda:self.plotButtonPressed(5))
b5.grid(row=1, column=1,sticky=N+S+E+W,padx=5,pady =5)
b6 = Button(f2,text='2D DP',relief=RAISED,command=lambda:self.plotButtonPressed(6))
b6.grid(row=1, column=2,sticky=N+S+E+W,padx=5,pady =5)
b1.config(state=EguanaModel().machine.plot3DKButtonState)
b2.config(state=EguanaModel().machine.plot3DDstButtonState)
b3.config(state=EguanaModel().machine.plot3DDpButtonState)
b4.config(state=EguanaModel().machine.plot2DKButtonState)
b5.config(state=EguanaModel().machine.plot2DDstButtonState)
b6.config(state=EguanaModel().machine.plot2DDpButtonState)
f2.columnconfigure(0, weight=1)
f2.columnconfigure(1, weight=1)
f2.columnconfigure(2, weight=1)
f2.rowconfigure(0, weight=1)
f2.rowconfigure(1, weight=1)
示例11: addPathFrame
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def addPathFrame(self):
frame=Frame(self)
frame.pack(fill=tk.X,expand=0,side=tk.TOP,padx=8,pady=5)
frame.columnconfigure(1,weight=1)
#------------------Database file------------------
label=tk.Label(frame,text='Mendeley Data file:',\
bg='#bbb')
label.grid(row=0,column=0,\
sticky=tk.W,padx=8)
self.db_entry=tk.Entry(frame)
self.db_entry.grid(row=0,column=1,sticky=tk.W+tk.E,padx=8)
self.db_button=tk.Button(frame,text='Open',command=self.openFile)
self.db_button.grid(row=0,column=2,padx=8,sticky=tk.E)
hint='''
Default location on Linux:
~/.local/share/data/Mendeley\ Ltd./Mendeley\ Desktop/[email protected]
Default location on Windows:
C:\Users\Your_name\AppData\Local\Mendeley Ltd\Mendeley Desktop\[email protected]'''
hint_label=tk.Label(frame,text=hint,\
justify=tk.LEFT,anchor=tk.NW)
hint_label.grid(row=1,column=0,columnspan=3,\
sticky=tk.W,padx=8)
#--------------------Output dir--------------------
label2=tk.Label(frame,text='Output folder:',\
bg='#bbb')
label2.grid(row=2,column=0,\
sticky=tk.W,padx=8)
self.out_entry=tk.Entry(frame)
self.out_entry.grid(row=2,column=1,sticky=tk.W+tk.E,padx=8)
self.out_button=tk.Button(frame,text='Choose',command=self.openDir)
self.out_button.grid(row=2,column=2,padx=8,sticky=tk.E)
示例12: BuildMainFrame
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [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)
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def __init__(self, master, gconf, directory=None):
self.master = master
self.initialized = False
self.master.bind('<Return>', self.infer)
self.master.bind('<Escape>', lambda a: self.master.quit())
self.master.protocol('WM_DELETE_WINDOW', self.quit)
self.dir = os.path.abspath(ifnone(directory, ifnone(gconf['prev_query_path'], os.getcwd())))
self.frame = Frame(master)
self.frame.pack(fill=BOTH, expand=1)
self.frame.columnconfigure(1, weight=1)
row = 0
# pracmln project options
Label(self.frame, text='PRACMLN Project: ').grid(row=row, column=0,
sticky='ES')
project_container = Frame(self.frame)
project_container.grid(row=row, column=1, sticky="NEWS")
# new proj file
self.btn_newproj = Button(project_container, text='New Project...', command=self.new_project)
self.btn_newproj.grid(row=0, column=1, sticky="WS")
# open proj file
self.btn_openproj = Button(project_container, text='Open Project...', command=self.ask_load_project)
self.btn_openproj.grid(row=0, column=2, sticky="WS")
# save proj file
self.btn_updateproj = Button(project_container, text='Save Project...', command=self.noask_save_project)
self.btn_updateproj.grid(row=0, column=3, sticky="WS")
# save proj file as...
self.btn_saveproj = Button(project_container, text='Save Project as...', command=self.ask_save_project)
self.btn_saveproj.grid(row=0, column=4, sticky="WS")
# grammar selection
row += 1
Label(self.frame, text='Grammar: ').grid(row=row, column=0, sticky='E')
grammars = ['StandardGrammar', 'PRACGrammar']
self.selected_grammar = StringVar()
self.selected_grammar.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_grammar) + tuple(grammars))
l.grid(row=row, column=1, sticky='NWE')
# logic selection
row += 1
Label(self.frame, text='Logic: ').grid(row=row, column=0, sticky='E')
logics = ['FirstOrderLogic', 'FuzzyLogic']
self.selected_logic = StringVar()
self.selected_logic.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_logic) + tuple(logics))
l.grid(row=row, column=1, sticky='NWE')
# mln section
row += 1
Label(self.frame, text="MLN: ").grid(row=row, column=0, sticky='NE')
self.mln_container = FileEditBar(self.frame, directory=self.dir,
filesettings={'extension': '.mln', 'ftypes': [('MLN files', '.mln')]},
defaultname='*unknown{}',
importhook=self.import_mln,
deletehook=self.delete_mln,
projecthook=self.save_proj,
filecontenthook=self.mlnfilecontent,
fileslisthook=self.mlnfiles,
updatehook=self.update_mln,
onchangehook=self.project_setdirty)
self.mln_container.editor.bind("<FocusIn>", self._got_focus)
self.mln_container.grid(row=row, column=1, sticky="NEWS")
self.mln_container.columnconfigure(1, weight=2)
self.frame.rowconfigure(row, weight=1)
row += 1
self.use_emln = IntVar()
self.use_emln.set(0)
self.cb_use_emln = Checkbutton(self.frame, text="use model extension",
variable=self.use_emln,
command=self.onchange_use_emln)
self.cb_use_emln.grid(row=row, column=1, sticky="W")
# mln extension section
row += 1
self.emlncontainerrow = row
self.emln_label = Label(self.frame, text="EMLN: ")
self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky='NE')
self.emln_container = FileEditBar(self.frame,
directory=self.dir,
filesettings={'extension': '.emln', 'ftypes': [('MLN extension files','.emln')]},
defaultname='*unknown{}',
importhook=self.import_emln,
deletehook=self.delete_emln,
projecthook=self.save_proj,
filecontenthook=self.emlnfilecontent,
fileslisthook=self.emlnfiles,
updatehook=self.update_emln,
onchangehook=self.project_setdirty)
self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NEWS")
self.emln_container.editor.bind("<FocusIn>", self._got_focus)
#.........这里部分代码省略.........
示例14: MLNQueryGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
class MLNQueryGUI(object):
def __init__(self, master, gconf, directory=None):
self.master = master
self.initialized = False
self.master.bind('<Return>', self.infer)
self.master.bind('<Escape>', lambda a: self.master.quit())
self.master.protocol('WM_DELETE_WINDOW', self.quit)
self.dir = os.path.abspath(ifnone(directory, ifnone(gconf['prev_query_path'], os.getcwd())))
self.frame = Frame(master)
self.frame.pack(fill=BOTH, expand=1)
self.frame.columnconfigure(1, weight=1)
row = 0
# pracmln project options
Label(self.frame, text='PRACMLN Project: ').grid(row=row, column=0,
sticky='ES')
project_container = Frame(self.frame)
project_container.grid(row=row, column=1, sticky="NEWS")
# new proj file
self.btn_newproj = Button(project_container, text='New Project...', command=self.new_project)
self.btn_newproj.grid(row=0, column=1, sticky="WS")
# open proj file
self.btn_openproj = Button(project_container, text='Open Project...', command=self.ask_load_project)
self.btn_openproj.grid(row=0, column=2, sticky="WS")
# save proj file
self.btn_updateproj = Button(project_container, text='Save Project...', command=self.noask_save_project)
self.btn_updateproj.grid(row=0, column=3, sticky="WS")
# save proj file as...
self.btn_saveproj = Button(project_container, text='Save Project as...', command=self.ask_save_project)
self.btn_saveproj.grid(row=0, column=4, sticky="WS")
# grammar selection
row += 1
Label(self.frame, text='Grammar: ').grid(row=row, column=0, sticky='E')
grammars = ['StandardGrammar', 'PRACGrammar']
self.selected_grammar = StringVar()
self.selected_grammar.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_grammar) + tuple(grammars))
l.grid(row=row, column=1, sticky='NWE')
# logic selection
row += 1
Label(self.frame, text='Logic: ').grid(row=row, column=0, sticky='E')
logics = ['FirstOrderLogic', 'FuzzyLogic']
self.selected_logic = StringVar()
self.selected_logic.trace('w', self.settings_setdirty)
l = OptionMenu(*(self.frame, self.selected_logic) + tuple(logics))
l.grid(row=row, column=1, sticky='NWE')
# mln section
row += 1
Label(self.frame, text="MLN: ").grid(row=row, column=0, sticky='NE')
self.mln_container = FileEditBar(self.frame, directory=self.dir,
filesettings={'extension': '.mln', 'ftypes': [('MLN files', '.mln')]},
defaultname='*unknown{}',
importhook=self.import_mln,
deletehook=self.delete_mln,
projecthook=self.save_proj,
filecontenthook=self.mlnfilecontent,
fileslisthook=self.mlnfiles,
updatehook=self.update_mln,
onchangehook=self.project_setdirty)
self.mln_container.editor.bind("<FocusIn>", self._got_focus)
self.mln_container.grid(row=row, column=1, sticky="NEWS")
self.mln_container.columnconfigure(1, weight=2)
self.frame.rowconfigure(row, weight=1)
row += 1
self.use_emln = IntVar()
self.use_emln.set(0)
self.cb_use_emln = Checkbutton(self.frame, text="use model extension",
variable=self.use_emln,
command=self.onchange_use_emln)
self.cb_use_emln.grid(row=row, column=1, sticky="W")
# mln extension section
row += 1
self.emlncontainerrow = row
self.emln_label = Label(self.frame, text="EMLN: ")
self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky='NE')
self.emln_container = FileEditBar(self.frame,
directory=self.dir,
filesettings={'extension': '.emln', 'ftypes': [('MLN extension files','.emln')]},
defaultname='*unknown{}',
importhook=self.import_emln,
deletehook=self.delete_emln,
projecthook=self.save_proj,
filecontenthook=self.emlnfilecontent,
fileslisthook=self.emlnfiles,
updatehook=self.update_emln,
onchangehook=self.project_setdirty)
self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NEWS")
#.........这里部分代码省略.........
示例15: createWidgets
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import columnconfigure [as 别名]
def createWidgets(self):
panel = Frame(self, name="mainMenu")
panel.grid(sticky=W)
Button(panel, name="quit", text="Выход", command=self.__quit__).grid(row=0, column=0)
Button(panel, name="reconnect", text="Пересоединение", command=self.control.reconnect).grid(row=0, column=1)
b = Button(panel, text="Загрузить", command=self.loadSettings)
b.grid(row=0, column=2)
self.disabledWhileRunning.append(b)
b = Button(panel, text="Сохранить", command=self.saveSettings)
b.grid(row=0, column=3)
self.disabledWhileRunning.append(b)
panel = LabelFrame(self, text="Прямое управление стаканом", name="motor")
panel.grid(sticky=W)
b = Button(panel, text="Вверх", command=self.__up__, name="up")
b.grid(row=0, column=0)
self.disabledWhileRunning.append(b)
b = Button(panel, text="Вниз", command=self.__down__, name="down")
b.grid(row=1, column=0)
self.disabledWhileRunning.append(b)
Label(panel, text="Шаг:").grid(sticky=E, row=0, column=1)
self.steps = IntVar(self, "10000")
Entry(panel, textvariable=self.steps, width=6).grid(sticky=W, row=0, column=2)
Label(panel, text="Скорость:").grid(sticky=E, row=1, column=1)
self.speed = IntVar(self, "2000")
Entry(panel, textvariable=self.speed, width=6).grid(sticky=W, row=1, column=2)
self.position = IntVar(self, "1000")
def readPosition():
try:
self.position.set(self.control.mover.getPosition())
except (ConnectionResetError, Timeout):
pass
run_repeating(self, readPosition, 10000)
b = Button(panel, text="Прочитать положение", command=readPosition)
b.grid(row=0, column=3, columnspan=2)
self.disabledWhileRunning.append(b)
Label(panel, text="Положение:").grid(sticky=E, row=1, column=3)
Entry(panel, textvariable=self.position, width=8, state="disabled").grid(sticky=W, row=1, column=4)
panel = LabelFrame(self, text="Программа", name="program")
program = panel
panel.grid(sticky=W + E)
panel.columnconfigure(1, weight=1)
row = 0
for f in self.formulae:
columns, rows = self.grid_size()
Label(panel, text="Насос %d:" % (row + 1)).grid(row=row, column=0, sticky=E)
e = Entry(panel, textvariable=f)
e.grid(sticky=E + W, row=row, column=1)
self.disabledWhileRunning.append(e)
f.trace("w", lambda *x: self.after_idle(self.plotFormulae))
row += 1
panel = Frame(program, name="mover")
panel.grid(columnspan=2, sticky=W)
Label(panel, text="Максимальное смещение:").grid(sticky=E)
Entry(panel, textvariable=self.maxTravel).grid(sticky=W, row=0, column=1)
Label(panel, text="Скорость:").grid(sticky=E)
Entry(panel, textvariable=self.programSpeed).grid(sticky=W, row=1, column=1)
Label(panel, text="Время выполнения (в секундах):").grid(sticky=E)
e = Entry(panel, textvariable=self.executionTime)
e.grid(sticky=W, row=2, column=1)
self.current_time = DoubleVar(self, "0")
Label(panel, text="Текущее время:").grid(sticky=E)
e = Entry(panel, textvariable=self.current_time)
e.grid(sticky=W, row=3, column=1)
self.disabledWhileRunning.append(e)
self.executionTime.trace("w", lambda *x: self.plotFormulae())
panel = Frame(program, name="bottom")
panel.grid(columnspan=2, sticky=W)
row = 0
startButton = Button(panel, name="start", text="Старт", command=self.__start__)
startButton.grid(row=row, column=0)
self.disabledWhileRunning.append(startButton)
Button(panel, text="Стоп", command=self.__stop__).grid(row=row, column=1)
self.canvas = GraphCanvas(self)
self.graphs = (Graph(self.canvas), Graph(self.canvas))
self.canvas.x.end = 100
self.canvas.y.end = 24
self.plotFormulae()
self.canvas.grid(sticky=E + W + S + N)
columns, rows = self.grid_size()
self.columnconfigure(columns - 1, weight=1)
self.rowconfigure(rows - 1, weight=1)