本文整理汇总了Python中tkinter.Button.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Button.bind方法的具体用法?Python Button.bind怎么用?Python Button.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Button
的用法示例。
在下文中一共展示了Button.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playerbox
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
def playerbox(event, player):
togglebutton = event.widget
bleh = Label(self, cursor = 'hand1',
highlightthickness = 0, bd = 0,
image = self.emptylist[togglebutton.slot -1])
self.canvas.create_window((togglebutton.winfo_x() + 86,
togglebutton.winfo_y() + 122),
window = bleh,
tags = ('p{}empty'
.format(togglebutton.slot),
'p{}'
.format(togglebutton.slot)))
namebutton = TkButton(self, text = 'SELECT A NAME',
compound = CENTER,
bd = 0, fg = 'white',
font = ('Arial Black', 8),
highlightthickness = 0,
cursor = 'hand2',
highlightbackground = 'black',
image = self.nameboxpreimage)
namebutton.bind('<Button-1>',
lambda event:
nameselectbox(self, togglebutton,
namebutton, player))
self.canvas.create_window((togglebutton.winfo_x() + 90,
togglebutton.winfo_y() + 185),
window = namebutton,
tags = ('namebutton',
'p{}'
.format(togglebutton.slot)))
togglebutton.lift()
self.canvas.tag_raise('p{}coin'.format(togglebutton.slot))
示例2: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class _Testdialog:
"""Only used to test dialog from CLI"""
def __init__(self, master):
"""Initialize CLI test GUI"""
frame = Frame(master, width=300, height=300)
self.master = master
self.x, self.y, self.w, self.h = -1,-1,-1,-1
self.Button_1 = Button(frame, text="My Popup", relief="raised", width="15")
self.Button_1.pack()
self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)
statframe = Frame(frame)
master.statusMessage = StringVar()
master.statusMessage.set('Welcome')
self.statusbar = Label(statframe, textvariable=master.statusMessage,
bd=1, relief=SUNKEN, anchor=W)
self.statusbar.pack(anchor=SW, fill=X, side=BOTTOM)
statframe.pack(anchor=SW, fill=X, side=BOTTOM)
self.dx = 30
self.dy = 30
frame.pack()
self.dialog = None
# pylint: disable=W0613
def Button_1_Click(self, event): #click method for component ID=1
"""Launch Select_Py_Version for CLI testing."""
self.dialog = SatelliteWindow(self, self.master, "Test Dialog", dx=self.dx, dy=self.dy)
self.dx += 30
self.dy += 30
示例3: LoginGui
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class LoginGui(object):
def __init__(self, root):
self.welcome_text = 'Prihlaseny' if User.is_loaded_session() else ""
self.response_text = StringVar(root, value=self.welcome_text)
self.top_frame = Frame(root, width=400, height=400)
self.middle_frame = Frame(root, width=300, height=300)
self.top_frame.pack(fill="both", expand=True, padx=20, pady=20)
self.middle_frame.place(in_=self.top_frame, anchor='c', relx=.5, rely=.5)
self.l_email = Label(self.middle_frame, text="Email")
self.e_email = Entry(self.middle_frame)
self.l_pass = Label(self.middle_frame, text="Password")
self.e_pass = Entry(self.middle_frame, show="*")
self.l_sign_up = Label(self.middle_frame, text="Sign up", fg='blue', cursor='hand2')
self.l_req_result = Label(self.middle_frame, textvariable=self.response_text)
self.b_submit = Button(self.middle_frame, text="Login")
self.l_email.grid(row=0, sticky=E)
self.e_email.grid(row=0, column=1)
self.l_pass.grid(row=1, column=0, sticky=E)
self.e_pass.grid(row=1, column=1)
self.b_submit.grid(row=2, column=1, sticky=E)
self.l_sign_up.grid(row=3, column=1, sticky=E)
self.l_req_result.grid(row=4)
self.l_sign_up.bind('<Button-1>', self.sing_up_callback)
self.b_submit.bind('<Button-1>', self.login)
self.root = root
self.root.mainloop()
def login(self, event):
response = User.login(self.e_email.get(), self.e_pass.get())
self.response_text.set(response)
if User.is_loaded_session():
self.root.destroy()
@staticmethod
def sing_up_callback(event):
webbrowser.open_new(Config.SIGN_UP_URL)
@staticmethod
def show_login():
root = tkinter.Tk(className="Productivity optimizer")
LoginGui(root)
root.mainloop()
示例4: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class SpeciesListDialog:
def __init__(self, parent):
self.parent = parent
self.gui = Toplevel(parent.guiRoot)
self.gui.grab_set()
self.gui.focus()
self.gui.columnconfigure(0, weight=1)
self.gui.rowconfigure(1, weight=1)
Label(self.gui, text="Registered Species:").grid(row=0, column=0, pady=5, padx=5, sticky="w")
self.listRegisteredSpecies = Listbox(self.gui, width=70)
self.buttonAdd = Button(self.gui, text=" + ")
self.buttonDel = Button(self.gui, text=" - ")
self.listRegisteredSpecies.grid(row=1, column=0, columnspan=3, sticky="nswe", pady=5, padx=5)
self.buttonAdd.grid(row=2, column=1, pady=5, padx=5)
self.buttonDel.grid(row=2, column=2, pady=5, padx=5)
# Set (minimum + max) Window size
self.gui.update()
self.gui.minsize(self.gui.winfo_width(), self.gui.winfo_height())
# self.gui.maxsize(self.gui.winfo_width(), self.gui.winfo_height())
self.actionUpdate(None)
self.gui.bind("<<Update>>", self.actionUpdate)
self.gui.protocol("WM_DELETE_WINDOW", self.actionClose)
self.buttonDel.bind("<ButtonRelease>", self.actionDel)
self.buttonAdd.bind("<ButtonRelease>", self.actionAdd)
self.gui.mainloop()
def actionClose(self):
self.parent.guiRoot.event_generate("<<Update>>", when="tail")
self.gui.destroy()
def actionUpdate(self, event):
self.listRegisteredSpecies.delete(0, "end")
for (taxid, name) in self.parent.optimizer.speciesList:
self.listRegisteredSpecies.insert("end", taxid + ": " + name)
def actionDel(self, event):
try:
selection = self.listRegisteredSpecies.selection_get()
selectionSplit = selection.split(": ")
self.parent.optimizer.speciesList.remove((selectionSplit[0], selectionSplit[1]))
self.gui.event_generate("<<Update>>")
except tkinter.TclError:
# no selection
pass
def actionAdd(self, Event):
SpeciesSearchDialog(self.parent, self)
示例5: TkTimerCore
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class TkTimerCore(TimerCore):
def __init__(self, *args, title, font_size, **kwargs):
def close_handler(event):
self.close()
def clicked_handler(event):
self.interact()
self.master = Tk()
self.master.wm_title(title)
self.master.bind('<Destroy>', close_handler)
self.label = Label(self.master, font='Sans {}'.format(int(font_size)))
self.label.pack(expand=True)
self.control = Toplevel()
self.control.wm_title(title + ' (control)')
self.control.minsize(150, 150)
self.control.bind('<Destroy>', close_handler)
self.button = Button(self.control, text='Start/Pause')
self.button.bind('<ButtonRelease>', clicked_handler)
self.button.pack(expand=True)
self.timeout_running = False
super().__init__(*args, **kwargs)
def start_timeout(self):
assert self.timeout_running is False
def timeout_call():
if self.timeout_running:
self.update()
self.master.after(25, timeout_call)
self.timeout_running = True
timeout_call()
def stop_timeout(self):
assert self.timeout_running is True
self.timeout_running = False
def mainloop(self):
return self.master.mainloop()
def shutdown(self):
self.master.quit()
def set_label_text(self, text, finished=False):
self.label.config(text=text)
if finished:
self.label.config(fg='red')
示例6: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class _Testdialog:
"""Only used to test dialog from CLI"""
def __init__(self, master):
"""Initialize CLI test GUI"""
frame = Frame(master, width=300, height=300)
frame.pack()
self.master = master
self.x, self.y, self.w, self.h = -1, -1, -1, -1
self.Button_1 = Button(text="Test Dialog", relief="raised", width="15")
self.Button_1.place(x=84, y=36)
self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)
def Button_1_Click(self, event): #click method for component ID=1
"""Launch Select_Py_Version for CLI testing."""
rbL = ['2.5.5', '2.6.6', 'PYPY 3.2.2']
dialog = Select_Py_Version(self.master, "Test Dialog", dialogOptions={'rbL':rbL})
print( '===============Result from Dialog====================' )
print( dialog.result)
print( '=====================================================' )
示例7: create_check_buttons
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
def create_check_buttons(self):
self.cb_frame = LabelFrame(self, text="Global Settings")
for cb in CHECK_BUTTONS:
label = cb
target_parent = self.cb_frame
if isinstance(CHECK_BUTTONS[cb], dict) and 'sub_frame' in list(CHECK_BUTTONS[cb].keys()):
target_parent = getattr(self, CHECK_BUTTONS[cb]['sub_frame'])
setattr(self, cb, IntVar(value=type(CHECK_BUTTONS[cb]) == dict and
CHECK_BUTTONS[cb]['val'] or
CHECK_BUTTONS[cb]))
self.this_cb = Checkbutton(target_parent, text=label, variable=getattr(self, cb))
self.this_cb.bind('<Button-1>', self.check_boxes_handler)
self.this_cb.disable = (type(CHECK_BUTTONS[cb]) == dict and
'disable' in list(CHECK_BUTTONS[cb].keys()))
self.this_cb.grid(sticky=W, column=0, row=len(target_parent.winfo_children()))
self.this_cb.ref = cb
for but in GLOBAL_BUTTONS:
label = but
ele = GLOBAL_BUTTONS[but]
this_but = Button(self.cb_frame, text=but)
this_but.bind('<ButtonRelease-1>', getattr(self, ele['handler']))
this_but.ref = but
this_but.grid(sticky=W, column=0, row=len(self.cb_frame.winfo_children()))
self.cb_frame.grid(column=0, row=0, rowspan=10, sticky=N)
示例8: create_voices
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
def create_voices(self):
voice_ids = ['1', '2', '3', '4']
SCALES = OrderedDict([
('pan_pos', {'min': -1, 'max': 1, 'start': 0.5, 'res': 0.001}),
('volume', {'min': 0, 'max': 1, 'start': 0.666, 'res': 0.001}),
('slide_duration_msecs', {'min': 0, 'max': 2000, 'start': 60, 'res': 1}),
('slide_duration_prop', {'min': 0, 'max': 2, 'start': 0.666, 'res': 0.001}),
('binaural_diff', {'min': 0, 'max': 66, 'start': 0.2, 'res': 0.01})
])
for vid in voice_ids:
counter = 0
for sca in SCALES:
name = 'voice_' + vid + '_' + sca
setattr(self, 'min_' + name, SCALES[sca]['min'])
setattr(self, 'max_' + name, SCALES[sca]['max'])
this_sca = Scale(self, label=sca, orient=HORIZONTAL,
from_=getattr(self, 'min_' + name),
to=getattr(self, 'max_' + name),
resolution=SCALES[sca]['res'])
this_sca.enable = ('enable' in list(SCALES[sca].keys()) and
SCALES[sca]['enable'] or None)
this_sca.disable = ('disable' in list(SCALES[sca].keys()) and
SCALES[sca]['disable'] or None)
this_sca.grid(column=int(2 + int(vid)), row=counter, sticky=E + W)
this_sca.bind("<ButtonRelease>", self.scale_handler)
this_sca.ref = name
counter += 1
CHECK_BUTTONS = OrderedDict(
[('mute', False),
('automate_binaural_diffs', True),
('automate_note_duration_prop', True),
('use_proportional_slide_duration', {'val': True, 'label': 'proportional slide'}),
('automate_pan', True),
('automate_wavetables', True)])
for vid in voice_ids:
counter = 0
cb_frame = LabelFrame(self, text="Voice {0} - Automation".format(vid))
setattr(self, 'voice_' + vid + '_cb_frame', cb_frame)
for cb in CHECK_BUTTONS:
options = CHECK_BUTTONS[cb]
name = 'voice_' + vid + '_' + cb
if isinstance(options, dict) and 'label' in list(options.keys()):
label = options['label']
else:
label = cb[9:] if cb[:9] == 'automate_' else cb
setattr(self, name, IntVar(
value=type(options) == dict and options['val'] or options))
self.this_cb = Checkbutton(cb_frame, text=label, variable=getattr(self, name))
self.this_cb.bind('<Button-1>', self.check_boxes_handler)
self.this_cb.disable = None
self.this_cb.grid(sticky=W, column=0, row=counter)
self.this_cb.ref = name
counter += 1
# add trigger wavetable-button
trigWavetableButton = Button(cb_frame, text='Next Wavetable')
trigWavetableButton.bind('<Button-1>', self.trigger_waveform_handler)
trigWavetableButton.ref = 'voice_' + vid + "_trigger_wavetable"
trigWavetableButton.grid(row=counter)
cb_frame.grid(column=int(vid) + 2, row=5, sticky=E + W + N, rowspan=8)
for vid in voice_ids:
generation_types = ["random", "random_harmonic", "harmonic"]
partial_pools = ["even", "odd", "all"]
prefix = 'voice_' + vid + '_'
types_name = prefix + 'wavetable_generation_type'
pools_name = prefix + 'partial_pool'
setattr(self, types_name, StringVar())
getattr(self, types_name).set("random")
setattr(self, pools_name, StringVar())
getattr(self, pools_name).set("all")
target_frame = getattr(self, 'voice_' + vid + '_cb_frame')
gen_typ_frame = LabelFrame(target_frame, text="type")
gen_typ_frame.grid(row=len(target_frame.winfo_children()), sticky=W)
for gen_t in generation_types:
gen_t_entry = Radiobutton(gen_typ_frame, value=gen_t, text=gen_t, anchor=W,
variable=getattr(self, types_name))
gen_t_entry.bind('<ButtonRelease-1>', self.wt_handler)
gen_t_entry.ref = types_name
gen_t_entry.grid(row=len(gen_typ_frame.winfo_children()), sticky=W)
pp_frame = LabelFrame(target_frame, text="harmonics")
for pp in partial_pools:
pp_entry = Radiobutton(pp_frame, value=pp, text=pp, anchor=W,
variable=getattr(self, pools_name))
pp_entry.bind('<ButtonRelease-1>', self.wt_handler)
pp_entry.ref = pools_name
pp_entry.grid(row=len(pp_frame.winfo_children()), sticky=E + W)
this_num_partials = Scale(pp_frame, label='number of harmonics', orient=HORIZONTAL,
from_=1, to=24, resolution=1)
this_num_partials.ref = prefix + 'num_partials'
this_num_partials.grid(column=0, row=len(pp_frame.winfo_children()), sticky=E + W)
this_num_partials.bind("<ButtonRelease>", self.scale_handler)
pp_frame.grid(row=len(target_frame.winfo_children()), sticky=E + W)
示例9: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class BaseExFrame:
def __init__(self, master, current_unit, needs_span):
self.master = master
self.frame = create_content_frame(self.master)
self.current_unit = current_unit
self.needs_span = needs_span
self.heading_column_span = 1
self.heading_options = {'background': SEA_GREEN, 'font': ("Helvetica", 20), 'fg': "cyan"}
self.entries = []
self.prev_button = None
self.next_button = None
def show(self):
self.heading_options['text'] = self.current_unit.name
heading = Label(master=self.frame, cnf=self.heading_options)
heading.grid(row=0, sticky=(N, S, E, W), columnspan=self.heading_column_span)
pictures = create_images(self.frame, self._images_path())
show_pictures(pictures, self.needs_span)
self.entries = self._load_entries()
self.prev_button = Button(self.frame, text="Назад")
self._config_prev_button()
self.prev_button.grid(row=3, column=0, sticky=(W, S))
self.next_button = Button(self.frame, text="Продължи", state="disabled")
self._config_next_button()
self._grid_next_button()
self.frame.grid(row=0, column=0)
def hide(self):
self.frame.grid_forget()
def grid(self, row, column):
self.frame.grid(row=row, column=column)
def _images_path(self):
pass
def _load_entries(self):
pass
def _callback(self):
pass
def _config_prev_button(self):
self.prev_button['width'] = 10
def bind_prev_button(self, command):
self.prev_button.bind("<Button-1>", command)
def _config_next_button(self):
self.next_button['width'] = 10
def _grid_next_button(self):
self.next_button.grid(row=3, column=self.heading_column_span - 1, sticky=(E, S))
def bind_next_button(self, command):
self.next_button.bind("<Button-1>", command)
示例10: SatelliteWindow
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class SatelliteWindow( Toplevel ):
"""
SatelliteWindow is used to display nosetests results of concurrently run
python interpreters.
"""
def cleanupOnQuit(self):
"""When closing popup, do a little clean up."""
# I'm not sure that transient windows need this, but I'm trying to be careful
self.MainWin.focus_set()
if self.main_gui.kill_popup_window( self.statusMessage.get() ):
self.destroy()
self.main_gui.statusMessage.set('Closed: ' + self.statusMessage.get())
else:
self.main_gui.statusMessage.set('ERROR Closing: ' + self.statusMessage.get())
self.main_gui.set_statusbar_bg( '#FF9999' )
def __init__(self, main_gui, MainWin, mytitle, dx=30, dy=30):
"""Initialize popup"""
Toplevel.__init__(self, MainWin)
self.title(mytitle)
x = MainWin.winfo_x()
if x<10:
x=10
y = MainWin.winfo_y()
if y<10:
y=10
# position over to the upper right
self.geometry( '+%i+%i'%(x+dx,y+dy))
self.config( highlightcolor='#FF99FF', highlightbackground='#FF99FF',
highlightthickness=2, borderwidth=10 )
#===========
# make a Status Bar
self.statusMessage = StringVar()
self.statusMessage.set(mytitle)
self.statusbar = Label(self, textvariable=self.statusMessage, bd=1, relief=SUNKEN)
self.statusbar.pack(anchor=SW, fill=X, side=BOTTOM)
self.statusbar_bg = self.statusbar.cget('bg') # save bg for restore
myFont = tkinter.font.Font(family="Arial", size=12, weight=tkinter.font.BOLD)
self.statusbar.config( font=myFont )
frame = Frame(self)
frame.pack(anchor=NE, fill=BOTH, side=TOP)
self.Pass_Fail_Button = Button(frame,text="Pass/Fail Will Be Shown Here",
image="", width="15", background="green",
anchor=W, justify=LEFT, padx=2)
self.Pass_Fail_Button.pack(anchor=NE, fill=X, side=TOP)
self.Pass_Fail_Button.bind("<ButtonRelease-1>", self.Pass_Fail_Button_Click)
#self.title('%s %s.%s.%s '%(python_exe_name, python_major, python_minor, python_micro))
self.oscillator = 1 # animates character on title
self.oscillator_B = 0 # used to return statusbar to statusbar_bg
self.lbframe = Frame( frame )
self.lbframe.pack(anchor=SE, side=LEFT, fill=BOTH, expand=1)
scrollbar = Scrollbar(self.lbframe, orient=VERTICAL)
self.Text_1 = Text(self.lbframe, width="80", height="24", yscrollcommand=scrollbar.set)
scrollbar.config(command=self.Text_1.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.Text_1.pack(side=LEFT, fill=BOTH, expand=1)
self.resizable(1,1) # Linux may not respect this
#===========
self.MainWin = MainWin
self.main_gui = main_gui
# only main window can close this window
self.protocol('WM_DELETE_WINDOW', self.cleanupOnQuit)
def Pass_Fail_Button_Click(self, event):
"""Place-holder routine for user clicking Pass/Fail Button"""
self.main_gui.Pass_Fail_Button_Click( event )
def reset_statusbar_bg(self):
"""Return status bar to default state"""
self.statusbar.config(bg=self.statusbar_bg)
def set_statusbar_bg(self, c):
"""Set status bar to show new color and message"""
self.statusbar.config(bg=c)
self.oscillator_B = 1 # will return to initial color after a few cycles
示例11: __init__
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
def __init__(self, master, cluster_fname=None, fig_cols = 4, fig_rows = None):
if not cluster_fname:
cluster_fname = tkinter.filedialog.askopenfilename(parent=master,
title="List of genes",
initialdir=path.abspath('./'))
print(cluster_fname)
master.wm_title(cluster_fname)
self.all_in_cluster = [line.strip() for line in open(cluster_fname)]
print("No images", [item for item in self.all_in_cluster
if item not in has_img])
self.imgs_in_cluster = [item for item in self.all_in_cluster
if item in has_img]
print(self.imgs_in_cluster)
print(len(self.imgs_in_cluster), len(self.all_in_cluster), end=' ')
print(len(self.imgs_in_cluster) / float(len(self.all_in_cluster)))
self.img_lists = [[x for x in
st_5_with_lat[(st_5_with_lat['Name2'] == gene)
+(st_5_with_lat['FBgn'] == gene)]['imgfile']]
for gene in self.imgs_in_cluster]
num_genes = len(self.imgs_in_cluster)
self.fig_rows, self.fig_cols = adjust_rows_cols(num_genes,
fig_rows or 0, fig_cols or 0)
self.outfn = path.basename(cluster_fname)[:-4]+'.png'
buttons = Frame(master)
buttons.grid(row=1, column=1)
savebutton = Button(buttons, text="Save", command=self.save)
savebutton.grid(row=2, column = 2)
Button(buttons, text="Add Row", command=self.add_row).grid(row=1,column=3)
Button(buttons, text="Add Col", command=self.add_col).grid(row=3,column=3)
Button(buttons, text="Remove Row",
command=self.remove_row).grid(row=1,column=1)
Button(buttons, text="Remove Col",
command=self.remove_col).grid(row=3,column=1)
images = Frame(master)
images.grid(row=2, column=1)
self.button_selected = IntVar(master, -1)
self.images_selected = [0 for list in self.img_lists]
out_name = '{}.png.txt'.format(path.splitext(path.basename(cluster_fname))[0])
print(out_name)
if path.exists(out_name):
for i, line in enumerate(open(out_name)):
self.images_selected[i] = int(line.split()[0].strip())
self.radio_buttons = []
self.image_files = []
self.x_flipped = []
for i, gene in enumerate(self.imgs_in_cluster):
for image_file_name in self.img_lists[i]:
try:
raise IOError
image_file = imget(image_file_name)
import_image = Image.open(image_file)
except (IOError, OSError):
try:
image_file = imget_bdgp(image_file_name)
import_image = Image.open(image_file)
except Exception as exc:
print(exc)
print(image_file_name, gene)
raise exc
import_image = import_image.resize((180,80), Image.ANTIALIAS)
except urllib.error.HTTPError as exc:
print(image_file_name, gene)
raise exc
embryo_image = ImageTk.PhotoImage(import_image)
label = Label(image=embryo_image)
label.image = embryo_image
b = Button(images,
image = label.image,
width = 200,
height= 100,
text=gene,
#text = image_file,
#variable=self.button_selected,
#command=self.handle_button_click,
#value = i+1,
#indicatoron=0,
)
#ToolTip(b, gene)
b.bind("<Button-1>", self.handle_button_click)
b.bind("<Button-2>", self.handle_button_click)
b.grid(row = i // self.fig_cols, column = i % self.fig_cols)
#w = Tix.Balloon(master, message=gene)
#w.bind_widget(b)
self.image_files.append(image_file)
self.radio_buttons.append(b)
self.x_flipped.append(False)
示例12: titlescreen
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
def titlescreen(self):
'''
Main menu screen.
Options:
-display records
-begin stat recording:
-stat analysis
-whatever
-quit
'''
def button_highlight(event):
event.widget.config(foreground = '#040D24',
background = '#FFCB00')
def button_dehighlight(event):
event.widget.config(foreground = '#C89632',
background = '#040D24')
try: self.canvas.delete('all')
except: pass
self.titleimage = PhotoImage(file = 'titleimage.png')
self.canvas.create_image((400, 300),
image = self.titleimage)
RecordingButton = TkButton(master = self,
text = 'Start Recording', cursor = 'hand1',
font = ('Helectiva', 20, 'bold'),
fg = '#C89632', bg = '#040D24', bd = 1,
command = self.playerselect)
StatDisplayButton = TkButton(master = self,
text = 'Stat Display', cursor = 'hand1',
font = ('Helectiva', 20, 'bold'),
fg = '#C89632', bg = '#040D24', bd = 1,
command = self.statdisplay)
AnalysisButton = TkButton(master = self,
text = 'Stat Analysis', cursor = 'hand1',
font = ('Helectiva', 20, 'bold'),
fg = '#C89632', bg = '#040D24', bd = 1,
command = self.statanalysis)
RecordingButton.bind('<Enter>', button_highlight)
StatDisplayButton.bind('<Enter>', button_highlight)
AnalysisButton.bind('<Enter>', button_highlight)
RecordingButton.bind('<Leave>', button_dehighlight)
StatDisplayButton.bind('<Leave>', button_dehighlight)
AnalysisButton.bind('<Leave>', button_dehighlight)
self.canvas.create_window((322,186), window = RecordingButton,
width = 323, height = 40)
self.canvas.create_window((255,245), window = StatDisplayButton,
width = 320, height = 40)
self.canvas.create_window((204,308), window = AnalysisButton,
width = 320, height = 41)
示例13: rmap
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
#.........这里部分代码省略.........
#-------------------
r.sleep = 0
r.demoAll()
#-------------------
"""
global r
r = self
for x in r.m:
r.lm(x)
print(x)
r.demo()
r.pause()
def __init__(self):
self._w = 4 # толщина стен
self._d = 4 # на столько меньше клетки закраска (с каждой стороны)
self.sleep = 0.5 # замедление
self._font_size = self._size // 2
self._tk = Tk()
self._tk.geometry('+0+0')
x = (self._tk.winfo_screenwidth() - self._tk.winfo_reqwidth()) / 3
y = (self._tk.winfo_screenheight() - self._tk.winfo_reqheight()) / 4
self._tk.wm_geometry("+%d+%d" % (x, y))
self._tk.title('Robot-hobot')
self._canvas = Canvas(self._tk, width=(self._size*(self._nc+1)), height=(self._size*(self._nr+1)), bg="gray")
buttons = Frame(self._tk)
self.task = Label (self._tk, justify = 'left')
self.res = Label (self._tk, justify = 'left')
self._but_start = Button(buttons,text = 'start',width=10,height=1)
self._but_start.bind('<ButtonRelease-1>',self.but1)
self._but_demo = Button(buttons,text = 'demo',width=10,height=1)
self._but_demo.bind('<ButtonRelease-1>',self.but_demo)
self._but_reload = Button(buttons,text = 'reload',width=10,height=1)
self._but_reload.bind('<ButtonRelease-1>',self.but_reload)
self._but_load_next = Button(buttons,text = 'load next',width=10,height=1)
self._but_load_next.bind('<ButtonRelease-1>',self.but_load_next)
buttons.grid(row=0, column=0, sticky = "w")
self._canvas.grid(row=1, column=0, sticky = "e")
self._but_start.pack(side = "left")
self._but_demo.pack(side = "left")
self._but_reload.pack(side = "left")
self._but_load_next.pack(side = "left")
self.task.grid(row=3, column=0, sticky = "w")
self.res.grid(row=4, column=0, sticky = "w")
## self.loadmap()
def but_load_next(self,event):
print ("load next")
index = self.m.index(self._cur_map)
if index < len(self.m)-1:
self.lm(self.m[index+1])
else:
self.lm(self.m[0])
def but_demo(self,event):
print ("demo")
self.demo()
示例14: loop
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
nboard[x][y] = 0;
else:
nboard[x][y] = board[x][y]
board, nboard = nboard, board;
def loop(*args):
if state:
makeTurn();
redraw();
canvas.after(10, func=loop);
def switchState(event):
global state;
state = not state;
if state:
event.widget.configure(text = "Stop");
loop();
else:
event.widget.configure(text = "Start");
def save(*args):
plistlib.writePlist(board, "sav.plist");
def load(*args):
global board;
board = plistlib.readPlist("sav.plist");
redraw();
canvas.bind("<Button-1>",diviveIntervention);
startButton.bind("<Button-1>",switchState);
loadButton.bind("<Button-1>",load);
saveButton.bind("<Button-1>",save);
canvas.mainloop();
示例15: Tk_Nosy
# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import bind [as 别名]
class Tk_Nosy(object):
"""This class is the tkinter GUI object"""
# make a collection of python interpreters to choose from
pythonInterpreterCollection = None # will be PyInterpsOnSys object
# extra python interpreters can run nosetests concurrently to main window
# concurrent_versionL contains tuples = (PI, Popup)
concurrent_versionL = [] # additional running python interpreters
def __init__(self, master):
self.dirname = os.path.abspath( os.curdir )
self.initComplete = 0
self.master = master
self.x, self.y, self.w, self.h = -1,-1,-1,-1
# bind master to <Configure> in order to handle any resizing, etc.
# postpone self.master.bind("<Configure>", self.Master_Configure)
self.master.bind('<Enter>', self.bindConfigure)
self.menuBar = Menu(master, relief = "raised", bd=2)
self.menuBar.add("command", label = "Change_Dir", command = self.menu_Directory_Change_Dir)
disp_Choices = Menu(self.menuBar, tearoff=0)
self.display_test_details = StringVar()
self.display_test_details.set('N')
disp_Choices.add_checkbutton(label='Display Test Details', variable=self.display_test_details, onvalue='Y', offvalue='N')
self.display_watched_files = StringVar()
self.display_watched_files.set('N')
disp_Choices.add_checkbutton(label='Show Watched Files', variable=self.display_watched_files, onvalue='Y', offvalue='N')
self.menuBar.add("cascade", label="Display", menu=disp_Choices)
py_choices = Menu(self.menuBar, tearoff=0)
py_choices.add("command", label = "Change Python Version",
command = self.changePythonVersion)
py_choices.add("command", label = "Find New Python Interpreter",
command = self.findNewPythonInterpreter)
py_choices.add("command", label = "Launch Another Python Interpreter",
command = self.launchAnotherPythonInterpreter)
self.menuBar.add("cascade", label="Python", menu=py_choices)
#top_Snippet = Menu(self.menuBar, tearoff=0)
self.menuBar.add("command", label = "Run", command = self.menu_Run)
self.display_test_details.trace("w", self.rerun_tests)
self.display_watched_files.trace("w", self.rerun_tests)
master.config(menu=self.menuBar)
# make a Status Bar
self.statusMessage = StringVar()
self.statusMessage.set(self.dirname)
self.statusbar = Label(self.master, textvariable=self.statusMessage,
bd=1, relief=SUNKEN)
self.statusbar.pack(anchor=SW, fill=X, side=BOTTOM)
self.statusbar_bg = self.statusbar.cget('bg') # save bg for restore
self.arial_12_bold_font = tkinter.font.Font(family="Arial", size=12,
weight=tkinter.font.BOLD)
self.arial_12_font = tkinter.font.Font(family="Arial", size=12)
self.statusbar.config( font=self.arial_12_bold_font )
frame = Frame(master)
frame.pack(anchor=NE, fill=BOTH, side=TOP)
self.Pass_Fail_Button = Button(frame,text="Pass/Fail Will Be Shown Here",
image="", width="15", background="green",
anchor=W, justify=LEFT, padx=2)
self.Pass_Fail_Button.pack(anchor=NE, fill=X, side=TOP)
self.Pass_Fail_Button.bind("<ButtonRelease-1>", self.Pass_Fail_Button_Click)
self.master.title("tk_nosy")
self.oscillator = 1 # animates character on title
self.oscillator_B = 0 # used to return statusbar to statusbar_bg
self.lbframe = Frame( frame )
self.lbframe.pack(anchor=SE, side=LEFT, fill=BOTH, expand=1)
scrollbar = Scrollbar(self.lbframe, orient=VERTICAL)
self.Text_1 = Text(self.lbframe, width="80", height="24",
yscrollcommand=scrollbar.set)
scrollbar.config(command=self.Text_1.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.Text_1.pack(side=LEFT, fill=BOTH, expand=1)
self.master.resizable(1,1) # Linux may not respect this
self.numNosyCalls = 0
self.need_to_pick_dir = 1
#.........这里部分代码省略.........