Python tkinter.ttk.Frame() Examples

The following are 30 code examples of tkinter.ttk.Frame(). 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.ttk , or try the search function .
Example #1
Source File: program12.py    From python-gui-demos with MIT License 10 votes vote down vote up
def __init__(self, master):
        self.master = master
        self.notebk = ttk.Notebook(self.master)
        self.notebk.pack()
        self.frame1 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
        self.frame2 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
        self.notebk.add(self.frame1, text = 'One')
        self.notebk.add(self.frame2, text = 'Two')
        
        self.btn = ttk.Button(self.frame1, text='Add/Insert Tab at Position 1', command = self.AddTab)
        self.btn.pack()
        
        self.btn2 = ttk.Button(self.frame1, text='Disable Tab at Position 1', command = self.disableTab)
        self.btn2.pack()

        strdisplay = r'Tab ID:{}'.format(self.notebk.select())
        ttk.Label(self.frame1, text = strdisplay).pack()
        
        strdisplay2 = 'Tab index:{}'.format(self.notebk.index(self.notebk.select()))
        ttk.Label(self.frame1, text = strdisplay2).pack() 
Example #2
Source File: annotation_gui.py    From SEM with MIT License 9 votes vote down vote up
def preferences(self, event=None):
        preferenceTop = tkinter.Toplevel()
        preferenceTop.focus_set()
        
        notebook = ttk.Notebook(preferenceTop)
        
        frame1 = ttk.Frame(notebook)
        notebook.add(frame1, text='general')
        frame2 = ttk.Frame(notebook)
        notebook.add(frame2, text='shortcuts')

        c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word)
        c.pack()
        
        shortcuts_vars = []
        shortcuts_gui = []
        cur_row = 0
        j = -1
        frame_list = []
        frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts"))
        frame_list[-1].pack(fill="both", expand="yes")
        for i, shortcut in enumerate(self.shortcuts):
            j += 1
            key, cmd, bindings = shortcut
            name, command = cmd
            shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key))
            tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W)
            entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j])
            entry.grid(row=cur_row, column=1)
            cur_row += 1
        notebook.pack()
    
    #
    # ? menu methods
    # 
Example #3
Source File: components.py    From SEM with MIT License 8 votes vote down vote up
def __init__(self, root, resource_dir):
        ttk.Frame.__init__(self, root)
        
        self.master_selector = None
        self.resource_dir = resource_dir
        self.items = os.listdir(os.path.join(self.resource_dir, "master"))
        
        self.cur_lang = tkinter.StringVar()
        self.select_lang_label = ttk.Label(root, text=u"select language:")
        self.langs = ttk.Combobox(root, textvariable=self.cur_lang)
        
        self.langs["values"] = self.items

        self.langs.current(0)
        for i, item in enumerate(self.items):
            if item == "fr":
                self.langs.current(i)
        
        self.langs.bind("<<ComboboxSelected>>", self.select_lang) 
Example #4
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 7 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1) 
Example #5
Source File: opcodes.py    From brownie with MIT License 6 votes vote down vote up
def __init__(self, parent, columns, **kwargs):
        self._last = set()
        self._seek_buffer = ""
        self._seek_last = 0
        self._highlighted = set()
        self._frame = ttk.Frame(parent)
        super().__init__(
            self._frame, columns=[i[0] for i in columns[1:]], selectmode="browse", **kwargs
        )
        self.pack(side="left", fill="y")
        self.heading("#0", text=columns[0][0])
        self.column("#0", width=columns[0][1])
        for tag, width in columns[1:]:
            self.heading(tag, text=tag)
            self.column(tag, width=width)

        scroll = ttk.Scrollbar(self._frame)
        scroll.pack(side="right", fill="y")

        self.configure(yscrollcommand=scroll.set)
        scroll.configure(command=self.yview)

        self.tag_configure("NoSource", background="#161616")
        self.bind("<<TreeviewSelect>>", self._select_bind)

        root = self.root = self._root()
        root.bind("j", self._highlight_jumps)
        root.bind("r", self._highlight_revert)
        self.bind("<3>", self._highlight_opcode)
        for i in range(10):
            root.bind(str(i), self._seek) 
Example #6
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_main_frame(self):
        main = ttk.Frame(master=self, padding=STANDARD_MARGIN)
        main.grid(row=0, column=0, sticky='nsew')
        self.create_parameters_frame(main)
        self.create_buttons_frame(main)
        main.pack() 
Example #7
Source File: program11.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.master = master
        self.panedWindow = ttk.Panedwindow(self.master, orient = tk.HORIZONTAL)  # orient panes horizontally next to each other
        self.panedWindow.pack(fill = tk.BOTH, expand = True)    # occupy full master window and enable expand property
        
        self.frame1 = ttk.Frame(self.panedWindow, width = 100, height = 300, relief = tk.SUNKEN)
        self.frame2 = ttk.Frame(self.panedWindow, width = 400, height = 400, relief = tk.SUNKEN)
        
        self.panedWindow.add(self.frame1, weight = 1)
        self.panedWindow.add(self.frame2, weight = 3)
        
        self.button = ttk.Button(self.frame1, text = 'Add frame in Paned Window', command = self.AddFrame)
        self.button.pack() 
Example #8
Source File: program11.py    From python-gui-demos with MIT License 6 votes vote down vote up
def AddFrame(self):
        if self.button['text']=='Add frame in Paned Window':
            self.frame3 = ttk.Frame(self.panedWindow, width = 50, height=400, relief = tk.SUNKEN)
            self.panedWindow.insert(1, self.frame3)     # default weight=0
            self.button.config(text = 'Remove/Forget Added Frame')
        else:
            self.panedWindow.forget(1)
            self.button.config(text = 'Add frame in Paned Window') 
Example #9
Source File: program12.py    From python-gui-demos with MIT License 6 votes vote down vote up
def AddTab(self):
        if self.btn['text'] == 'Add/Insert Tab at Position 1':
            self.frame3 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
            self.notebk.insert(1, self.frame3, text = 'Additional Tab')
            self.btn.config(text = 'Remove/Forget Tab')
        else:
            self.notebk.forget(1)
            self.btn.config(text = 'Add/Insert Tab at Position 1') 
Example #10
Source File: program9.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.frame = ttk.Frame(master, width = 100, height = 100)   # frame height and width are in pixel
        self.frame.pack()
        self.frame.config(relief = tk.RAISED)   # to define frame boarder
        self.button = ttk.Button(self.frame, text = 'Click for Magic')
        self.button.config(command = self.performMagic)
        self.button.grid()  # use grid geometry manager
        self.frame.config(padding = (30,15))
        
        self.lbfrm = ttk.LabelFrame(master, width = 100, height = 100)
        self.lbfrm.config(padding = (30, 15))
        self.lbfrm.config(text = "Magic Below")
        self.lbfrm.pack()
        self.label = ttk.Label(self.lbfrm, text = "Waiting for Magic")
        self.label.grid() 
Example #11
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
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 #12
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def show_friends(self):
        self.configure(menu=self.menu)
        self.login_frame.pack_forget()

        self.canvas = tk.Canvas(self, bg="white")
        self.canvas_frame = tk.Frame(self.canvas)

        self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.scrollbar.set)

        self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)
        self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)

        self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw")

        self.bind_events()

        self.load_friends() 
Example #13
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)
        self.username_entry.focus_force()

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1)

        self.login_event = self.bind("<Return>", self.login) 
Example #14
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
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 #15
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.title('Tk Chat')
        self.geometry('700x500')

        self.menu = tk.Menu(self, bg="lightgrey", fg="black", tearoff=0)

        self.friends_menu = tk.Menu(self.menu, fg="black", bg="lightgrey", tearoff=0)
        self.friends_menu.add_command(label="Add Friend", command=self.add_friend)

        self.menu.add_cascade(label="Friends", menu=self.friends_menu)

        self.configure(menu=self.menu)

        self.canvas = tk.Canvas(self, bg="white")
        self.canvas_frame = tk.Frame(self.canvas)

        self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.scrollbar.set)

        self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)
        self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)

        self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw")

        self.bind_events()

        self.load_friends() 
Example #16
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
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 #17
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def show_friends(self):
        self.configure(menu=self.menu)
        self.login_frame.pack_forget()

        self.canvas = tk.Canvas(self, bg="white")
        self.canvas_frame = tk.Frame(self.canvas)

        self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.scrollbar.set)

        self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)
        self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)

        self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw")

        self.bind_events()

        self.load_friends() 
Example #18
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_parameters_frame(self, parent):
        parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        parameters.grid(sticky='nsew')

        heading = ttk.Label(parameters, text='Analysis parameters')
        heading.grid(column=0, row=0, sticky='n')

        for i, param in enumerate(self.parameters, start=1):
            param_label = ttk.Label(parameters, text=param._name)
            param_label.grid(row=i, column=0, sticky='nsew')
            if type(param) == tk.BooleanVar:
                param_entry = ttk.Checkbutton(parameters, variable=param)
            elif hasattr(param, '_choices'):
                param_entry = ttk.OptionMenu(parameters, param, param.get(),
                                             *param._choices.keys())
            else:
                param_entry = ttk.Entry(parameters, textvariable=param)
            param_entry.grid(row=i, column=1, sticky='nsew') 
Example #19
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_buttons_frame(self, parent):
        buttons = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        buttons.grid(sticky='nsew')
        actions = [
            ('Choose config', self.choose_config_file),
            ('Choose files', self.choose_input_files),
            ('Choose output folder', self.choose_output_folder),
            ('Run', lambda: asyncio.ensure_future(self.run()))
        ]
        for col, (action_name, action) in enumerate(actions):
            button = ttk.Button(buttons, text=action_name,
                                command=action)
            button.grid(row=0, column=col) 
Example #20
Source File: Preferences.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_widgets(self, master):
        self.frame = ttk.Frame(master)
        self.restoreFrame = ttk.Labelframe(self.frame, text="Restore")
        self.restoreWindowCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Window Position and Size",
                underline=0, variable=self.restoreWindow)
        TkUtil.Tooltip.Tooltip(self.restoreWindowCheckbutton,
                "Restore Toolbars and Window Position and Size at Startup")
        self.restoreFontCheckbutton = TkUtil.Checkbutton(self.restoreFrame,
                text="Font Settings", underline=0,
                variable=self.restoreFont)
        TkUtil.Tooltip.Tooltip(self.restoreFontCheckbutton,
                "Restore the Last Used Font Settings at Startup")
        self.restoreSessionCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Session", underline=0,
                variable=self.restoreSession)
        TkUtil.Tooltip.Tooltip(self.restoreSessionCheckbutton,
                "Open the Last Edited File at Startup")
        self.otherFrame = ttk.Labelframe(self.frame, text="Other")
        self.blinkCheckbutton = TkUtil.Checkbutton(self.otherFrame,
                text="Blinking Cursor", underline=0, variable=self.blink)
        TkUtil.Tooltip.Tooltip(self.blinkCheckbutton,
                "Switch Cursor Blink On or Off") 
Example #21
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_statusbar(self):
        statusBar = ttk.Frame(self.master)
        statusLabel = ttk.Label(statusBar, textvariable=self.statusText)
        statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E))
        self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.modifiedLabel,
                text="MOD if the text has unsaved changes")
        self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E),
                pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.positionLabel,
                text="Current line and column position")
        ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E))
        statusBar.columnconfigure(0, weight=1)
        statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E))
        self.set_status_text("Start typing to create a new document or "
                "click Fileā†’Open") 
Example #22
Source File: Preferences.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_widgets(self, master):
        self.frame = ttk.Frame(master)
        self.restoreFrame = ttk.Labelframe(self.frame, text="Restore")
        self.restoreWindowCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Window Position and Size",
                underline=0, variable=self.restoreWindow)
        TkUtil.Tooltip.Tooltip(self.restoreWindowCheckbutton,
                "Restore Toolbars and Window Position and Size at Startup")
        self.restoreFontCheckbutton = TkUtil.Checkbutton(self.restoreFrame,
                text="Font Settings", underline=0,
                variable=self.restoreFont)
        TkUtil.Tooltip.Tooltip(self.restoreFontCheckbutton,
                "Restore the Last Used Font Settings at Startup")
        self.restoreSessionCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Session", underline=0,
                variable=self.restoreSession)
        TkUtil.Tooltip.Tooltip(self.restoreSessionCheckbutton,
                "Open the Last Edited File at Startup")
        self.otherFrame = ttk.Labelframe(self.frame, text="Other")
        self.blinkCheckbutton = TkUtil.Checkbutton(self.otherFrame,
                text="Blinking Cursor", underline=0, variable=self.blink)
        TkUtil.Tooltip.Tooltip(self.blinkCheckbutton,
                "Switch Cursor Blink On or Off") 
Example #23
Source File: Dialog.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def button_box(self, master):
        """Override to create the dialog's buttons; you must return the
        containing widget"""
        frame = ttk.Frame(master)
        if self.buttons & OK_BUTTON:
            self.acceptButton = self.add_button(frame, "OK", 0, self.__ok,
                    self.default == OK_BUTTON, "<Alt-o>")
        if self.buttons & CANCEL_BUTTON:
            self.add_button(frame, "Cancel", 0, self.__cancel,
                    self.default == CANCEL_BUTTON, "<Alt-c>")
        if self.buttons & YES_BUTTON:
            self.acceptButton = self.add_button(frame, "Yes", 0, self.__ok,
                    self.default == YES_BUTTON, "<Alt-y>")
        if self.buttons & NO_BUTTON:
            self.add_button(frame, "No", 0, self.__cancel,
                    self.default == NO_BUTTON, "<Alt-n>")
        self.bind("<Return>", self.__ok, "+")
        self.bind("<Escape>", self.__cancel, "+")
        return frame 
Example #24
Source File: Dock.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def __create_widgets(self):
        self.dockFrame = ttk.Frame(self, relief=tk.RAISED, padding=PAD)
        self.dockLeftButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKLEFT], style="Toolbutton",
                command=self.dock_left)
        TkUtil.Tooltip.Tooltip(self.dockLeftButton, text="Dock Left")
        self.dockRightButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKRIGHT], style="Toolbutton",
                command=self.dock_right)
        TkUtil.Tooltip.Tooltip(self.dockRightButton, text="Dock Right")
        self.dockLabel = ttk.Label(self.dockFrame, text=self.title,
                anchor=tk.CENTER)
        TkUtil.Tooltip.Tooltip(self.dockLabel, text="Drag and drop to "
                "dock elsewhere or to undock")
        self.undockButton = ttk.Button(self.dockFrame,
                image=self.images[UNDOCK], style="Toolbutton",
                command=self.undock)
        TkUtil.Tooltip.Tooltip(self.undockButton, text="Undock")
        self.hideButton = ttk.Button(self.dockFrame,
                image=self.images[HIDE], style="Toolbutton",
                command=lambda *args: self.visible.set(False))
        TkUtil.Tooltip.Tooltip(self.hideButton, text="Hide")
        self.create_widgets() 
Example #25
Source File: tickscale.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def _apply_style(self):
        """Apply the scale style to the frame and labels."""
        ttk.Frame.configure(self, style=self._style_name + ".TFrame")
        self.label.configure(style=self._style_name + ".TLabel")
        bg = self.style.lookup('TFrame', 'background', default='light grey')
        for label in self.ticklabels:
            label.configure(style=self._style_name + ".TLabel")
        self.style.configure(self._style_name + ".TFrame",
                             background=self.style.lookup(self._style_name,
                                                          'background',
                                                          default=bg))
        self.style.map(self._style_name + ".TFrame",
                       background=self.style.map(self._style_name, 'background'))
        self.style.configure(self._style_name + ".TLabel",
                             font=self.style.lookup(self._style_name, 'font', default='TkDefaultFont'),
                             background=self.style.lookup(self._style_name, 'background', default=bg),
                             foreground=self.style.lookup(self._style_name, 'foreground', default='black'))
        self.style.map(self._style_name + ".TLabel",
                       font=self.style.map(self._style_name, 'font'),
                       background=self.style.map(self._style_name, 'background'),
                       foreground=self.style.map(self._style_name, 'foreground')) 
Example #26
Source File: selectframe.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, master=None, callback=None, **kwargs):
        """
        :param master: master widget
        :type master: widget
        :param callback: callback passed argument
                         (`str` family, `int` size, `bool` bold, `bool` italic, `bool` underline)
        :type callback: function
        :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
        """
        ttk.Frame.__init__(self, master, **kwargs)
        self.__callback = callback
        self._family = None
        self._size = 11
        self._bold = False
        self._italic = False
        self._underline = False
        self._overstrike = False
        self._family_dropdown = FontFamilyDropdown(self, callback=self._on_family)
        self._size_dropdown = FontSizeDropdown(self, callback=self._on_size, width=4)
        self._properties_frame = FontPropertiesFrame(self, callback=self._on_properties, label=False)
        self._grid_widgets() 
Example #27
Source File: toggledframe.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, master=None, text="", width=20, compound=tk.LEFT, **kwargs):
        """
        Create a ToggledFrame.

        :param master: master widget
        :type master: widget
        :param text: text to display next to the toggle arrow
        :type text: str
        :param width: width of the closed ToggledFrame (in characters)
        :type width: int
        :param compound: "center", "none", "top", "bottom", "right" or "left":
                         position of the toggle arrow compared to the text
        :type compound: str
        :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
        """
        ttk.Frame.__init__(self, master, **kwargs)
        self._open = False
        self.__checkbutton_var = tk.BooleanVar()
        self._open_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "open.png")))
        self._closed_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "closed.png")))
        self._checkbutton = ttk.Checkbutton(self, style="Toolbutton", command=self.toggle,
                                            variable=self.__checkbutton_var, text=text, compound=compound,
                                            image=self._closed_image, width=width)
        self.interior = ttk.Frame(self, relief=tk.SUNKEN)
        self._grid_widgets() 
Example #28
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def display_tab2():
    monty2 = ttk.LabelFrame(display_area, text=' Holy Grail ')
    monty2.grid(column=0, row=0, padx=8, pady=4)
    
    # Creating three checkbuttons
    chVarDis = tk.IntVar()
    check1 = tk.Checkbutton(monty2, text="Disabled", variable=chVarDis, state='disabled')
    check1.select()
    check1.grid(column=0, row=0, sticky=tk.W)                 
    
    chVarUn = tk.IntVar()
    check2 = tk.Checkbutton(monty2, text="UnChecked", variable=chVarUn)
    check2.deselect()
    check2.grid(column=1, row=0, sticky=tk.W )                  
     
    chVarEn = tk.IntVar()
    check3 = tk.Checkbutton(monty2, text="Toggle", variable=chVarEn)
    check3.deselect()
    check3.grid(column=2, row=0, sticky=tk.W)                 

    # Create a container to hold labels
    labelsFrame = ttk.LabelFrame(monty2, text=' Labels in a Frame ')
    labelsFrame.grid(column=0, row=7)
     
    # Place labels into the container element - vertically
    ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
    ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)
    
    # Add some space around each label
    for child in labelsFrame.winfo_children(): 
        child.grid_configure(padx=8)
        
#------------------------------------------ 
Example #29
Source File: GUI.py    From nekros with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _create_container(func):
    '''Creates a ttk Frame with a given master, and use this new frame to
    place the scrollbars and the widget.'''
    def wrapped(cls, master, **kw):
        container = ttk.Frame(master)
        container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
        container.bind('<Leave>', lambda e: _unbound_to_mousewheel(e, container))
        return func(cls, container, **kw)
    return wrapped 
Example #30
Source File: GUI_Not_OOP.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def createWidgets():    
    tabControl = ttk.Notebook(win)     
    tab1 = ttk.Frame(tabControl)            
    tabControl.add(tab1, text='Tab 1')    
    tabControl.pack(expand=1, fill="both")  
    monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)        
    
    ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
    name = tk.StringVar()
    nameEntered = ttk.Entry(monty, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1, sticky='W')
    
    action = ttk.Button(monty, text="Click Me!")   
    action.grid(column=2, row=1)
    
    ttk.Label(monty, text="Choose a number:").grid(column=1, row=0)
    number = tk.StringVar()
    numberChosen = ttk.Combobox(monty, width=12, textvariable=number)
    numberChosen['values'] = (42)
    numberChosen.grid(column=1, row=1)
    numberChosen.current(0)
    
    scrolW = 30; scrolH = 3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)
    
    menuBar = Menu(tab1)
    win.config(menu=menuBar)
    fileMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="File", menu=fileMenu)
    helpMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="Help", menu=helpMenu)
    
    nameEntered.focus()     
#======================