本文整理汇总了Python中tkinter.Frame.grid_columnconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_columnconfigure方法的具体用法?Python Frame.grid_columnconfigure怎么用?Python Frame.grid_columnconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid_columnconfigure方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_instance_panel
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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'))
示例2: home_page
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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
示例3: create_module_panel
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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_columnconfigure [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_columnconfigure [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_columnconfigure [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: LucteriosMainForm
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [as 别名]
class LucteriosMainForm(Tk):
def __init__(self):
Tk.__init__(self)
try:
img = Image("photo", file=join(
dirname(import_module('lucterios.install').__file__), "lucterios.png"))
self.tk.call('wm', 'iconphoto', self._w, img)
except:
pass
self.has_checked = False
self.title(ugettext("Lucterios installer"))
self.minsize(475, 260)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.running_instance = {}
self.resizable(True, True)
self.protocol("WM_DELETE_WINDOW", self.on_closing)
self.ntbk = ttk.Notebook(self)
self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))
self.create_instance_panel()
self.create_module_panel()
stl = ttk.Style()
stl.theme_use("default")
stl.configure("TProgressbar", thickness=5)
self.progress = ttk.Progressbar(
self, style="TProgressbar", orient='horizontal', mode='indeterminate')
self.progress.grid(row=1, column=0, sticky=(E, W))
self.btnframe = Frame(self, bd=1)
self.btnframe.grid(row=2, column=0, columnspan=1)
Button(self.btnframe, text=ugettext("Refresh"), width=20, command=self.refresh).grid(
row=0, column=0, padx=3, pady=3, sticky=(N, S))
self.btnupgrade = Button(
self.btnframe, text=ugettext("Search upgrade"), width=20, command=self.upgrade)
self.btnupgrade.config(state=DISABLED)
self.btnupgrade.grid(row=0, column=1, padx=3, pady=3, sticky=(N, S))
Button(self.btnframe, text=ugettext("Close"), width=20, command=self.on_closing).grid(
row=0, column=2, padx=3, pady=3, sticky=(N, S))
def on_closing(self):
all_stop = True
instance_names = list(self.running_instance.keys())
for old_item in instance_names:
if (self.running_instance[old_item] is not None) and self.running_instance[old_item].is_running():
all_stop = False
if all_stop or askokcancel(None, ugettext("An instance is always running.\nDo you want to close?")):
self.destroy()
else:
self.refresh()
def destroy(self):
instance_names = list(self.running_instance.keys())
for old_item in instance_names:
if self.running_instance[old_item] is not None:
self.running_instance[old_item].stop()
del self.running_instance[old_item]
Tk.destroy(self)
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'))
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)
#.........这里部分代码省略.........
示例8: InstanceEditor
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [as 别名]
class InstanceEditor(Toplevel):
def __init__(self):
Toplevel.__init__(self)
self.focus_set()
self.grab_set()
self.result = None
self.module_data = None
self.mod_applis = None
self.title(ugettext("Instance editor"))
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.ntbk = ttk.Notebook(self)
self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))
self.frm_general = Frame(self.ntbk, width=350, height=150)
self.frm_general.grid_columnconfigure(0, weight=0)
self.frm_general.grid_columnconfigure(1, weight=1)
self._general_tabs()
self.ntbk.add(self.frm_general, text=ugettext('General'))
self.frm_database = Frame(self.ntbk, width=350, height=150)
self.frm_database.grid_columnconfigure(0, weight=0)
self.frm_database.grid_columnconfigure(1, weight=1)
self._database_tabs()
self.ntbk.add(self.frm_database, text=ugettext('Database'))
btnframe = Frame(self, bd=1)
btnframe.grid(row=1, column=0, columnspan=1)
Button(btnframe, text=ugettext("OK"), width=10, command=self.apply).grid(
row=0, column=0, sticky=(N, S, E))
Button(btnframe, text=ugettext("Cancel"), width=10, command=self.destroy).grid(
row=0, column=1, sticky=(N, S, W))
def _database_tabs(self):
Label(self.frm_database, text=ugettext("Type")).grid(
row=0, column=0, sticky=(N, W), padx=5, pady=3)
self.typedb = ttk.Combobox(
self.frm_database, textvariable=StringVar(), state=READLONY)
self.typedb.bind("<<ComboboxSelected>>", self.typedb_selection)
self.typedb.grid(row=0, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_database, text=ugettext("Name")).grid(
row=1, column=0, sticky=(N, W), padx=5, pady=3)
self.namedb = Entry(self.frm_database)
self.namedb.grid(row=1, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_database, text=ugettext("User")).grid(
row=2, column=0, sticky=(N, W), padx=5, pady=3)
self.userdb = Entry(self.frm_database)
self.userdb.grid(row=2, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_database, text=ugettext("Password")).grid(
row=3, column=0, sticky=(N, W), padx=5, pady=3)
self.pwddb = Entry(self.frm_database)
self.pwddb.grid(row=3, column=1, sticky=(N, S, E, W), padx=5, pady=3)
def _general_tabs(self):
Label(self.frm_general, text=ugettext("Name")).grid(
row=0, column=0, sticky=(N, W), padx=5, pady=3)
self.name = Entry(self.frm_general)
self.name.grid(row=0, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_general, text=ugettext("Appli")).grid(
row=1, column=0, sticky=(N, W), padx=5, pady=3)
self.applis = ttk.Combobox(
self.frm_general, textvariable=StringVar(), state=READLONY)
self.applis.bind("<<ComboboxSelected>>", self.appli_selection)
self.applis.grid(row=1, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_general, text=ugettext("Modules")).grid(
row=2, column=0, sticky=(N, W), padx=5, pady=3)
self.modules = Listbox(self.frm_general, selectmode=EXTENDED)
self.modules.configure(exportselection=False)
self.modules.grid(row=2, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_general, text=ugettext("Language")).grid(
row=3, column=0, sticky=(N, W), padx=5, pady=3)
self.language = ttk.Combobox(
self.frm_general, textvariable=StringVar(), state=READLONY)
self.language.grid(
row=3, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_general, text=ugettext("CORE-connectmode")
).grid(row=4, column=0, sticky=(N, W), padx=5, pady=3)
self.mode = ttk.Combobox(
self.frm_general, textvariable=StringVar(), state=READLONY)
self.mode.bind("<<ComboboxSelected>>", self.mode_selection)
self.mode.grid(row=4, column=1, sticky=(N, S, E, W), padx=5, pady=3)
Label(self.frm_general, text=ugettext("Password")).grid(
row=5, column=0, sticky=(N, W), padx=5, pady=3)
self.password = Entry(self.frm_general, show="*")
self.password.grid(
row=5, column=1, sticky=(N, S, E, W), padx=5, pady=3)
def typedb_selection(self, event):
visible = list(self.typedb[VALUES]).index(self.typedb.get()) != 0
for child_cmp in self.frm_database.winfo_children()[2:]:
if visible:
child_cmp.config(state=NORMAL)
else:
child_cmp.config(state=DISABLED)
def appli_selection(self, event):
#.........这里部分代码省略.........
示例9: Tk
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [as 别名]
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]))
示例10: Preferences
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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=''),
#.........这里部分代码省略.........
示例11: MiniSedGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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")
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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
#.........这里部分代码省略.........
示例13: Keypad
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_columnconfigure [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')