本文整理汇总了Python中tkinter.RIGHT属性的典型用法代码示例。如果您正苦于以下问题:Python tkinter.RIGHT属性的具体用法?Python tkinter.RIGHT怎么用?Python tkinter.RIGHT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tkinter
的用法示例。
在下文中一共展示了tkinter.RIGHT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def __init__(self):
super().__init__()
self.text_area = TextArea(self, bg="white", fg="black", undo=True)
self.scrollbar = ttk.Scrollbar(orient="vertical", command=self.scroll_text)
self.text_area.configure(yscrollcommand=self.scrollbar.set)
self.line_numbers = LineNumbers(self, self.text_area, bg="grey", fg="white", width=1)
self.highlighter = Highlighter(self.text_area, 'languages/python.yaml')
self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.line_numbers.pack(side=tk.LEFT, fill=tk.Y)
self.text_area.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.bind_events()
示例2: load_friends
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def load_friends(self):
all_users = self.requester.get_all_users()
for user in all_users:
if user['username'] != self.username:
friend_frame = ttk.Frame(self.canvas_frame)
profile_photo = tk.PhotoImage(file="images/avatar.png")
profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
profile_photo_label.image = profile_photo
friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)
message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"])
message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend)
profile_photo_label.pack(side=tk.LEFT)
friend_name.pack(side=tk.LEFT)
message_button.pack(side=tk.RIGHT)
friend_frame.pack(fill=tk.X, expand=1)
示例3: load_friends
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def load_friends(self):
friend_frame = ttk.Frame(self.canvas_frame)
profile_photo = tk.PhotoImage(file="images/avatar.png")
profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
profile_photo_label.image = profile_photo
friend_name = ttk.Label(friend_frame, text="Jaden Corebyn", anchor=tk.W)
message_button = ttk.Button(friend_frame, text="Chat", command=self.open_chat_window)
profile_photo_label.pack(side=tk.LEFT)
friend_name.pack(side=tk.LEFT)
message_button.pack(side=tk.RIGHT)
friend_frame.pack(fill=tk.X, expand=1)
示例4: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def __init__(self):
super().__init__()
self.text_area = TextArea(self, bg="white", fg="black", undo=True)
self.scrollbar = ttk.Scrollbar(orient="vertical", command=self.scroll_text)
self.text_area.configure(yscrollcommand=self.scrollbar.set)
self.line_numbers = tk.Text(self, bg="grey", fg="white")
first_100_numbers = [str(n+1) for n in range(100)]
self.line_numbers.insert(1.0, "\n".join(first_100_numbers))
self.line_numbers.configure(state="disabled", width=3)
self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.line_numbers.pack(side=tk.LEFT, fill=tk.Y)
self.text_area.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self.bind_events()
示例5: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def __init__(self):
super().__init__()
self.title("Hello Tkinter")
self.label_text = tk.StringVar()
self.label_text.set("My Name Is: ")
self.name_text = tk.StringVar()
self.label = tk.Label(self, textvar=self.label_text)
self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=10)
self.name_entry = tk.Entry(self, textvar=self.name_text)
self.name_entry.pack(fill=tk.BOTH, expand=1, padx=20, pady=20)
hello_button = tk.Button(self, text="Say Hello", command=self.say_hello)
hello_button.pack(side=tk.LEFT, padx=(20, 0), pady=(0, 20))
goodbye_button = tk.Button(self, text="Say Goodbye", command=self.say_goodbye)
goodbye_button.pack(side=tk.RIGHT, padx=(0, 20), pady=(0, 20))
示例6: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [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)
示例7: build
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [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)
示例8: create_toolbar
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def create_toolbar(self):
self.toolbar = ttk.Frame(self.master)
newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
image=self.images[NEW], command=self.board.new_game)
TkUtil.Tooltip.Tooltip(newButton, text="New Game")
zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
self.zoomSpinbox = Spinbox(self.toolbar,
textvariable=self.zoom, from_=Board.MIN_ZOOM,
to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
justify=tk.RIGHT, validate="all")
self.zoomSpinbox.config(validatecommand=(
self.zoomSpinbox.register(self.validate_int), "%P"))
TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
textvariable=self.shapeName, state="readonly",
values=sorted(Shapes.ShapeForName.keys()))
TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
zoomLabel, self.zoomSpinbox, self.shapeCombobox))
self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board)
示例9: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [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)
示例10: _init_toolbar
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [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:
# Add a spacer; return value is unused.
self._Spacer()
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)
示例11: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def __init__(self, master=None, compound=tk.RIGHT, autohidescrollbar=True, **kwargs):
"""
Create a Listbox with a vertical scrollbar.
:param master: master widget
:type master: widget
:param compound: side for the Scrollbar to be on (:obj:`tk.LEFT` or :obj:`tk.RIGHT`)
:type compound: str
:param autohidescrollbar: whether to use an :class:`~ttkwidgets.AutoHideScrollbar` or a :class:`ttk.Scrollbar`
:type autohidescrollbar: bool
:param kwargs: keyword arguments passed on to the :class:`tk.Listbox` initializer
"""
ttk.Frame.__init__(self, master)
self.columnconfigure(1, weight=1)
self.rowconfigure(0, weight=1)
self.listbox = tk.Listbox(self, **kwargs)
if autohidescrollbar:
self.scrollbar = AutoHideScrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview)
else:
self.scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview)
self.config_listbox(yscrollcommand=self.scrollbar.set)
if compound is not tk.LEFT and compound is not tk.RIGHT:
raise ValueError("Invalid compound value passed: {0}".format(compound))
self.__compound = compound
self._grid_widgets()
示例12: _init_toolbar
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [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:
# Add a spacer; return value is unused.
self._Spacer()
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)
示例13: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def __init__(self, parent, **kwargs):
super().__init__(parent, highlightthickness=0, **kwargs)
vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
vscrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.canvas = canvas = tk.Canvas(self, bd=2, highlightthickness=0,
yscrollcommand=vscrollbar.set)
canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
vscrollbar.config(command=canvas.yview)
canvas.xview_moveto(0)
canvas.yview_moveto(0)
self.interior = interior = tk.Frame(canvas)
self.interior_id = canvas.create_window(0, 0,
window=interior,
anchor=tk.NW)
self.interior.bind("<Configure>", self.configure_interior)
self.canvas.bind("<Configure>", self.configure_canvas)
self.scrollbar = vscrollbar
self.mouse_position = 0
示例14: addInput
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def addInput(self, item, defValue, row):
pos = len(row)
inputVal = tk.StringVar()
inputVal.set(str(defValue))
inputEl = tk.Entry(self.interior,
width=10,
justify=tk.RIGHT,
textvariable=inputVal)
inputEl.item = item
inputEl.row = row
inputEl.pos = pos
inputEl.val = inputVal
inputEl.bind('<Shift-Key-Tab>', self.onShiftTab)
inputEl.bind('<Key-Tab>', self.onTab)
inputEl.bind('<Key-Return>', self.onReturn)
inputEl.bind('<Key-Down>', self.onDown)
inputEl.bind('<Key-Up>', self.onUp)
inputEl.bind('<FocusOut>', lambda evt: self.validateRow(evt.widget.row))
self.addWidget(inputEl, sticky='E')
row.append((inputEl, inputVal))
示例15: build_window
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import RIGHT [as 别名]
def build_window(self):
"""
Generates the window.
:author: Pablo Sanz Alguacil
"""
self.root = Toplevel()
self.root.geometry('460x300')
self.root.resizable(width=False, height=False)
self.root.title('About')
# LABEL - INFO
self.label_info = Label(self.root, pady=15,
text="Developed as the Group Project for 3rd year of the Bachelor "
"\nof Science in Computing in Digital Forensics and Cyber Security "
"\nat the Technological University Dublin."
"\n")
self.label_info.pack()
self.button = Button(self.root, text="Project page", command=self.open_link)
self.button.pack()
self.frame = Frame(self.root)
self.frame.pack()
photo = PhotoImage(file=self.logo)
photo_label = Label(self.frame, image=photo)
photo_label.image = photo
photo_label.pack(side=LEFT)
self.label_collaborators = Label(self.frame, text="\tPablo Sanz Alguacil (Code)"
"\n\tMiguel Yanes Fernández (Code)"
"\n\tAdam Chalkley (Research)")
self.label_collaborators.pack(side=RIGHT)