Python tkinter.RIGHT Examples
The following are 30
code examples of tkinter.RIGHT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.

Example #1
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 8 votes |
def create_list_box(self): frame = tk.Frame(self.root) self.list_box = tk.Listbox(frame, activestyle='none', cursor='hand2', bg='#1C3D7D', fg='#A0B9E9', selectmode=tk.EXTENDED, height=10) self.list_box.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.list_box.bind( "<Double-Button-1>", self.on_play_list_double_clicked) self.list_box.bind("<Button-3>", self.show_context_menu) scroll_bar = tk.Scrollbar(frame) scroll_bar.pack(side=tk.RIGHT, fill=tk.BOTH) self.list_box.config(yscrollcommand=scroll_bar.set) scroll_bar.config(command=self.list_box.yview) frame.grid(row=4, padx=5, columnspan=10, sticky='ew')
Example #2
Source File: texteditor.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
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()
Example #3
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
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)
Example #4
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
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)
Example #5
Source File: texteditor.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
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()
Example #6
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def load_friends(self): my_friends = self.requester.get_friends(self.username) for user in my_friends["friends"]: if user['username'] != self.username: friend_frame = ttk.Frame(self.canvas_frame) friend_avatar_path = os.path.join(friend_avatars_dir, f"{user['username']}.png") if user["avatar"]: with open(friend_avatar_path, 'wb') as friend_avatar: img = base64.urlsafe_b64decode(user['avatar']) friend_avatar.write(img) else: friend_avatar_path = default_avatar_path profile_photo = tk.PhotoImage(file=friend_avatar_path) 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"], avatar=friend_avatar_path) block_this_friend = partial(self.block_friend, username=user["username"]) message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend) block_button = ttk.Button(friend_frame, text="Block", command=block_this_friend) profile_photo_label.pack(side=tk.LEFT) friend_name.pack(side=tk.LEFT) message_button.pack(side=tk.RIGHT) block_button.pack(side=tk.RIGHT, padx=(0, 30)) friend_frame.pack(fill=tk.X, expand=1)
Example #7
Source File: ch1-6.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
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))
Example #8
Source File: SikuliGui.py From lackey with MIT License | 6 votes |
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)
Example #9
Source File: _backend_tk.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
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)
Example #10
Source File: _backend_tk.py From GraphicDesignPatternByPython with MIT License | 6 votes |
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)
Example #11
Source File: _backend_tk.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #12
Source File: tkwidgets.py From hwk-mirror with GNU General Public License v3.0 | 6 votes |
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
Example #13
Source File: update_gui.py From Trade-Dangerous with Mozilla Public License 2.0 | 6 votes |
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))
Example #14
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_list_box(self): frame = tk.Frame(self.root) self.list_box = tk.Listbox(frame, activestyle='none', cursor='hand2', bg='#1C3D7D', fg='#A0B9E9', selectmode=tk.EXTENDED, height=10) self.list_box.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.list_box.bind( "<Double-Button-1>", self.on_play_list_double_clicked) self.list_box.bind("<Button-3>", self.show_context_menu) scroll_bar = tk.Scrollbar(frame) scroll_bar.pack(side=tk.RIGHT, fill=tk.BOTH) self.list_box.config(yscrollcommand=scroll_bar.set) scroll_bar.config(command=self.list_box.yview) frame.grid(row=4, padx=5, columnspan=10, sticky='ew')
Example #15
Source File: wicc_view_about.py From WiCC with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: findwindow.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self, master, **kwargs): super().__init__(**kwargs ) self.geometry('350x100') self.title('Find and Replace') self.text_to_find = tk.StringVar() self.text_to_replace_with = tk.StringVar() top_frame = tk.Frame(self) middle_frame = tk.Frame(self) bottom_frame = tk.Frame(self) find_entry_label = tk.Label(top_frame, text="Find: ") self.find_entry = ttk.Entry(top_frame, textvar=self.text_to_find) replace_entry_label = tk.Label(middle_frame, text="Replace: ") self.replace_entry = ttk.Entry(middle_frame, textvar=self.text_to_replace_with) self.find_button = ttk.Button(bottom_frame, text="Find", command=self.on_find) self.replace = ttk.Button(bottom_frame, text="Replace", command=self.on_replace) self.cancel_button = ttk.Button(bottom_frame, text="Cancel", command=self.destroy) find_entry_label.pack(side=tk.LEFT, padx=(20, 0)) self.find_entry.pack(side=tk.LEFT, fill=tk.X, expand=1) replace_entry_label.pack(side=tk.LEFT) self.replace_entry.pack(side=tk.LEFT, fill=tk.X, expand=1) self.find_button.pack(side=tk.LEFT, padx=(85, 0)) self.cancel_button.pack(side=tk.RIGHT, padx=(0, 30)) top_frame.pack(side=tk.TOP, expand=1, fill=tk.X, padx=30) middle_frame.pack(side=tk.TOP, expand=1, fill=tk.X, padx=30) bottom_frame.pack(side=tk.TOP, expand=1, fill=tk.X)
Example #17
Source File: ch1-5.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self): super().__init__() self.title("Hello Tkinter") self.label_text = tk.StringVar() self.label_text.set("Choose One") self.label = tk.Label(self, textvar=self.label_text) self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=30) 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))
Example #18
Source File: ch1-4.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self): super().__init__() self.title("Hello Tkinter") self.label_text = tk.StringVar() self.label_text.set("Choose One") self.label = tk.Label(self, textvar=self.label_text) self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=30) 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))
Example #19
Source File: ch1-2.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self): super().__init__() self.title("Hello Tkinter") self.label = tk.Label(self, text="Choose One") self.label.pack(fill=tk.BOTH, expand=1, padx=100, pady=30) 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))
Example #20
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
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)
Example #21
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
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)
Example #22
Source File: map-creator.py From rpg-text with MIT License | 5 votes |
def __init__(self, master=None): super().__init__(master) self.text = tk.Text(self, width=80, height=40) self.vsb = tk.Scrollbar(self, command=self.text.yview) self.text.pack(side=tk.LEFT, expand=True, fill=tk.BOTH) self.vsb.pack(side=tk.RIGHT, expand=True, fill=tk.Y) self.text.insert(tk.END, HELP_TXT) self.text.config(state=tk.DISABLED, xscrollcommand=self.vsb.set)
Example #23
Source File: components.py From SEM with MIT License | 5 votes |
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)
Example #24
Source File: components.py From SEM with MIT License | 5 votes |
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)
Example #25
Source File: Editor.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def __init__(self, master, set_status_text=report, **kwargs): super().__init__(master, **kwargs) self.set_status_text = set_status_text self.filename = None for justify in (tk.LEFT, tk.CENTER, tk.RIGHT): self.text.tag_configure(justify, justify=justify)
Example #26
Source File: Editor.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def align(self, alignment): for justify in {tk.LEFT, tk.CENTER, tk.RIGHT} - {alignment}: self.text.tag_remove(justify, "1.0", tk.END) self.text.tag_add(alignment, "1.0", tk.END)
Example #27
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_view_menu(self): modifier = TkUtil.menu_modifier() viewMenu = tk.Menu(self.menubar) viewMenu.add_checkbutton(label=BOLD, underline=0, image=self.menuImages[BOLD], compound=tk.LEFT, variable=self.bold, command=lambda: self.toggle_button(self.boldButton)) viewMenu.add_checkbutton(label=ITALIC, underline=0, image=self.menuImages[ITALIC], compound=tk.LEFT, variable=self.italic, command=lambda: self.toggle_button(self.italicButton)) viewMenu.add_separator() viewMenu.add_radiobutton(label=ALIGN_LEFT, underline=6, image=self.menuImages[ALIGNLEFT], compound=tk.LEFT, variable=self.alignment, value=tk.LEFT, command=self.toggle_alignment) viewMenu.add_radiobutton(label=ALIGN_CENTER, underline=6, image=self.menuImages[ALIGNCENTER], compound=tk.LEFT, variable=self.alignment, value=tk.CENTER, command=self.toggle_alignment) viewMenu.add_radiobutton(label=ALIGN_RIGHT, underline=6, image=self.menuImages[ALIGNRIGHT], compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT, command=self.toggle_alignment) self.menubar.add_cascade(label="View", underline=0, menu=viewMenu)
Example #28
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_alignment_toolbar(self): settings = TkUtil.Settings.Data self.alignmentToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED) self.alignmentToolbar.text = ALIGNMENT_TOOLBAR self.alignmentToolbar.underline = 0 menuButton = ttk.Button(self.alignmentToolbar, text="Alignment Toolbar Menu", image=self.toolbarImages[TOOLBARMENU], command=self.toolbar_menu) TkUtil.bind_context_menu(menuButton, self.toolbar_menu) TkUtil.Tooltip.Tooltip(menuButton, text="Alignment Toolbar Menu") self.leftButton = ttk.Button(self.alignmentToolbar, text=ALIGN_LEFT, image=self.toolbarImages[ALIGNLEFT]) self.leftButton.config( command=lambda: self.toggle_alignment(tk.LEFT)) TkUtil.Tooltip.Tooltip(self.leftButton, text=ALIGN_LEFT) self.centerButton = ttk.Button(self.alignmentToolbar, text=ALIGN_CENTER, image=self.toolbarImages[ALIGNCENTER]) self.centerButton.config( command=lambda: self.toggle_alignment(tk.CENTER)) TkUtil.Tooltip.Tooltip(self.centerButton, text=ALIGN_CENTER) self.rightButton = ttk.Button(self.alignmentToolbar, text=ALIGN_RIGHT, image=self.toolbarImages[ALIGNRIGHT]) self.rightButton.config( command=lambda: self.toggle_alignment(tk.RIGHT)) TkUtil.Tooltip.Tooltip(self.rightButton, text=ALIGN_RIGHT) TkUtil.add_toolbar_buttons(self.alignmentToolbar, (menuButton, self.leftButton, self.centerButton, self.rightButton)) self.toolbars.append(self.alignmentToolbar) self.leftButton.state((TkUtil.SELECTED,)) self.alignment.set(tk.LEFT)
Example #29
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def context_menu(self, event): modifier = TkUtil.menu_modifier() menu = tk.Menu(self.master) if self.editor.text.tag_ranges(tk.SEL): menu.add_command(label=COPY, underline=0, command=lambda: self.editor.text.event_generate( "<<Copy>>"), image=self.menuImages[COPY], compound=tk.LEFT, accelerator=modifier + "+C") menu.add_command(label=CUT, underline=2, command=lambda: self.editor.text.event_generate( "<<Cut>>"), image=self.menuImages[CUT], compound=tk.LEFT, accelerator=modifier + "+X") menu.add_command(label=PASTE, underline=0, command=lambda: self.editor.text.event_generate( "<<Paste>>"), image=self.menuImages[PASTE], compound=tk.LEFT, accelerator=modifier + "+V") menu.add_separator() menu.add_checkbutton(label=BOLD, underline=0, image=self.menuImages[BOLD], compound=tk.LEFT, variable=self.bold, command=lambda: self.toggle_button(self.boldButton)) menu.add_checkbutton(label=ITALIC, underline=0, image=self.menuImages[ITALIC], compound=tk.LEFT, variable=self.italic, command=lambda: self.toggle_button(self.italicButton)) menu.add_separator() menu.add_radiobutton(label=ALIGN_LEFT, underline=6, image=self.menuImages[ALIGNLEFT], compound=tk.LEFT, variable=self.alignment, value=tk.LEFT, command=self.toggle_alignment) menu.add_radiobutton(label=ALIGN_CENTER, underline=6, image=self.menuImages[ALIGNCENTER], compound=tk.LEFT, variable=self.alignment, value=tk.CENTER, command=self.toggle_alignment) menu.add_radiobutton(label=ALIGN_RIGHT, underline=6, image=self.menuImages[ALIGNRIGHT], compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT, command=self.toggle_alignment) menu.tk_popup(event.x_root, event.y_root)
Example #30
Source File: Preferences.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_widgets(self, master): self.frame = ttk.Frame(master) self.columnsLabel = TkUtil.Label(self.frame, text="Columns", underline=2) self.columnsSpinbox = Spinbox(self.frame, textvariable=self.columns, from_=Board.MIN_COLUMNS, to=Board.MAX_COLUMNS, width=3, justify=tk.RIGHT, validate="all") self.columnsSpinbox.config(validatecommand=( self.columnsSpinbox.register(self.validate_int), "columnsSpinbox", "%P")) self.rowsLabel = TkUtil.Label(self.frame, text="Rows", underline=0) self.rowsSpinbox = Spinbox(self.frame, textvariable=self.rows, from_=Board.MIN_ROWS, to=Board.MAX_ROWS, width=3, justify=tk.RIGHT, validate="all") self.rowsSpinbox.config(validatecommand=( self.rowsSpinbox.register(self.validate_int), "rowsSpinbox", "%P")) self.maxColorsLabel = TkUtil.Label(self.frame, text="Max. Colors", underline=0) self.maxColorsSpinbox = Spinbox(self.frame, textvariable=self.maxColors, from_=Board.MIN_MAX_COLORS, to=Board.MAX_MAX_COLORS, width=3, justify=tk.RIGHT, validate="all") self.maxColorsSpinbox.config(validatecommand=( self.maxColorsSpinbox.register(self.validate_int), "maxColorsSpinbox", "%P"))