本文整理汇总了Python中tkinter.Frame.winfo_children方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.winfo_children方法的具体用法?Python Frame.winfo_children怎么用?Python Frame.winfo_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.winfo_children方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import winfo_children [as 别名]
class Widget_:
def __init__(self, parent_frame, row, column, width=50, height=50):
self.widget_frame = Frame(parent_frame, width=width, height=height)
self.widget_frame.grid(row=row, column=column)
self.width, self.height = width, height
return
def add_tag(self, tag_library, string):
tag_library[string] = self
def delete_widget(self):
for child in self.widget_frame.winfo_children():
child.destroy()
self.widget_frame.destroy()
def hide_widget(self):
self.widget_frame.grid_forget()
def get_info(self):
return
def set_field(self):
return
pass
示例2: InstanceEditor
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import winfo_children [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):
#.........这里部分代码省略.........
示例3: LucteriosMainForm
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import winfo_children [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'))
def do_progress(self, progressing):
if not progressing:
self.progress.stop()
self.progress.grid_remove()
else:
self.progress.start(25)
self.progress.grid(row=1, column=0, sticky=(E, W))
def enabled(self, is_enabled, widget=None):
if widget is None:
widget = self
self.do_progress(not is_enabled)
if is_enabled:
widget.config(cursor="")
else:
widget.config(cursor="watch")
if isinstance(widget, Button) and (widget != self.btnupgrade):
if is_enabled and (not hasattr(widget, 'disabled') or not widget.disabled):
widget.config(state=NORMAL)
else:
widget.config(state=DISABLED)
else:
for child_cmp in widget.winfo_children():
self.enabled(is_enabled, child_cmp)
@ThreadRun
def refresh(self, instance_name=None):
if instance_name is None:
instance_name = self.get_selected_instance_name()
self.instance_txt.delete("1.0", END)
self._refresh_instance_list()
self.set_select_instance_name(instance_name)
if not self.has_checked:
self._refresh_modules()
if self.instance_list.size() == 0:
sleep(.3)
self._refresh_modules()
sleep(.3)
self.after_idle(self.add_inst)
def _refresh_modules(self):
self.btnupgrade.config(state=DISABLED)
self.module_txt.config(state=NORMAL)
self.module_txt.delete("1.0", END)
lct_glob = LucteriosGlobal()
mod_lucterios, mod_applis, mod_modules = lct_glob.installed()
self.module_txt.insert(
END, ugettext("Lucterios core\t\t%s\n") % mod_lucterios[1])
self.module_txt.insert(END, '\n')
self.module_txt.insert(END, ugettext("Application\n"))
for appli_item in mod_applis:
self.module_txt.insert(
END, "\t%s\t%s\n" % (appli_item[0].ljust(30), appli_item[1]))
self.module_txt.insert(END, ugettext("Modules\n"))
for module_item in mod_modules:
示例4: Application
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import winfo_children [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.send_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind((host, port))
self.grid()
self.columnconfigure(0, minsize=100)
self.columnconfigure(1, minsize=200)
self.columnconfigure(2, minsize=200)
self.columnconfigure(3, minsize=150)
self.columnconfigure(4, minsize=150)
self.columnconfigure(5, minsize=150)
self.columnconfigure(6, minsize=150)
self.create_widgets()
self.settables = self.assemble_settables()
self.gui_logger = logging.getLogger('gui')
self.request_update()
def create_widgets(self):
self.create_monitor()
self.create_check_buttons()
self.create_ranges()
self.create_scales()
self.create_radio_buttons()
self.create_voices()
self.quitButton = Button(self, text='Quit', command=self.quit)
self.quitButton.grid(columnspan=7, sticky=E + W)
def assemble_settables(self):
settables = self.winfo_children()
for w in settables:
settables += w.winfo_children()
return [w for w in settables if w.__class__.__name__ in ['Scale', 'Checkbutton']]
def create_radio_buttons(self):
# Scale related
entries = ['DIATONIC', 'HARMONIC', 'MELODIC', 'PENTATONIC', 'PENTA_MINOR',
'GREEK_CHROMATIC', 'GREEK_ENHARMONIC']
self.scale = StringVar()
self.scale.set('DIATONIC')
self.rb_frame = Frame(self)
for e in entries:
rb = Radiobutton(self.rb_frame, value=e, text=e, anchor=W,
command=self.send_scale, variable=self.scale)
rb.grid(row=len(self.rb_frame.winfo_children()), sticky=W)
self.rb_frame.grid(column=1, row=len(self.grid_slaves(column=1)), rowspan=3)
def create_monitor(self):
self.monitor_frame = LabelFrame(self, text="Monitor and Transport")
this_cycle = Scale(self.monitor_frame, label='cycle_pos', orient=HORIZONTAL,
from_=1, to=16, resolution=1)
this_cycle.disable, this_cycle.enable = (None, None)
this_cycle.ref = 'cycle_pos'
this_cycle.grid(column=0, row=0, sticky=E + W)
self.updateButton = Button(self.monitor_frame,
text='Reload all Settings',
command=self.request_update)
self.updateButton.grid(row=1, sticky=E + W)
self.ForceCaesuraButton = Button(self.monitor_frame,
text='Force Caesura',
command=self.force_caesura)
self.ForceCaesuraButton.grid(row=2, sticky=E + W)
self.saveBehaviourButton = Button(self.monitor_frame,
text='Save current behaviour',
command=self.request_saving_behaviour)
self.saveBehaviourButton.grid(row=3, sticky=E + W)
self.saveBehaviourNameEntry = Entry(self.monitor_frame)
self.saveBehaviourNameEntry.grid(row=4, sticky=E + W)
self.saveBehaviourNameEntry.bind('<KeyRelease>', self.request_saving_behaviour)
self.selected_behaviour = StringVar()
self.selected_behaviour.trace('w', self.new_behaviour_chosen)
self.savedBehavioursMenu = OptionMenu(self.monitor_frame,
self.selected_behaviour, None,)
self.savedBehavioursMenu.grid(row=5, sticky=E + W)
self.monitor_frame.grid(column=0, row=10, sticky=E + W)
def request_update(self):
self.send({'sys': 'update'})
def request_saving_behaviour(self, event=None):
"""callback for save behaviour button and textentry"""
if event and event.widget == self.saveBehaviourNameEntry:
if event.keysym == 'Return':
name = self.saveBehaviourNameEntry.get()
self.saveBehaviourNameEntry.delete(0, len(name))
else:
return
else: # button was pressed
name = self.saveBehaviourNameEntry.get()
if name:
self.send({'sys': ['save_behaviour', name]})
def force_caesura(self):
self.send({'force_caesura': True})
def create_voices(self):
voice_ids = ['1', '2', '3', '4']
SCALES = OrderedDict([
('pan_pos', {'min': -1, 'max': 1, 'start': 0.5, 'res': 0.001}),
#.........这里部分代码省略.........