本文整理汇总了Python中tkinter.Frame.rowconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.rowconfigure方法的具体用法?Python Frame.rowconfigure怎么用?Python Frame.rowconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.rowconfigure方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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)
示例2: showPlotTools
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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)
示例3: _build_cell
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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
示例4: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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()
示例5: showPlotTools
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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)
示例6: Example
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("EGUANA")
self.style = ttk.Style()
self.style.theme_use("alt")
self.photoName = "eguana.gif"
self.frame = Frame(self, relief=FLAT, borderwidth=10,bg='#FADC46')
self.frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
self.setupMenuBar()
self.setupTopBar()
def setupMenuBar(self):
self.menubar = EguanaMenu(self.parent,self)
self.parent.config(menu=self.menubar)
def setupTopBar(self):
self.openButton3D = Button(self.frame,text="Select Directory for 3D EMA",relief=RAISED,command=self.askDirectory)
self.openButton3D.grid(row=0,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.openButton2D = Button(self.frame,text="Select Directory for 2D EMA",relief=RAISED,command=self.askDirectory);
self.openButton2D.grid(row=2,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p1Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p1Button.grid(row=0,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.p2Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p2Button.grid(row=0,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p3Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p3Button.grid(row=1,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.p4Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p4Button.grid(row=1,column=2, sticky=N+S+E+W,padx=2,pady =2)
self.p5Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p5Button.grid(row=2,column=0, sticky=N+S+E+W,padx=2,pady =2)
self.p6Button = Button(self.frame,text="Placeholder",relief=RAISED)
self.p6Button.grid(row=2,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.openButton3D.bind('<Motion>',self.cursorPosition)
self.openButton2D.bind('<Motion>',self.cursorPosition)
self.photo = PhotoImage(file="eguana.gif")
self.photo = self.photo.subsample(2);
self.photo_label = Label(self.frame,image=self.photo,borderwidth=0,highlightthickness=0)
self.photo_label.configure(bg='#FADC46')
self.photo_label.grid(row=1,column=1, sticky=N+S+E+W,padx=2,pady =2)
self.photo_label.image = self.photo
self.frame.columnconfigure(0, weight=1)
self.frame.columnconfigure(1, weight=1)
self.frame.columnconfigure(2, weight=1)
self.frame.rowconfigure(0, weight=1)
self.frame.rowconfigure(1, weight=1)
self.frame.rowconfigure(2, weight=1)
def askDirectory(self):
dirStr = filedialog.askdirectory()
if len(dirStr):
self.openButton3D.destroy()
self.openButton2D.destroy()
self.p1Button.destroy()
self.p2Button.destroy()
self.p3Button.destroy()
self.p4Button.destroy()
self.p5Button.destroy()
self.p6Button.destroy()
self.menubar.entryconfigure('Filter', state = 'active')
self.photo_label.destroy()
dirStr = 'Input Path : '+dirStr
self.frame.grid_forget()
self.infoFrame = Frame(self.frame, relief=FLAT, bg='#FADC46')
self.infoFrame.grid(row=0,column=0,columnspan=3, sticky=N+S+E+W,padx=2,pady =2)
self.directoryLabel = Label(self.infoFrame, text="No project currently selected",relief=FLAT)
self.directoryLabel.grid(row=0,column=0,columnspan=2, sticky=N+S+E+W,padx=2,pady =2)
#.........这里部分代码省略.........
示例7: BuildMainFrame
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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: MLNQueryGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [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")
#.........这里部分代码省略.........
示例9: EguanaGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
class EguanaGUI(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
# if not EguanaInit.eguana_root_dir_exists():
# EguanaInit.create_eguana_root_dir()
def initUI(self):
self.parent.title("EGUANA")
self.style = ttk.Style()
self.style.theme_use("alt")
self.photoName = "eguana.gif"
self.frame = Frame(self, relief=FLAT, borderwidth=10,bg='#FADC46')
self.frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
self.setupMenuBar()
self.setupTopBar()
def setupMenuBar(self):
self.menubar = EguanaMenu(self.parent,self)
self.parent.config(menu=self.menubar)
def setupTopBar(self):
self.supportedDevices = []
for fileName in [name for name in os.listdir('./machineConfig') if os.path.isfile('./machineConfig/' + name) and not name == 'eguanaMachineConfig.py' and name.endswith('.py')]:
# try:{
components = fileName.split('.')
fileName = components[0]
className = fileName[0].upper() + fileName[1:]
try:
module = __import__("machineConfig."+fileName,fromlist=["machineConfig."])
classVar = getattr(module,className)
except:
continue
self.supportedDevices.append(classVar())
# except:
# pass
self.selectMachineFrame = Frame(self.frame,relief=FLAT,bg='#FADC46')
self.selectMachineFrame.pack(fill=BOTH,expand=True)
self.setupSelectMachineButtons()
def setupSelectMachineButtons(self):
numDevices = len(self.supportedDevices)
numColumns = 3
numRows = math.ceil((numDevices+1)/3)
self.photo = PhotoImage(file="eguana.gif")
self.photo = self.photo.subsample(2);
self.photo_label = Label(self.selectMachineFrame,image=self.photo,borderwidth=0,highlightthickness=0)
self.photo_label.configure(bg='#FADC46')
self.photo_label.grid(row=int(numRows/2),column=1, sticky=N+S+E+W,padx=2,pady =2)
self.photo_label.image = self.photo
index = 0
for i in range(numRows):
for j in range(numColumns):
if not(j == 1 and i == int(numRows/2)) and (index < numDevices):
device = self.supportedDevices[index]
b = Button(self.selectMachineFrame,text=device.name,relief=RAISED, command=lambda device=device :self.machineButtonPressed(device))
b.grid(row=i,column=j, sticky=N+S+E+W,padx=2,pady =2)
index += 1
for i in range(numRows):
self.selectMachineFrame.rowconfigure(i,weight=1)
for i in range(numColumns):
self.selectMachineFrame.columnconfigure(i,weight=1)
def machineButtonPressed(self,inputDevice):
dirStr = filedialog.askdirectory()
if len(dirStr) and inputDevice.isDirectoryValid(dirStr):
inputDevice.setDirPath(dirStr)
EguanaModel().machine = inputDevice
self.selectMachineFrame.destroy()
self.menubar.inputSelected()
self.photo_label.destroy()
dirStr = 'Input Path : '+dirStr
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
class SpeciesSearchDialog:
def __init__(self, parent, caller):
# main window
self.parent = parent
# dialog that called this second dialog
self.caller = caller
self.gui = Toplevel(parent.guiRoot)
self.gui.grab_set()
self.gui.focus()
self.gui.columnconfigure(0, weight=1)
self.gui.rowconfigure(1, weight=1)
self.entrySearch = Entry(self.gui)
self.buttonSearch = Button(self.gui, text=" Search ")
self.buttonAdd = Button(self.gui, text=" Add Species ")
self.buttonClose = Button(self.gui, text=" Close Window ")
self.frameResults = Frame(self.gui)
self.frameResults.columnconfigure(0, weight=1)
self.frameResults.rowconfigure(0, weight=1)
self.scrollResults = Scrollbar(self.frameResults, orient="vertical")
self.scrollResults.grid(row=0, column=1, sticky="ns")
self.listResults = Listbox(self.frameResults, width=70, height=20)
self.listResults.grid(row=0, column=0, sticky="nswe")
self.listResults.config(yscrollcommand=self.scrollResults.set)
self.scrollResults.config(command=self.listResults.yview)
self.entrySearch.grid(row=0, column=0, columnspan=2, sticky="we", padx=5, pady=5)
self.frameResults.grid(row=1, column=0, columnspan=3, sticky="nswe", padx=5, pady=5)
self.buttonSearch.grid(row=0, column=2, padx=5, pady=5, sticky="e")
self.buttonAdd.grid(row=2, column=1, padx=5, pady=5, sticky="e")
self.buttonClose.grid(row=2, column=2, padx=5, pady=5, sticky="e")
self.gui.protocol("WM_DELETE_WINDOW", self.actionClose)
self.buttonClose.bind("<ButtonRelease>", self.actionClose)
self.buttonAdd.bind("<ButtonRelease>", self.actionAdd)
self.buttonSearch.bind("<ButtonRelease>", self.actionSearch)
self.entrySearch.bind("<Return>", self.actionSearch)
self.gui.update()
self.gui.minsize(self.gui.winfo_width(), self.gui.winfo_height())
self.gui.mainloop()
def actionAdd(self, event):
try:
selection = self.listResults.selection_get()
selectionSplit = selection.split(":\t", 1)
selectionSplit2 = selectionSplit[1].split("\t")
if not (selectionSplit[0], selectionSplit2[0]) in self.parent.optimizer.speciesList:
self.parent.optimizer.speciesList.append((selectionSplit[0], selectionSplit2[0].strip()))
self.caller.gui.event_generate("<<Update>>")
except tkinter.TclError:
# no selection
pass
def actionSearch(self, event):
query = self.entrySearch.get()
if query:
self.listResults.delete(0, "end")
results = self.parent.optimizer.SPSUMHandler.search(query)
# sort results by nr of CDS
results = sorted(results.items(), reverse=True, key=lambda x: (int(x[1][1])))
for name, (taxid, ncs) in results:
self.listResults.insert("end", taxid + ":\t " + name + " \t(" + ncs + " CDS)")
def actionClose(self, event=None):
self.caller.gui.event_generate("<<Update>>", when="tail")
self.gui.destroy()
示例11: reactToClick
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
class OptimizerMainWindow:
"""
classdocs
"""
# TODO: change that name
def reactToClick(self, event):
a = AddRestrictionDialog(self)
def __init__(self, optimizer):
# always have a reference to model/controller
self.optimizer = optimizer
# setup main GUI and make stretchable
self.guiRoot = Tk()
self.guiRoot.title("OPTIMIZR")
self.guiRoot.columnconfigure(1, weight=1)
self.guiRoot.rowconfigure(0, weight=1)
# left (settings) and right (sequences) part
self.frameLeft = Frame(self.guiRoot)
self.frameLeft.grid(row=0, column=0, sticky=W + E + N + S)
self.frameLeft.columnconfigure(0, weight=1)
self.frameRight = Frame(self.guiRoot)
self.frameRight.grid(row=0, column=1, sticky=W + E + N + S)
self.frameRight.columnconfigure(0, weight=1)
self.frameRight.rowconfigure(0, weight=1)
self.frameRight.rowconfigure(1, weight=1)
self.frameSpeciesControll = LabelFrame(self.frameLeft, text="Species", pady=10, padx=10)
self.frameSpeciesControll.columnconfigure(1, weight=1)
self.frameOptimizationControll = LabelFrame(self.frameLeft, text="Optimization", pady=10, padx=10)
self.frameRestrictionControll = LabelFrame(self.frameLeft, text="Restriction Enzymes", pady=10, padx=10)
self.frameSpeciesControll.grid(row=0, column=0, sticky=W + E, padx=10, pady=10)
self.frameOptimizationControll.grid(row=1, column=0, sticky=W + E, padx=10, pady=10)
self.frameRestrictionControll.grid(row=2, column=0, sticky=W + E, padx=10, pady=10)
# Species Controll
Label(self.frameSpeciesControll, text="Source:").grid(row=0, column=0)
Label(self.frameSpeciesControll, text="Target:").grid(row=1, column=0)
self.comboSourceSpecies = Combobox(self.frameSpeciesControll, state="readonly")
self.comboSourceSpecies.grid(row=0, column=1, pady=5, sticky="ew")
self.comboTargetSpecies = Combobox(self.frameSpeciesControll, state="readonly")
self.comboTargetSpecies.grid(row=1, column=1, pady=5, sticky="we")
self.buttonSpeciesList = Button(self.frameSpeciesControll, text="Edit Species List")
self.buttonSpeciesList.grid(row=2, column=1, pady=5, sticky="e")
self.comboSourceSpecies.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
self.comboTargetSpecies.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
# Optimization Controll
Label(self.frameOptimizationControll, text="Optimization Strategy:").grid(row=0, column=0)
self.comboOptimizationStrategy = Combobox(self.frameOptimizationControll, state="readonly")
self.comboOptimizationStrategy.grid(row=0, column=1)
self.comboOptimizationStrategy["values"] = self.optimizer.possibleOptimizationStrategies
self.comboOptimizationStrategy.bind("<<ComboboxSelected>>", self.actionOptimizerSettingsChanged)
# Restriction Enzymes
self.listRestriction = Listbox(self.frameRestrictionControll)
self.listRestriction.grid(row=0, column=0, columnspan=3, pady=5, sticky=W + E)
self.frameRestrictionControll.columnconfigure(0, weight=1)
self.buttonRestricionAdd = Button(self.frameRestrictionControll, text=" + ")
self.buttonRestricionDel = Button(self.frameRestrictionControll, text=" - ")
self.buttonRestricionAdd.grid(row=1, column=1, padx=5)
self.buttonRestricionDel.grid(row=1, column=2, padx=5)
# Source Sequence Frame
self.frameSourceSequence = LabelFrame(self.frameRight, text="Source Sequence", padx=10, pady=10)
self.frameResultSequence = LabelFrame(self.frameRight, text="Result Sequence", padx=10, pady=10)
self.frameSourceSequence.grid(row=0, column=0, sticky="wens", padx=10, pady=10)
self.frameResultSequence.grid(row=1, column=0, sticky="wens", padx=10, pady=10)
self.buttonSourceLoad = Button(self.frameSourceSequence, text=" Load ")
self.textSourceSeq = ScrolledText(self.frameSourceSequence, height=10)
self.buttonSourceLoad.grid(row=0, column=1, sticky="e", pady=5)
self.textSourceSeq.grid(row=1, column=0, columnspan=2, sticky="wens")
self.frameSourceSequence.columnconfigure(0, weight=1)
self.frameSourceSequence.rowconfigure(1, weight=1)
self.textSourceSeq.frame.columnconfigure(1, weight=1)
self.textSourceSeq.frame.rowconfigure(0, weight=1)
self.buttonOptimize = Button(self.frameResultSequence, text=" OPTIMIZE! ")
self.buttonOptimize.bind("<ButtonRelease>", self.actionOptimize)
self.buttonRemoveRestriction = Button(self.frameResultSequence, text=" RESTRICTION-B-GONE! ")
self.buttonRemoveRestriction.bind("<ButtonRelease>", self.actionRemoveRestricion)
self.buttonSaveResult = Button(self.frameResultSequence, text=" Save ")
self.textResultSequence = ScrolledText(self.frameResultSequence, height=10)
self.buttonOptimize.grid(column=0, row=0, pady=5, sticky="w")
self.buttonRemoveRestriction.grid(column=1, row=0, pady=5, padx=10, sticky="w")
self.textResultSequence.grid(row=1, column=0, columnspan=4, sticky="wens")
self.buttonSaveResult.grid(row=2, column=3, pady=5, sticky="e")
self.frameResultSequence.columnconfigure(2, weight=1)
self.frameResultSequence.rowconfigure(1, weight=1)
self.textResultSequence.frame.columnconfigure(1, weight=1)
self.textResultSequence.frame.rowconfigure(0, weight=1)
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
class OthelloGUI:
n = 1
def __init__(self):
self._configure_game()
self._init_game()
self.refresh_board()
def _configure_game(self) -> None:
config = ConfigureGUI()
config.start()
self.game = config.getOthello()
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)
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
def refresh_board(self) -> None:
self.draw_board()
self._score_label["text"] = "I update when things happen. n = %d" % self.n
self.n = self.n + 1
def draw_board(self) -> None:
for cell in self.cells:
p = Point(cell.col, cell.row)
board_piece = self.game.board.piece_at(p)
if(Piece.is_playable_piece(board_piece)):
self.draw_piece(cell, board_piece)
if cell.bound:
cell._canvas.unbind("<ButtonPress-1>", None)
else:
cell._canvas.bind("<ButtonPress-1>", self.click_empty)
cell.bound = True
def draw_piece(self, cell: Frame, piece: Piece) -> None:
cell._canvas.delete(const.ALL)
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
def __init__(self):
"""
Methode speciale initialisant une nouvelle fenêtre de jeu Ultimate Tic-Tac-Toe.
"""
super().__init__()
# Nom de la fenêtre.
self.title("Ultimate Tic-Tac-Toe")
# La partie de ultimate Tic-Tac-Toe
self.partie = Partie()
# Un ditionnaire contenant les 9 canvas des 9 plateaux du jeu
self.canvas_uplateau = {}
# Création de deux joueurs.
self.JoueursDuJeux()
Popup()
# Création des frames et des canvas du jeu
for i in range(0, 3):
for j in range(0, 3):
cadre = Frame(self, borderwidth=5, relief=GROOVE, background = '#e1e1e1')
cadre.grid(row=i, column=j, padx=5, pady=5)
cadre.columnconfigure(0, weight=1)
cadre.rowconfigure(0, weight=1)
cadre.columnconfigure(1, weight=1)
cadre.rowconfigure(1, weight=1)
cadre.columnconfigure(2, weight=1)
cadre.rowconfigure(2, weight=1)
#cadre.columnconfigure(j, weight=1)
#cadre.rowconfigure(i, weight=1)
#Dessiner le cadre en jaune si la sourie entre dans le cadre
cadre.bind('<Enter>', self.entrer_frame)
cadre.bind('<Leave>', self.sortir_frame)
self.canvas_uplateau[i, j] = CanvasPlateau(cadre, self.partie.uplateau[i, j])
self.canvas_uplateau[i, j].grid()
# On lie un clic sur le Canvas à une méthode.
self.canvas_uplateau[i, j].bind('<Button-1>', self.selectionner)
#Pour redimensionner automatiquement la fenêtre principale
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(1, weight=1)
self.grid_columnconfigure(2, weight=1)
self.grid_rowconfigure(2, weight=1)
# Ajout d'une étiquette d'information.
self.messages = Label(self)
self.messages.grid(column=0, row=4, columnspan=3)
# Ajout d'une étiquette pour le nom des joueurs.
self.labNoms = Label(self)
self.labNoms.grid(column=0, row=5)
# Ajout d'une étiquette pour la date et le chronometre.
self.labDate = Label(self)
self.labDate.grid(column=0, row=6)
# Les bouttons en dessous
B1 = Button(self, text='Règles', width=15, command=self.regles).grid(row=7,column=0)
B2 = Button(self, text='Nouvelle Partie', width=15, command=self.nouvellePartie).grid(row=7, column=1)
B3 = Button(self, text='Statistiques', width=15, command=self.statistiques).grid(row=7, column=2)
B4 = Button(self, text='Historique', width=15, command=self.regles).grid(row=8, column=1)
B5 = Button(self, text='Quitter', width=5, command=self.quitter).grid(row=8, column=2)
B5 = Button(self, text='Tout recommencer', width=15, command=self.regles).grid(row=8, column=0)
示例14: show_items
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import rowconfigure [as 别名]
def show_items(self, items, upper=[]):
"""
Creates a new page on the stack, automatically adds a back button when there are
pages on the stack already
:param items: list the items to display
:param upper: list previous levels' ids
:return: None
"""
num = 0
# create a new frame
wrap = Frame(self, bg="black")
# when there were previous frames, hide the top one and add a back button for the new one
if len(self.framestack):
self.hide_top()
back = FlatButton(
wrap,
text='back…',
image=self.get_icon("arrow.left"),
command=self.go_back,
)
back.set_color("#00a300") # green
back.grid(row=0, column=0, padx=1, pady=1, sticky=TkC.W + TkC.E + TkC.N + TkC.S)
num += 1
# add the new frame to the stack and display it
self.framestack.append(wrap)
self.show_top()
# calculate tile distribution
all = len(items) + num
rows = floor(sqrt(all))
cols = ceil(all / rows)
# make cells autoscale
for x in range(int(cols)):
wrap.columnconfigure(x, weight=1)
for y in range(int(rows)):
wrap.rowconfigure(y, weight=1)
# display all given buttons
for item in items:
act = upper + [item['name']]
if 'icon' in item:
image = self.get_icon(item['icon'])
else:
image = self.get_icon('scrabble.'+item['label'][0:1].lower())
btn = FlatButton(
wrap,
text=item['label'],
image=image
)
if 'items' in item:
# this is a deeper level
btn.configure(command=lambda act=act, item=item: self.show_items(item['items'], act), text=item['label']+'…')
btn.set_color("#2b5797") # dark-blue
else:
# this is an action
btn.configure(command=lambda act=act: self.go_action(act), )
if 'color' in item:
btn.set_color(item['color'])
# add buton to the grid
btn.grid(
row=int(floor(num / cols)),
column=int(num % cols),
padx=1,
pady=1,
sticky=TkC.W + TkC.E + TkC.N + TkC.S
)
num += 1