本文整理汇总了Python中tkinter.Checkbutton.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Checkbutton.bind方法的具体用法?Python Checkbutton.bind怎么用?Python Checkbutton.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Checkbutton
的用法示例。
在下文中一共展示了Checkbutton.bind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: from tkinter import Checkbutton [as 别名]
# 或者: from tkinter.Checkbutton import bind [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}),
#.........这里部分代码省略.........