本文整理匯總了Python中Tkinter.Y屬性的典型用法代碼示例。如果您正苦於以下問題:Python Tkinter.Y屬性的具體用法?Python Tkinter.Y怎麽用?Python Tkinter.Y使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類Tkinter
的用法示例。
在下文中一共展示了Tkinter.Y屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def __init__(self, parent, property_dict, *args, **kw):
tk.Frame.__init__(self, parent, *args, **kw)
# create a canvas object and a vertical scrollbar for scrolling it
self.vscrollbar = vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
vscrollbar.pack(fill=tk.Y, side=tk.RIGHT, expand=tk.FALSE)
self.canvas = canvas = tk.Canvas(self, bd=0, highlightthickness=0,
yscrollcommand=vscrollbar.set)
canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.TRUE)
vscrollbar.config(command=canvas.yview)
# reset the view
canvas.xview_moveto(0)
canvas.yview_moveto(0)
# create a frame inside the canvas which will be scrolled with it
self.interior = interior = tk.Frame(canvas)
self.interior_id = canvas.create_window(0, 0, window=interior,
anchor='nw')
self.interior.bind('<Configure>', self._configure_interior)
self.canvas.bind('<Configure>', self._configure_canvas)
self.build(property_dict)
示例2: __init__
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def __init__(self, master, textvariable=None, *args, **kwargs):
tk.Frame.__init__(self, master)
# Init GUI
self._y_scrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
self._text_widget = tk.Text(self, yscrollcommand=self._y_scrollbar.set, *args, **kwargs)
self._text_widget.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self._y_scrollbar.config(command=self._text_widget.yview)
self._y_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
if textvariable is not None:
if not isinstance(textvariable, tk.Variable):
raise TypeError("tkinter.Variable type expected, {} given.".format(
type(textvariable)))
self._text_variable = textvariable
self.var_modified()
self._text_trace = self._text_widget.bind('<<Modified>>', self.text_modified)
self._var_trace = textvariable.trace("w", self.var_modified)
示例3: canvClick
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def canvClick(self, event):
try:
x = int(self.canvas1.canvasx(event.x) / self.root.zoomMult)
y = int(self.canvas1.canvasy(event.y) / self.root.zoomMult)
w, h = self.root.im.size
if 0 <= x < w and 0 <= y < h:
tk_rgb = "#%02x%02x%02x" % self.root.im.getpixel((x, y))
self.canvas2.config(bg=tk_rgb)
rgb = "R: %d; G: %d; B: %d;" % self.root.im.getpixel((x, y))
self.v.set(rgb)
xy = "X: %d; Y: %d;" % (x, y)
self.xy.set(xy)
else:
rgb = "X,Y Out of Range"
self.v.set(rgb)
except ValueError:
pass
示例4: addMessageFrame
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def addMessageFrame(self):
frame=Frame(self)
frame.pack(fill=tk.BOTH,side=tk.TOP,\
expand=1,padx=8,pady=5)
self.messagelabel=tk.Label(frame,text='Message',bg='#bbb')
self.messagelabel.pack(side=tk.TOP,fill=tk.X)
self.text=tk.Text(frame)
self.text.pack(side=tk.TOP,fill=tk.BOTH,expand=1)
self.text.height=10
scrollbar=tk.Scrollbar(self.text)
scrollbar.pack(side=tk.RIGHT,fill=tk.Y)
self.text.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.text.yview)
示例5: pack
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def pack(self):
self.file_selector_button.pack(**self.button_opt)
self.label.pack()
self.scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
self.selected_files.pack(fill=tkinter.BOTH, expand=True)
示例6: grid
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def grid(self, row=0, column=0):
"""
TODO: to be tested
"""
x = row
y = column
self.file_selector_button.grid(row=x, column=y, **self.button_opt)
x += 1
self.label.grid(row=x, column=y)
x += 1
self.scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
self.selected_files.grid(row=x, column=y, fill=tkinter.BOTH, expand=True)
x += 1
return (x,y)
示例7: __init__
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def __init__(self, parent):
scrollbar = tk.Scrollbar(parent, orient=tk.VERTICAL)
self.listbox = tk.Listbox(parent, yscrollcommand=scrollbar.set, selectmode=tk.EXTENDED)
scrollbar.configure(command=self.listbox.yview)
self.listbox.pack(side=tk.LEFT,fill=tk.BOTH, expand=1, pady=5)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y, pady=5)
示例8: picture_tool
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def picture_tool(filename = None):
"""Allows you to find information about digital images.
The PictureTool's Toolbar:
Once you have opened an image, you can view information about its
individual pixels by looking at the toolbar. To select a pixel drag
(click and hold down) the mouse to the position you want and then
release it to hold that position's information in the toolbar.
The following information in the toolbar changes to reflect the
properties of the pixel you selected:
X = the x coordinate of the pixel (starting with 0, counting from the left)
Y = the y coordinate of the pixel (starting with 0, counting from the top)
R = the Red value of the pixel (0 to 255)
G = the Green value of the pixel (0 to 255)
B = the Blue value of the pixel (0 to 255)
In addition, the box at the far right displays the color of the pixel.
Zooming in/out:
To Zoom, select the amount of zoom you want from the zoom menu.
Less than 100% zooms out and more than 100% zooms in.
The 100% zoom level will always return you to your orginal picture.
filename: a string representing the location and name of picture.
If no filename is given, a file-chooser opens."""
if not filename:
filename = _easygui.fileopenbox("Select an image",
_sys.argv[0], '*',
[ [ "*.jpg", "*.png", "*.bmp", "*.gif",
"Image files" ] ])
if not filename:
raise RuntimeError("No image file selected.")
img = load_picture(filename)
tool = PictureTool(img)
tool.run_tool()
# --------------------------------------------------------------------
示例9: show_error_dialog
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [as 別名]
def show_error_dialog(self, title, message_text, exception):
# ToDo: Check Windows behavior!! --> -disable
self._root.wm_attributes("-topmost", False)
err_dialog = Tk.Toplevel(self._frame)
err_dialog.minsize(300, 400)
err_dialog.transient(self._frame)
err_dialog.focus_force()
err_dialog.grab_set()
def add_textview(header, text):
err_dialog_frame = Tk.Frame(err_dialog)
err_dialog_label = Tk.Label(err_dialog_frame, text=header)
err_dialog_label.pack(side='top', fill=Tk.X)
err_dialog_text = Tk.Text(err_dialog_frame, height=10)
err_dialog_text.insert(Tk.END, text)
err_dialog_text.pack(side='left', fill=Tk.Y)
err_dialog_scrollbar = Tk.Scrollbar(err_dialog_frame)
err_dialog_scrollbar.pack(side='right', fill=Tk.Y)
err_dialog_scrollbar.config(command=err_dialog_text.yview)
err_dialog_text.config(yscrollcommand=err_dialog_scrollbar.set)
err_dialog_frame.pack(side='top')
def close_error_dialog():
# ToDo: Check Windows behavior!! -disable
self._root.wm_attributes("-topmost", True)
err_dialog.destroy()
err_dialog.protocol("WM_DELETE_WINDOW", close_error_dialog)
add_textview(message_text, str(exception))
if isinstance(exception, TexTextCommandFailed):
if exception.stdout:
add_textview('Stdout:', exception.stdout.decode('utf-8'))
if exception.stderr:
add_textview('Stderr:', exception.stderr.decode('utf-8'))
close_button = Tk.Button(err_dialog, text='OK', command=close_error_dialog)
close_button.pack(side='top', fill='x', expand=True)
示例10: __init__
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [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()
示例11: __init__
# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Y [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()