本文整理汇总了Python中tkinter.Frame.grid_rowconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_rowconfigure方法的具体用法?Python Frame.grid_rowconfigure怎么用?Python Frame.grid_rowconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid_rowconfigure方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: home_page
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def home_page(self, master):
frame = Frame(master)
frame.grid(row=0, column=0)
image = PhotoImage(file="img/guido.gif")
bg = Label(frame, image=image)
bg.image = image
bg.grid(row=0, column=0, rowspan=4, columnspan=2)
index = 0
while index < 3:
frame.grid_columnconfigure(index, minsize=200)
frame.grid_rowconfigure(index, minsize=80)
index += 1
summary_button = HomeButton(frame, self.to_summary, 'img/summary.png')
summary_button.grid(row=0, column=0, sticky='w')
edit_button = HomeButton(frame, self.to_edit, 'img/edit.png')
edit_button.grid(row=0, column=1, sticky='e')
momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png')
momentary_button.grid(row=1, column=0, sticky='w')
preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png')
preferences_button.grid(row=1, column=1, sticky='e')
music = HomeButton(frame, self.to_summary, 'img/music.png')
music.grid(row=2, column=0, sticky='w')
info = HomeButton(frame, self.to_summary, 'img/info.png')
info.grid(row=2, column=1, sticky='e')
return frame
示例2: create_instance_panel
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def create_instance_panel(self):
frm_inst = Frame(self.ntbk)
frm_inst.grid_columnconfigure(0, weight=1)
frm_inst.grid_rowconfigure(0, weight=1)
frm_inst.grid_columnconfigure(1, weight=3)
frm_inst.grid_rowconfigure(1, weight=0)
self.instance_list = Listbox(frm_inst, width=20)
self.instance_list.bind('<<ListboxSelect>>', self.select_instance)
self.instance_list.pack()
self.instance_list.grid(row=0, column=0, sticky=(N, S, W, E))
self.instance_txt = Text(frm_inst, width=75)
self.instance_txt.grid(row=0, column=1, rowspan=2, sticky=(N, S, W, E))
self.instance_txt.config(state=DISABLED)
self.btninstframe = Frame(frm_inst, bd=1)
self.btninstframe.grid(row=1, column=0, columnspan=1)
self.btninstframe.grid_columnconfigure(0, weight=1)
Button(self.btninstframe, text=ugettext("Launch"), width=25, command=self.open_inst).grid(
row=0, column=0, columnspan=2, sticky=(N, S))
Button(self.btninstframe, text=ugettext("Modify"), width=10,
command=self.modify_inst).grid(row=1, column=0, sticky=(N, S))
Button(self.btninstframe, text=ugettext("Delete"), width=10,
command=self.delete_inst).grid(row=1, column=1, sticky=(N, S))
Button(self.btninstframe, text=ugettext("Save"), width=10,
command=self.save_inst).grid(row=2, column=0, sticky=(N, S))
Button(self.btninstframe, text=ugettext("Restore"), width=10,
command=self.restore_inst).grid(row=2, column=1, sticky=(N, S))
Button(self.btninstframe, text=ugettext("Add"), width=25, command=self.add_inst).grid(
row=3, column=0, columnspan=2, sticky=(N, S))
self.ntbk.add(frm_inst, text=ugettext('Instances'))
示例3: create_module_panel
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def create_module_panel(self):
frm_mod = Frame(self.ntbk)
frm_mod.grid_columnconfigure(0, weight=1)
frm_mod.grid_rowconfigure(0, weight=1)
self.module_txt = Text(frm_mod)
self.module_txt.grid(row=0, column=0, sticky=(N, S, W, E))
self.module_txt.config(state=DISABLED)
self.ntbk.add(frm_mod, text=ugettext('Modules'))
示例4: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def __init__(self):
Tk.__init__(self)
Tk.wm_title(self, 'Five in a Row')
container = Frame(self)
container.pack(side='top', fill='both', expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
frame = GameUI(container, self)
self.frames[GameUI] = frame
frame.grid(row=0, column=0, sticky='nsew')
self.show_frame(GameUI)
示例5: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# Container where the different Frames stack
container = Frame(self)
container.pack(side='top', fill='both', expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (Main, ReadFromFile, AddManually):
page_name = F.__name__
frame = F(container, self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky='nsew')
self.show_frame('Main')
示例6: Edit
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class Edit(Frame):
def __init__(self, master, valves):
Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
self.master = master
self.canvas = Canvas(self, height=630, width=1320, bg='sky blue')
self.frame = Frame(self.canvas, bg='sky blue')
self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 800])
self.scrollbar.pack(side='right', fill='y')
self.canvas.pack(side='left')
self.canvas.create_window((0, 0), window=self.frame, anchor='nw')
self.valves = valves
self.frame.config(bg='sky blue')
index = 0
while index < 10:
self.frame.grid_rowconfigure(index, minsize=80)
self.frame.grid_columnconfigure(index, minsize=30)
index += 1
self.frame.grid_columnconfigure(3, minsize=130)
self.frame.grid_columnconfigure(6, minsize=130)
interval = Label(self.frame, text='RUN', width=6, font=('Lucida Console', 30))
interval.grid(row=0, column=2)
interval.config(bg='sky blue', fg='RoyalBlue4')
delay = Label(self.frame, text='DELAY', width=6, font=('Lucida Console', 30))
delay.grid(row=0, column=5)
delay.config(bg='sky blue', fg='RoyalBlue4')
self.seconds = [IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar()]
for each in self.seconds:
each.set(0)
self.set_seconds()
self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
Label(self.frame, textvariable=self.valves[1].get_name()),
Label(self.frame, textvariable=self.valves[2].get_name()),
Label(self.frame, textvariable=self.valves[3].get_name()),
Label(self.frame, textvariable=self.valves[4].get_name()),
Label(self.frame, textvariable=self.valves[5].get_name()),
Label(self.frame, textvariable=self.valves[6].get_name()),
Label(self.frame, textvariable=self.valves[7].get_name())
]
row = 1
for each in self.valve_label:
each.grid(row=row, column=0)
each.config(width=8, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
row += 1
self.minus_image = PhotoImage(file="img/minus.png").subsample(x=5, y=5)
self.minusInterval = [Button(self.frame, image=self.minus_image, command=lambda: self.subtract(0)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(1)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(2)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(3)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(4)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(5)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(6)),
Button(self.frame, image=self.minus_image, command=lambda: self.subtract(7)),
]
row = 1
for each in self.minusInterval:
each.grid(row=row, column=1)
each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
row += 1
self.labelInterval = [Label(self.frame, textvariable=self.seconds[0]),
Label(self.frame, textvariable=self.seconds[1]),
Label(self.frame, textvariable=self.seconds[2]),
Label(self.frame, textvariable=self.seconds[3]),
Label(self.frame, textvariable=self.seconds[4]),
Label(self.frame, textvariable=self.seconds[5]),
Label(self.frame, textvariable=self.seconds[6]),
Label(self.frame, textvariable=self.seconds[7])]
#.........这里部分代码省略.........
示例7: tail
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
def tail(f):
line = f.readline()
while line:
logfile.insert('end', line)
logfile.see("end")
line = f.readline()
logfile.after(100, tail, f)
root = Tk()
""""
def callback():
not(autoscroll)
"""
logframe = Frame(root, relief='ridge', bd=2)
logframe.grid_rowconfigure(0, weight=1)
logframe.grid_columnconfigure(0, weight=1)
sb = Scrollbar(logframe)
sb.grid(row=0, column=1, sticky='n s')
logfile = Text(logframe, wrap='word', yscrollcommand=sb.set)
logfile.grid(row=0, column=0, sticky='n s e w')
sb.config(command=logfile.yview)
logframe.pack()
"""b = Button(root, text = "autoscroll", command = callback )
b.pack(side=BOTTOM)
b.config(state = ACTIVE)
"""
termf = Frame(root, height=200, width=500, relief='ridge', bd=2)
termf.pack()
wid = termf.winfo_id()
os.system('urxvt -embed {} -geometry 500x200 -e python3 -i -c "from {} import*" &'.format(wid, sys.argv[1]))
示例8: Preferences
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class Preferences(Frame):
def __init__(self, master, valves):
Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
self.master = master
self.canvas = Canvas(self, height=640, width=1300, bg='sky blue')
self.frame = Frame(self.canvas, bg='sky blue')
self.frame.bind('<Button-1>', self.process_click_out)
self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 2100])
self.scrollbar.pack(side='right', fill='y')
self.canvas.pack(side='left')
self.canvas.create_window((0, 0), window=self.frame, anchor='nw')
self.keyboard = Keyboard(self.master)
self.valves = valves
self.frame.config(bg='sky blue')
index = 0
while index < 25:
self.frame.grid_rowconfigure(index, minsize=80)
self.frame.grid_columnconfigure(index, minsize=150)
index += 1
num_label = [Label(self.frame, text='1'),
Label(self.frame, text='2'),
Label(self.frame, text='3'),
Label(self.frame, text='4'),
Label(self.frame, text='5'),
Label(self.frame, text='6'),
Label(self.frame, text='7'),
Label(self.frame, text='8'),
]
row = 1
for each in num_label:
each.grid(row=row, column=0)
each.config(width=3, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
row += 3
text_label = [Label(self.frame, text='VALVE 1: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 2: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 3: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 4: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 5: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 6: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 7: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: '),
Label(self.frame, text='VALVE 8: '),
Label(self.frame, text='ACTION A: '),
Label(self.frame, text='ACTION B: ')
]
row = 1
for each in text_label:
each.grid(row=row, column=1)
each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
row += 1
self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
Label(self.frame, textvariable=self.valves[1].get_name()),
Label(self.frame, textvariable=self.valves[2].get_name()),
Label(self.frame, textvariable=self.valves[3].get_name()),
Label(self.frame, textvariable=self.valves[4].get_name()),
Label(self.frame, textvariable=self.valves[5].get_name()),
Label(self.frame, textvariable=self.valves[6].get_name()),
Label(self.frame, textvariable=self.valves[7].get_name())]
row = 1
for each in self.valve_label:
each.grid(row=row, column=2)
each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
each.bind('<Button-1>', self.process_click_out)
row += 3
self.entry_field = [Entry(self.frame, text=''),
Entry(self.frame, text=''),
Entry(self.frame, text=''),
#.........这里部分代码省略.........
示例9: MiniSedGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class MiniSedGUI(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.cfg = MiniSedConfig()
self.source_directory = None
self.target_directory = None
self.create_widgets()
self.pack(anchor=CENTER, fill=BOTH, expand=1)
self.files_with_content = []
self.cfg.directory.trace('w', self.disable_apply)
self.cfg.glob.trace('w', self.disable_apply)
self.cfg.search.trace('w', self.disable_apply)
self.cfg.replace.trace('w', self.disable_apply)
self.cfg.ignore_case.trace('w', self.disable_apply)
def disable_apply(self, *args):
self.run_btn["state"] = 'disabled'
def create_widgets(self):
self.directory_frame = Frame(self)
self.directory_frame.pack(side=TOP, fill=X, expand=0, padx=4, pady=4)
self.directory_frame.grid_columnconfigure(1, weight=1)
self.directory_label = Label(self.directory_frame, text="Directory:")
self.directory_label.grid(column=0, row=0)
self.directory_entry = Entry(self.directory_frame, textvariable=self.cfg.directory)
self.directory_entry.grid(column=1, row=0, sticky=W + E)
self.directory_entry.bind('<Return>', lambda arg: self.do_preview())
self.directory_button = Button(self.directory_frame, text="Browse")
self.directory_button["command"] = lambda: do_ask_directory(self.cfg.directory)
self.directory_button.grid(column=2, row=0)
self.glob_label = Label(self.directory_frame, text="Glob:")
self.glob_label.grid(column=0, row=1, stick=E)
self.glob_entry = Entry(self.directory_frame, textvariable=self.cfg.glob)
self.glob_entry.bind('<Return>', lambda arg: self.do_preview())
self.glob_entry.grid(column=1, row=1, sticky=N + S + W)
self.search_replace_frame = Frame(self)
self.search_replace_frame.grid_columnconfigure(1, weight=1)
self.search_replace_frame.pack(anchor=N, side=TOP, fill=X, expand=0, padx=4, pady=4)
self.search_label = Label(self.search_replace_frame, text="Search:")
self.search_label.grid(column=0, row=0, sticky=E)
self.search_entry = Entry(self.search_replace_frame, textvariable=self.cfg.search)
self.search_entry.grid(column=1, row=0, sticky=N + S + W + E)
self.search_entry.bind('<Return>', lambda arg: self.do_preview())
self.replace_label = Label(self.search_replace_frame, text="Replace:")
self.replace_label.grid(column=0, row=1, sticky=E)
self.replace_entry = Entry(self.search_replace_frame, textvariable=self.cfg.replace)
self.replace_entry.grid(column=1, row=1, sticky=N + S + W + E)
self.replace_entry.bind('<Return>', lambda arg: self.do_preview())
self.option_frame = Frame(self)
self.option_frame.pack(side=TOP, fill=X, expand=0, pady=4)
self.work_frame = LabelFrame(self.option_frame, text="Options")
self.work_frame.pack(side=LEFT, padx=4, pady=4)
self.ignore_case_checkbutton = Checkbutton(
self.work_frame, text="ignore case", variable=self.cfg.ignore_case)
self.ignore_case_checkbutton.pack(side=TOP, anchor=W, expand=0)
self.create_backups_checkbutton = Checkbutton(
self.work_frame, text="create backups", variable=self.cfg.create_backups)
self.create_backups_checkbutton.pack(side=TOP, anchor=W, expand=0)
self.preview_frame = LabelFrame(self.option_frame, text="Preview")
self.preview_frame.pack(side=LEFT, padx=4, pady=4)
self.show_full_content_checkbutton = Checkbutton(
self.preview_frame, text="show full content", variable=self.cfg.show_full_content)
self.show_full_content_checkbutton.pack(side=TOP, anchor=W, expand=0)
self.show_original_checkbutton = Checkbutton(
self.preview_frame, text="show original", variable=self.cfg.show_original)
self.show_original_checkbutton.pack(side=TOP, anchor=W, expand=0)
self.text_frame = Frame(self)
self.text_frame.pack(side=TOP, fill=BOTH, expand=1, pady=4)
self.text_frame.grid_columnconfigure(0, weight=1)
self.text_frame.grid_rowconfigure(0, weight=1)
self.scrollbar = Scrollbar(self.text_frame)
self.scrollbar.grid(column=1, row=0, sticky=N + S)
self.text = Text(self.text_frame, yscrollcommand=self.scrollbar.set, width=120, height=20)
self.text.tag_config("file", background="lightgray", foreground="black")
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class Momentary:
def __init__(self, master, valves):
self.valves = valves
self.master = master
self.frame1 = Frame(master)
self.frame2 = Frame(master)
self.master.configure(bg='sky blue')
self.frame1.configure(bg='sky blue')
self.frame2.configure(bg='sky blue')
index = 0
while index < 6:
self.frame1.grid_columnconfigure(index, minsize=6)
self.frame2.grid_columnconfigure(index, minsize=6)
self.frame1.grid_rowconfigure(index, minsize=140)
self.frame2.grid_rowconfigure(index, minsize=140)
index += 1
self.end_all_image = PhotoImage(file="img/stop.png").subsample(x=6, y=6)
self.end_all_button = Button(self.master, image=self.end_all_image, command=lambda: self.end_all() )
self.end_all_button.config(bg='brown3', activebackground='brown4', border=5, width=850)
self.label = [Label(self.frame1, textvariable=self.valves[0].get_name()),
Label(self.frame1, textvariable=self.valves[1].get_name()),
Label(self.frame1, textvariable=self.valves[2].get_name()),
Label(self.frame1, textvariable=self.valves[3].get_name()),
Label(self.frame2, textvariable=self.valves[4].get_name()),
Label(self.frame2, textvariable=self.valves[5].get_name()),
Label(self.frame2, textvariable=self.valves[6].get_name()),
Label(self.frame2, textvariable=self.valves[7].get_name())]
row = 0
for each in self.label:
each.config(width=7, height=2)
each.config(bg='sky blue', fg='RoyalBlue4', font=('Lucida Console', 30), padx=18)
each.grid(row=row % 4, column=0)
row += 1
self.lightsA = [LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False)
]
self.lightsB = [LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False)
]
self.v = [IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar(),
IntVar()]
for each in self.v:
each.set(3)
self.a = [Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(0), value=1),
Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(1), value=1),
Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(2), value=1),
Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(3), value=1),
Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(4), value=1),
Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(5), value=1),
Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(6), value=1),
Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(7), value=1)]
index = 0
for each in self.a:
each.grid(row=index % 4, column=2)
each.config(width=4, height=2, indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
each.config(activeforeground='white')
index += 1
self.b = [Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(0), value=0),
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(1), value=0),
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(2), value=0),
Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(3), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(4), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(5), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(6), value=0),
Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(7), value=0)]
index = 0
#.........这里部分代码省略.........
示例11: GUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class GUI(object):
'''Stellt die Oberflaeche dar.
Alle steuerden Taetigkeiten werden (sollten) vom
Controller Objekt uebernommen werden.
'''
def __init__(self):
'''
Constructor
'''
self.root = Tk()
self.root.title("DinnerLog")
self.root.minsize(800, 600)
self.root.grid_columnconfigure(0, weight=1)
self.root.grid_rowconfigure(0, weight=1)
self.root.grid_rowconfigure(1, weight=3)
# Ein Frame für alles, das mit Zutaten zu tun hat
self.fr_zutaten = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Zutaten")
self.fr_zutaten.grid_columnconfigure(0, weight=1)
self.fr_zutaten.grid_rowconfigure(0, weight=1)
self.fr_zutaten.grid(row=0, column=0, sticky="NSWE")
self.lb_zutaten = Listbox(self.fr_zutaten)
sb_zutaten = Scrollbar(self.lb_zutaten, orient=VERTICAL)
self.lb_zutaten.configure(yscrollcommand=sb_zutaten.set)
sb_zutaten.config(command=self.lb_zutaten.yview)
sb_zutaten.pack(side="right", fill="both")
self.lb_zutaten.grid(row=0, column=0, sticky="NSEW")
self._addNeueZutatFrame()
# Ein Frame in den alles, das mit Mahlzeiten zu tun hat, kommt
self.fr_mahlzeit = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Mahlzeiten")
self.fr_mahlzeit.grid_columnconfigure(0, weight=1)
self.fr_mahlzeit.grid_rowconfigure(0, weight=1)
self.fr_mahlzeit.grid(row=1, column=0, sticky="NSWE")
self._addNeueMahlzeitFrame()
self.lb_mahlzeiten = Listbox(self.fr_mahlzeit, selectmode=SINGLE)
sb_mahlzeiten = Scrollbar(self.lb_mahlzeiten, orient=VERTICAL)
sb_mahlzeiten.configure(command=self.lb_mahlzeiten.yview)
self.lb_mahlzeiten.configure(yscrollcommand=sb_mahlzeiten.set)
sb_mahlzeiten.pack(side="right", fill="both")
self.lb_mahlzeiten.grid(row=0, column=0, sticky="NSEW")
fr_neu_ok = Frame(self.fr_mahlzeit)
fr_neu_ok.grid(row=1, column=0, columnspan=2, sticky="E")
self.btn_neu = Button(fr_neu_ok, text="Neu")
self.btn_neu.pack(side="left")
self.btn_mahlzeit_als_zt = Button(fr_neu_ok, text="Als Zutat")
self.btn_mahlzeit_als_zt.pack(anchor=E, side="right")
self.btn_insert = Button(fr_neu_ok, text="Hinzufuegen")
self.btn_insert.pack(anchor=E, side="right")
self.btn_update = Button(fr_neu_ok, text="Update")
self.btn_update.pack(anchor=E, side="right")
self.btn_delete = Button(fr_neu_ok, text="Loeschen")
self.btn_delete.pack(anchor=E, side="right")
# Ein Frame der Statistiken darstellt
self.fr_stats = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Statistik")
self.fr_stats.grid(row=3, column=0, sticky="NSWE")
#self.cv_stats = Canvas(self.fr_stats, height=80, width=600)
#self.cv_stats.create_line(2,5,598,5, fill="#bbb")
def _addNeueMahlzeitFrame(self):
self.fr_neue_mz = Frame(self.fr_mahlzeit)
self.fr_neue_mz.grid_rowconfigure(2, weight=1)
self.fr_neue_mz.grid(row=0, column=1, sticky="WSNE")
lbl_name = Label(self.fr_neue_mz, text="Name:")
lbl_name.grid(row=0, column=0, sticky="NW")
self.en_name = Entry(self.fr_neue_mz)
self.en_name.grid(row=0, column=1, columnspan=2, sticky="WNE")
lbl_zutat = Label(self.fr_neue_mz, text="Zutaten:")
lbl_zutat.grid(row=1, column=0, sticky="NW")
self.lb_zutat = Listbox(self.fr_neue_mz)
sb_zutat = Scrollbar(self.lb_zutat, orient=VERTICAL)
self.lb_zutat.configure(yscrollcommand=sb_zutat.set)
sb_zutat.configure(command=self.lb_zutat.yview)
sb_zutat.pack(side="right", fill="both")
self.lb_zutat.grid(row=2, column=0, columnspan=3, sticky="NWSE")
self.var_zutat = StringVar(self.fr_neue_mz)
#.........这里部分代码省略.........
示例12: Keypad
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_rowconfigure [as 别名]
class Keypad(Frame):
def __init__(self, master, gui, password):
Frame.__init__(self, master, bg='sky blue', width=450, height=550)
self.master.geometry('400x550')
self.master = master
self.master.configure(bg='sky blue')
self.gui = gui
self.password = password
self.frame = Frame(master)
self.frame.pack()
self.frame.configure(bg='sky blue')
index = 0
while index < 5:
self.frame.grid_rowconfigure(index, minsize=50)
index += 1
index = 0
while index < 5:
self.frame.grid_columnconfigure(index, minsize=50)
index += 1
self.box = Entry(self.frame)
self.box.grid(row=0, columnspan=3)
self.box.config(font=('Lucida Console', 78), width=6)
self.list1 = [Button(self.frame, font=('Lucida Console', 30), text='1', command=lambda: self.bob_print(1)),
Button(self.frame, font=('Lucida Console', 30), text='2', command=lambda: self.bob_print(2)),
Button(self.frame, font=('Lucida Console', 30), text='3', command=lambda: self.bob_print(3))
]
index = 0
for each in self.list1:
each.grid(row=1, column=index)
each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
each.config(height=2, width=4)
index += 1
self.list2 = [Button(self.frame, font=('Lucida Console', 30), text='4', command=lambda: self.bob_print(4)),
Button(self.frame, font=('Lucida Console', 30), text='5', command=lambda: self.bob_print(5)),
Button(self.frame, font=('Lucida Console', 30), text='6', command=lambda: self.bob_print(6))
]
index = 0
for each in self.list2:
each.grid(row=2, column=index)
each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
each.config(height=2, width=4)
index += 1
self.list3 = [Button(self.frame, font=('Lucida Console', 30), text='7', command=lambda: self.bob_print(7)),
Button(self.frame, font=('Lucida Console', 30), text='8', command=lambda: self.bob_print(8)),
Button(self.frame, font=('Lucida Console', 30), text='9', command=lambda: self.bob_print(9))
]
index = 0
for each in self.list3:
each.grid(row=3, column=index)
each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
each.config(height=2, width=4)
index += 1
self.list4 = [Button(self.frame, font=('Lucida Console', 30), text='<', command=lambda: self.bob_print('<')),
Button(self.frame, font=('Lucida Console', 30), text='0', command=lambda: self.bob_print(0)),
Button(self.frame, font=('Lucida Console', 30), text='E', command=lambda: self.bob_print('E'))
]
index = 0
for each in self.list4:
each.grid(row=4, column=index)
each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
each.config(height=2, width=4)
index += 1
def bob_print(self, character):
if not (character is '<' or character is 'E'):
self.box.insert("end", character)
elif character is '<':
string = self.box.get()
self.box.delete(0, 'end')
self.box.insert('end', string[:-1])
else:
if self.box.get() == self.password:
self.gui.access_granted()
self.master.destroy()
else:
self.box.delete(0, 'end')