本文整理汇总了Python中Tkinter.LEFT属性的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.LEFT属性的具体用法?Python Tkinter.LEFT怎么用?Python Tkinter.LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.LEFT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [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: build
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def build(self, property_dict):
for c in self.interior.winfo_children():
c.destroy()
# Filter property dict
property_dict = {k: v for k, v in property_dict.items()
if self._key_filter_function(k)}
# Prettify key/value pairs for display
property_dict = {self._make_key_pretty(k): self._make_value_pretty(v)
for k, v in property_dict.items()}
# Sort by key and filter
dict_values = sorted(property_dict.items(), key=lambda x: x[0])
for n,(k,v) in enumerate(dict_values):
tk.Label(self.interior, text=k, borderwidth=1, relief=tk.SOLID,
wraplength=75, anchor=tk.E, justify=tk.RIGHT).grid(
row=n, column=0, sticky='nesw', padx=1, pady=1, ipadx=1)
tk.Label(self.interior, text=v, borderwidth=1,
wraplength=125, anchor=tk.W, justify=tk.LEFT).grid(
row=n, column=1, sticky='nesw', padx=1, pady=1, ipadx=1)
示例3: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def __init__(self, root, main_window, button_opt):
ttk.Frame.__init__(self, root)
self.root = root
self.main_window = main_window
self.current_files = None
self.button_opt = button_opt
# define options for opening or saving a file
self.file_opt = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
options['initialdir'] = os.path.expanduser("~")
options['parent'] = root
options['title'] = 'Select files to annotate.'
self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames)
self.label = ttk.Label(self.root, text=u"selected file(s):")
self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif"))
self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT)
self.scrollbar = ttk.Scrollbar(self.root)
self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.selected_files.yview)
示例4: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [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)
示例5: showtip
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, _, _ = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + self.widget.winfo_rooty()
self.tipwindow = tw = Tk.Toplevel(self.widget)
tw.wm_overrideredirect(1)
tw.wm_geometry("+%d+%d" % (x, y))
try:
# For Mac OS
tw.tk.call("::tk::unsupported::MacWindowStyle",
"style", tw._w,
"help", "noActivates")
except Tk.TclError:
pass
label = Tk.Label(tw, text=self.text, justify=Tk.LEFT,
background="#ffffe0", relief=Tk.SOLID, borderwidth=1,
)
label.pack(ipadx=1)
示例6: _calltip_window
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def _calltip_window(parent): # htest #
from Tkinter import Toplevel, Text, LEFT, BOTH
top = Toplevel(parent)
top.title("Test calltips")
top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
parent.winfo_rooty() + 150))
text = Text(top)
text.pack(side=LEFT, fill=BOTH, expand=1)
text.insert("insert", "string.split")
top.update()
calltip = CallTip(text)
def calltip_show(event):
calltip.showtip("(s=Hello world)", "insert", "end")
def calltip_hide(event):
calltip.hidetip()
text.event_add("<<calltip-show>>", "(")
text.event_add("<<calltip-hide>>", ")")
text.bind("<<calltip-show>>", calltip_show)
text.bind("<<calltip-hide>>", calltip_hide)
text.focus_set()
示例7: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def __init__(self, parent):
tk.LabelFrame.__init__(self, parent)
self.title = tk.Label(self, text='SV Length')
self.len_GT_On = tk.IntVar(value=0)
self.len_GT_On_CB = tk.Checkbutton(self, text=">", justify=tk.LEFT, variable=self.len_GT_On)
self.len_GT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
self.len_GT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)
self.len_LT_On = tk.IntVar(value=0)
self.len_LT_On_CB = tk.Checkbutton(self, text="<", justify=tk.LEFT, variable=self.len_LT_On)
self.len_LT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
self.len_LT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)
self.title.grid(row=0, column=0, sticky=tk.EW, columnspan=4)
self.len_GT_On_CB.grid(row=1, column=0, sticky=tk.EW)
self.len_GT_val.grid(row=2, column=0, sticky=tk.EW)
self.len_GT_Units.grid(row=2, column=1, sticky=tk.EW)
self.len_LT_On_CB.grid(row=1, column=2, sticky=tk.EW)
self.len_LT_val.grid(row=2, column=2, sticky=tk.EW)
self.len_LT_Units.grid(row=2, column=3, sticky=tk.EW)
示例8: genotypes
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def genotypes(self, sv, vcf_samples, run_samples):
message = ''
line = ''
for i, gt in enumerate(sv.GTs):
if '1' in gt:
if vcf_samples[i] in run_samples:
this = '%s:%s' % (vcf_samples[i], gt)
if len(line) == 0:
line = this
elif len(this) + len(line) >= 50:
message += line + ',\n'
line = this
else:
line += ', %s' % this
message += line
self.message.config(text=message, bg='white', width=55, justify=tk.LEFT)
# class for multiple listboxes linked by single scroll bar
示例9: show_mnemonic_gui
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def show_mnemonic_gui(mnemonic_sentence):
"""may be called *after* main() to display the successful result iff the GUI is in use
:param mnemonic_sentence: the mnemonic sentence that was found
:type mnemonic_sentence: unicode
:rtype: None
"""
assert tk_root
global pause_at_exit
padding = 6
tk.Label(text="WARNING: seed information is sensitive, carefully protect it and do not share", fg="red") \
.pack(padx=padding, pady=padding)
tk.Label(text="Seed found:").pack(side=tk.LEFT, padx=padding, pady=padding)
entry = tk.Entry(width=80, readonlybackground="white")
entry.insert(0, mnemonic_sentence)
entry.config(state="readonly")
entry.select_range(0, tk.END)
entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=padding, pady=padding)
tk_root.deiconify()
tk_root.lift()
entry.focus_set()
tk_root.mainloop() # blocks until the user closes the window
pause_at_exit = False
示例10: buttonbox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def buttonbox(self):
try:
self.attributes("-toolwindow",1) #only works on windows
except:
#self.overrideredirect(1) #removes whole frame
self.resizable(0,0) #stops maximising and resizing but can still be minimised
box = tk.Frame(self)
w = tk.Button(box, text="Don't Save", width=10, command=self.close_dont_save)
w.pack(side=tk.LEFT, padx=5, pady=5)
w = tk.Button(box, text="Cancel", width=10, command=self.cancel)
w.pack(side=tk.LEFT, padx=5, pady=5)
w = tk.Button(box, text="Save", width=10, command=self.close_and_save, default=tk.ACTIVE)
w.pack(side=tk.LEFT, padx=5, pady=5)
self.bind("<Return>", self.close_and_save)
self.bind("<Escape>", self.cancel)
box.pack()
示例11: buttonbox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def buttonbox(self, box):
# add standard button box. override if you don't want the
# standard buttons
frame = tk.Frame(box)
frame.pack()
w = tk.Button(frame, text="OK", width=10, command=self.ok, default=tk.ACTIVE)
w.pack(side=tk.LEFT, padx=5, pady=5)
w = tk.Button(frame, text="Cancel", width=10, command=self.cancel)
w.pack(side=tk.LEFT, padx=5, pady=5)
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.cancel)
#
# standard button semantics
示例12: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def __init__(self, parent, src_file, lens):
# Set flag once all window objects created.
self.init_done = False
# Final result is the lens object.
self.lens = lens
# Load the input file.
self.img = Image.open(src_file)
# Create frame for this window with two vertical panels...
parent.wm_title('Fisheye Alignment')
self.frame = tk.Frame(parent)
self.controls = tk.Frame(self.frame)
# Make sliders for adjusting the lens parameters quaternion.
self.x = self._make_slider(self.controls, 0, 'Center-X (px)',
lens.get_x(), self.img.size[0])
self.y = self._make_slider(self.controls, 1, 'Center-Y (px)',
lens.get_y(), self.img.size[1])
self.r = self._make_slider(self.controls, 2, 'Radius (px)',
lens.radius_px, self.img.size[0])
self.f = self._make_slider(self.controls, 3, 'Field of view (deg)',
lens.fov_deg, 240, res=0.1)
# Create a frame for the preview image, which resizes based on the
# outer frame but does not respond to the contained preview size.
self.preview_frm = tk.Frame(self.frame)
self.preview_frm.bind('<Configure>', self._update_callback) # Update on resize
# Create the canvas object for the preview image.
self.preview = tk.Canvas(self.preview_frm)
# Finish frame creation.
self.controls.pack(side=tk.LEFT)
self.preview.pack(fill=tk.BOTH, expand=1)
self.preview_frm.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.frame.pack(fill=tk.BOTH, expand=1)
# Render the image once at default size
self.init_done = True
self.update_preview((800,800))
# Disable further size propagation.
self.preview_frm.update()
self.preview_frm.pack_propagate(0)
# Redraw the preview image using latest GUI parameters.
示例13: _Button
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def _Button(self, text, file, command):
file = os.path.join(rcParams['datapath'], 'images', file)
im = Tk.PhotoImage(master=self, file=file)
b = Tk.Button(
master=self, text=text, padx=2, pady=2, image=im, command=command)
b._ntimage = im
b.pack(side=Tk.LEFT)
return b
示例14: showtip
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def showtip(self, text, parenleft, parenright):
"""Show the calltip, bind events which will close it and reposition it.
"""
# Only called in CallTips, where lines are truncated
self.text = text
if self.tipwindow or not self.text:
return
self.widget.mark_set(MARK_RIGHT, parenright)
self.parenline, self.parencol = map(
int, self.widget.index(parenleft).split("."))
self.tipwindow = tw = Toplevel(self.widget)
self.position_window()
# remove border on calltip window
tw.wm_overrideredirect(1)
try:
# This command is only needed and available on Tk >= 8.4.0 for OSX
# Without it, call tips intrude on the typing process by grabbing
# the focus.
tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
"help", "noActivates")
except TclError:
pass
self.label = Label(tw, text=self.text, justify=LEFT,
background="#ffffe0", relief=SOLID, borderwidth=1,
font = self.widget['font'])
self.label.pack()
self.checkhideid = self.widget.bind(CHECKHIDE_VIRTUAL_EVENT_NAME,
self.checkhide_event)
for seq in CHECKHIDE_SEQUENCES:
self.widget.event_add(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
self.widget.after(CHECKHIDE_TIME, self.checkhide_event)
self.hideid = self.widget.bind(HIDE_VIRTUAL_EVENT_NAME,
self.hide_event)
for seq in HIDE_SEQUENCES:
self.widget.event_add(HIDE_VIRTUAL_EVENT_NAME, seq)
示例15: strap_design_frame_builder
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import LEFT [as 别名]
def strap_design_frame_builder(self):
self.strap_inputs_frame = tk.Frame(self.strap_design_frame)
self.strap_inputs_frame.pack(side=tk.LEFT, anchor='nw')
self.strap_calc_frame = tk.Frame(self.strap_design_frame)
self.strap_calc_frame.pack(side=tk.RIGHT ,anchor='ne', fill=tk.BOTH, expand=1)
tk.Label(self.strap_inputs_frame, text="B = ", font=self.helv).grid(row=0, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.bs, width=10, validate="key", validatecommand=self.reset_status).grid(row=0, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=0, column=2)
tk.Label(self.strap_inputs_frame, text="H = ", font=self.helv).grid(row=1, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.hs, width=10, validate="key", validatecommand=self.reset_status).grid(row=1, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=1, column=2)
self.strap_vbar_size = tk.StringVar()
self.inputs.append(self.strap_vbar_size)
self.strap_vbar_size.set('3')
self.strap_vbar_size_label = tk.Label(self.strap_inputs_frame, text="Shear\nBar Size (#) : ", font=self.helv)
self.strap_vbar_size_label.grid(row=2,column=0, pady=2)
self.strap_vbar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_vbar_size, '3', '4', '5', command=self.reset_status)
self.strap_vbar_size_menu.config(font=self.helv)
self.strap_vbar_size_menu.grid(row=2, column=1, padx= 2, sticky=tk.W)
self.strap_bar_size = tk.StringVar()
self.inputs.append(self.strap_bar_size)
self.strap_bar_size.set('3')
self.strap_bar_size_label = tk.Label(self.strap_inputs_frame, text="Flexure\nBar Size (#) : ", font=self.helv)
self.strap_bar_size_label.grid(row=4,column=0, pady=2)
self.strap_bar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_bar_size, '3', '4', '5','6','7','8','9','10','11','14','18', command=self.reset_status)
self.strap_bar_size_menu.config(font=self.helv)
self.strap_bar_size_menu.grid(row=4, column=1, padx= 2, sticky=tk.W)
self.strap_calc_txtbox = tk.Text(self.strap_calc_frame, height = 25, width = 70, bg= "grey90", font= self.helv_norm, wrap=tk.WORD)
self.strap_calc_txtbox.grid(row=0, column=0, sticky='nsew')
self.strap_scroll = tk.Scrollbar(self.strap_calc_frame, command=self.strap_calc_txtbox.yview)
self.strap_scroll.grid(row=0, column=1, sticky='nsew')
self.strap_calc_txtbox['yscrollcommand'] = self.strap_scroll.set