本文整理汇总了Python中Tkinter.BOTTOM属性的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.BOTTOM属性的具体用法?Python Tkinter.BOTTOM怎么用?Python Tkinter.BOTTOM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.BOTTOM属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_toolbar
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def _init_toolbar(self):
xmin, xmax = self.canvas.figure.bbox.intervalx
height, width = 50, xmax-xmin
Tk.Frame.__init__(self, master=self.window,
width=int(width), height=int(height),
borderwidth=2)
self.update() # Make axes menu
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
# spacer, unhandled in Tk
pass
else:
button = self._Button(text=text, file=image_file,
command=getattr(self, callback))
if tooltip_text is not None:
ToolTip.createToolTip(button, tooltip_text)
self.message = Tk.StringVar(master=self)
self._message_label = Tk.Label(master=self, textvariable=self.message)
self._message_label.pack(side=Tk.RIGHT)
self.pack(side=Tk.BOTTOM, fill=Tk.X)
示例2: plot
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def plot(self):
if len(self.channels) < 1 or len(self.channels) > 2:
print "The device can either operate as oscilloscope (1 channel) or x-y plotter (2 channels). Please operate accordingly."
self._quit()
else:
print "Plotting will start in a new window..."
try:
# Setup Quit button
button = Tkinter.Button(master=self.root, text='Quit', command=self._quit)
button.pack(side=Tkinter.BOTTOM)
# Setup speed and width
self.scale1 = Tkinter.Scale(master=self.root,label="View Width:", from_=3, to=1000, sliderlength=30, length=self.ax.get_window_extent().width, orient=Tkinter.HORIZONTAL)
self.scale2 = Tkinter.Scale(master=self.root,label="Generation Speed:", from_=1, to=200, sliderlength=30, length=self.ax.get_window_extent().width, orient=Tkinter.HORIZONTAL)
self.scale2.pack(side=Tkinter.BOTTOM)
self.scale1.pack(side=Tkinter.BOTTOM)
self.scale1.set(4000)
self.scale2.set(self.scale2['to']-10)
self.root.protocol("WM_DELETE_WINDOW", self._quit)
if len(self.channels) == 1:
self.values = []
else:
self.valuesx = [0 for x in range(4000)]
self.valuesy = [0 for y in range(4000)]
self.root.after(4000, self.draw)
Tkinter.mainloop()
except Exception, err:
print "Error. Try again."
print err
self._quit()
示例3: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def __init__(self, canvas, window):
self.canvas = canvas
self.window = window
xmin, xmax = canvas.figure.bbox.intervalx
height, width = 50, xmax-xmin
Tk.Frame.__init__(self, master=self.window,
width=int(width), height=int(height),
borderwidth=2)
self.update() # Make axes menu
self.bLeft = self._Button(
text="Left", file="stock_left",
command=lambda x=-1: self.panx(x))
self.bRight = self._Button(
text="Right", file="stock_right",
command=lambda x=1: self.panx(x))
self.bZoomInX = self._Button(
text="ZoomInX",file="stock_zoom-in",
command=lambda x=1: self.zoomx(x))
self.bZoomOutX = self._Button(
text="ZoomOutX", file="stock_zoom-out",
command=lambda x=-1: self.zoomx(x))
self.bUp = self._Button(
text="Up", file="stock_up",
command=lambda y=1: self.pany(y))
self.bDown = self._Button(
text="Down", file="stock_down",
command=lambda y=-1: self.pany(y))
self.bZoomInY = self._Button(
text="ZoomInY", file="stock_zoom-in",
command=lambda y=1: self.zoomy(y))
self.bZoomOutY = self._Button(
text="ZoomOutY",file="stock_zoom-out",
command=lambda y=-1: self.zoomy(y))
self.bSave = self._Button(
text="Save", file="stock_save_as",
command=self.save_figure)
self.pack(side=Tk.BOTTOM, fill=Tk.X)
示例4: retryskipabort
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def retryskipabort(message, timeout=20):
"""
Show dialog of RETRY,SKIP,ABORT
Returns:
one of "retry", "skip", "abort"
"""
root = tk.Tk()
root.geometry("400x200")
root.title("Exception handle")
root.eval('tk::PlaceWindow %s center' % root.winfo_pathname(root.winfo_id()))
root.attributes("-topmost", True)
_kvs = {"result": "abort"}
def cancel_timer(*args):
root.after_cancel(_kvs['root'])
root.title("Manual")
def update_prompt():
cancel_timer()
def f(result):
def _inner():
_kvs['result'] = result
root.destroy()
return _inner
tk.Label(root, text=message).pack(side=tk.TOP, fill=tk.X, pady=10)
frmbtns = tk.Frame(root)
tk.Button(frmbtns, text="Skip", command=f('skip')).pack(side=tk.LEFT)
tk.Button(frmbtns, text="Retry", command=f('retry')).pack(side=tk.LEFT)
tk.Button(frmbtns, text="ABORT", command=f('abort')).pack(side=tk.LEFT)
frmbtns.pack(side=tk.BOTTOM)
prompt = tk.StringVar()
label1 = tk.Label(root, textvariable=prompt) #, width=len(prompt))
label1.pack()
deadline = time.time() + timeout
def _refresh_timer():
leftseconds = deadline - time.time()
if leftseconds <= 0:
root.destroy()
return
root.title("Test will stop after " + str(int(leftseconds)) + " s")
_kvs['root'] = root.after(500, _refresh_timer)
_kvs['root'] = root.after(0, _refresh_timer)
root.bind('<Button-1>', cancel_timer)
root.mainloop()
return _kvs['result']
示例5: main
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def main():
root = tk.Tk()
lbl = tk.Label(root, text="Choose an option", fg=FGCOLOR, bg=BGCOLOR, font=TITLE_FONT)
lbl.pack(pady=(10,0))
# Main frame
fraMain = tk.Frame(root)
fraMain.pack(padx=10, pady=10)
optionsNum = len(MIM_OPTIONS)
imgIcons = [None] * optionsNum
lblImages = [None] * optionsNum
lblText1 = [None] * optionsNum
lblText2 = [None] * optionsNum
fraFields = [None] * optionsNum
i = 0
for r in MIM_OPTIONS:
fraFields[i] = tk.Frame(fraMain, bg=BGCOLOR)
# Images
imgIcons[i] = tk.PhotoImage(file=(os.path.join(RESOURCE_DIR, r['icon'])))
lblImages[i] = tk.Label(fraFields[i], image=imgIcons[i], bg=BGCOLOR)
lblImages[i].pack(side=tk.LEFT, padx=5, pady=5)
# Labels
lblText1[i] = tk.Label(fraFields[i], text=r['text1'], fg=FGCOLOR, bg=BGCOLOR, font=LABEL1_FONT)
lblText1[i].pack(pady=(10,0), anchor=tk.W) #side=tk.LEFT,
lblText2[i] = tk.Label(fraFields[i], text=r['text2'], fg=FGCOLOR, bg=BGCOLOR, font=LABEL2_FONT)
lblText2[i].pack(anchor=tk.W, padx=(0,3)) #side=tk.BOTTOM,
# Frames
fraFields[i].bind("<Enter>", lambda event, i=i: on_enter(event, [lblImages[i], lblText1[i], lblText2[i]], HIGHLIGHT_BGCOLOR))
fraFields[i].bind("<Leave>", lambda event, i=i: on_leave(event, [lblImages[i], lblText1[i], lblText2[i]], BGCOLOR))
fraFields[i].pack(fill=tk.BOTH)
name = r['script']
tag = "special" + str(i)
retag(tag, fraFields[i], lblImages[i], lblText1[i], lblText2[i])
root.bind_class(tag, "<Button-1>", lambda event, name=name: runScript(event, root, os.path.join(MIM_DIR, name)))
i = i + 1
root.configure(bg=BGCOLOR)
root.resizable(width=tk.FALSE, height=tk.FALSE)
if os.name != 'posix':
#workaround, do not load icon on unix
try:
root.iconbitmap(os.path.join(RESOURCE_DIR, 'live.ico'))
except tk.TclError:
print 'No ico file found'
root.title("simLAB")
root.mainloop()
示例6: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def __init__(self):
root = tk.Tk()
root.title('OpenCV Demo')
self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
self.win.pack(fill=tk.BOTH, expand=1)
left = tk.Frame(win)
right = tk.Frame(win)
win.add(left)
win.add(right)
scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
scrollbar.config(command=demos_lb.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.samples = {}
for fn in glob('*.py'):
name = splitfn(fn)[1]
if fn[0] != '_' and name not in exclude_list:
demos_lb.insert(tk.END, name)
self.samples[name] = fn
demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)
self.cmd_entry = cmd_entry = tk.Entry(right)
cmd_entry.bind('<Return>', self.on_run)
run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)
self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
self.linker = linker = LinkManager(text, self.on_link)
self.text.tag_config("header1", font=('arial', 14, 'bold'))
self.text.tag_config("header2", font=('arial', 12, 'bold'))
text.config(state='disabled')
text.pack(fill='both', expand=1, side=tk.BOTTOM)
cmd_entry.pack(fill='x', side='left' , expand=1)
run_btn.pack()
示例7: main
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def main():
print("Loading replay memory...")
memory = replay_memory.ReplayMemory.create_instance_supervised()
print("Loading previous annotations...")
annotations = load_annotations()
#is_annotated = dict([(str(annotation.idx), True) for annotation in annotations])
current_state_idx = memory.id_min
if annotations is not None:
while current_state_idx < memory.id_max:
key = str(current_state_idx)
if not key in annotations:
break
current_state_idx += EVERY_NTH
print("ID of first unannotated state: %d" % (current_state_idx,))
master = Tkinter.Tk()
state = memory.get_state_by_id(current_state_idx)
canvas_height = state.screenshot_rs.shape[0] * ZOOM_FACTOR
canvas_width = state.screenshot_rs.shape[1] * ZOOM_FACTOR
print("canvas height, width:", canvas_height, canvas_width)
canvas = Tkinter.Canvas(master, width=canvas_width, height=canvas_height)
canvas.pack()
canvas.focus_set()
#y = int(canvas_height / 2)
#w.create_line(0, y, canvas_width, y, fill="#476042")
message = Tkinter.Label(master, text="Click to draw annotation. Press E to switch to eraser mode. Press S to save. Use Numpad +/- for brush size.")
message.pack(side=Tkinter.BOTTOM)
window_state = WindowState(master, canvas, memory, current_state_idx, annotations)
#canvas.bind("<Button-1>", OnPaint(window_state))
#master.bind("<Button-1>", lambda event: print(event))
#master.bind("<Button-3>", lambda event: print("right", event))
#master.bind("<ButtonPress-1>", lambda event: print("press", event))
master.bind("<B1-Motion>", OnLeftMouseButton(window_state))
#master.bind("<ButtonRelease-1>", lambda event: print("release", event))
master.bind("<B3-Motion>", OnRightMouseButton(window_state))
canvas.bind("<e>", lambda event: window_state.toggle_eraser())
canvas.bind("<s>", lambda event: window_state.save_annotations(force=True))
canvas.bind("<w>", lambda event: window_state.toggle_heatmap())
canvas.bind("<Left>", lambda event: window_state.previous_state(autosave=True))
canvas.bind("<Right>", lambda event: window_state.next_state(autosave=True))
canvas.bind("<KP_Add>", lambda event: window_state.increase_brush_size())
canvas.bind("<KP_Subtract>", lambda event: window_state.decrease_brush_size())
Tkinter.mainloop()
示例8: create
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def create(memory, current_anno_attribute_name, save_to_fp, every_nth_example=10, zoom_factor=4):
print("Loading previous annotations...")
annotations = load_annotations(save_to_fp)
#is_annotated = dict([(str(annotation.idx), True) for annotation in annotations])
current_state_idx = memory.id_min
if annotations is not None:
while current_state_idx < memory.id_max:
key = str(current_state_idx)
if key not in annotations or current_anno_attribute_name not in annotations[key]:
break
current_state_idx += every_nth_example
print("ID of first unannotated state: %d" % (current_state_idx,))
master = Tkinter.Tk()
state = memory.get_state_by_id(current_state_idx)
canvas_height = state.screenshot_rs.shape[0] * zoom_factor
canvas_width = state.screenshot_rs.shape[1] * zoom_factor
print("canvas height, width:", canvas_height, canvas_width)
canvas = Tkinter.Canvas(master, width=canvas_width, height=canvas_height)
canvas.pack()
canvas.focus_set()
#y = int(canvas_height / 2)
#w.create_line(0, y, canvas_width, y, fill="#476042")
message = Tkinter.Label(master, text="Click to draw annotation. Press E to switch to eraser mode. Press S to save. Use Numpad +/- for brush size.")
message.pack(side=Tkinter.BOTTOM)
window_state = GridAnnotationWindow(
master,
canvas,
memory,
current_state_idx,
annotations,
current_anno_attribute_name,
save_to_fp,
every_nth_example,
zoom_factor
)
#canvas.bind("<Button-1>", OnPaint(window_state))
#master.bind("<Button-1>", lambda event: print(event))
#master.bind("<Button-3>", lambda event: print("right", event))
#master.bind("<ButtonPress-1>", lambda event: print("press", event))
master.bind("<B1-Motion>", window_state.on_left_mouse_button)
#master.bind("<ButtonRelease-1>", lambda event: print("release", event))
master.bind("<B3-Motion>", window_state.on_right_mouse_button)
canvas.bind("<e>", lambda event: window_state.toggle_eraser())
canvas.bind("<s>", lambda event: window_state.save_annotations(force=True))
canvas.bind("<w>", lambda event: window_state.toggle_heatmap())
canvas.bind("<p>", lambda event: window_state.toggle_previous_screenshot())
canvas.bind("<Left>", lambda event: window_state.previous_state(autosave=True))
canvas.bind("<Right>", lambda event: window_state.next_state(autosave=True))
canvas.bind("<KP_Add>", lambda event: window_state.increase_brush_size())
canvas.bind("<KP_Subtract>", lambda event: window_state.decrease_brush_size())
return window_state
示例9: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BOTTOM [as 别名]
def __init__(self):
root = tk.Tk()
root.title('OpenCV Demo')
self.win = win = tk.PanedWindow(root, orient=tk.HORIZONTAL, sashrelief=tk.RAISED, sashwidth=4)
self.win.pack(fill=tk.BOTH, expand=1)
left = tk.Frame(win)
right = tk.Frame(win)
win.add(left)
win.add(right)
scrollbar = tk.Scrollbar(left, orient=tk.VERTICAL)
self.demos_lb = demos_lb = tk.Listbox(left, yscrollcommand=scrollbar.set)
scrollbar.config(command=demos_lb.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
demos_lb.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.samples = {}
for fn in glob('*.py'):
name = splitfn(fn)[1]
if fn[0] != '_' and name not in exclude_list:
self.samples[name] = fn
for name in sorted(self.samples):
demos_lb.insert(tk.END, name)
demos_lb.bind('<<ListboxSelect>>', self.on_demo_select)
self.cmd_entry = cmd_entry = tk.Entry(right)
cmd_entry.bind('<Return>', self.on_run)
run_btn = tk.Button(right, command=self.on_run, text='Run', width=8)
self.text = text = ScrolledText(right, font=('arial', 12, 'normal'), width = 30, wrap='word')
self.linker = linker = LinkManager(text, self.on_link)
self.text.tag_config("header1", font=('arial', 14, 'bold'))
self.text.tag_config("header2", font=('arial', 12, 'bold'))
text.config(state='disabled')
text.pack(fill='both', expand=1, side=tk.BOTTOM)
cmd_entry.pack(fill='x', side='left' , expand=1)
run_btn.pack()