Python ttk.Notebook() Examples

The following are 17 code examples of ttk.Notebook(). 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 ttk , or try the search function .
Example #1
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 #2
Source File: myNotebook.py    From EDMarketConnector with GNU General Public License v2.0 7 votes vote down vote up
def __init__(self, master=None, **kw):

        ttk.Notebook.__init__(self, master, **kw)
        style = ttk.Style()

        if platform=='darwin':
            if map(int, mac_ver()[0].split('.')) >= [10,10]:
                # Hack for tab appearance with 8.5 on Yosemite & El Capitan. For proper fix see
                # https://github.com/tcltk/tk/commit/55c4dfca9353bbd69bbcec5d63bf1c8dfb461e25
                style.configure('TNotebook.Tab', padding=(12,10,12,2))
                style.map('TNotebook.Tab', foreground=[('selected', '!background', 'systemWhite')])
            self.grid(sticky=tk.NSEW)	# Already padded apropriately
        elif platform == 'win32':
            style.configure('nb.TFrame',                          background=PAGEBG)
            style.configure('nb.TButton',                         background=PAGEBG)
            style.configure('nb.TCheckbutton', foreground=PAGEFG, background=PAGEBG)
            style.configure('nb.TMenubutton',  foreground=PAGEFG, background=PAGEBG)
            style.configure('nb.TRadiobutton', foreground=PAGEFG, background=PAGEBG)
            self.grid(padx=10, pady=10, sticky=tk.NSEW)
        else:
            self.grid(padx=10, pady=10, sticky=tk.NSEW) 
Example #3
Source File: createHitbox.py    From universalSmashSystem with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,_parent):
        dataSelector.dataLine.__init__(self, _parent, _parent.interior, 'Create Hitbox')
        
        self.hitbox = None
        
        self.name_data = StringVar()
        self.name_entry = Entry(self,textvariable=self.name_data)
        
        self.hitboxPropertiesPanel = ttk.Notebook(self)
        
        self.properties_frame = HitboxPropertiesFrame(self.hitboxPropertiesPanel)
        self.damage_frame = HitboxDamageFrame(self.hitboxPropertiesPanel)
        self.charge_frame = HitboxChargeFrame(self.hitboxPropertiesPanel)
        override_frame = ttk.Frame(self.hitboxPropertiesPanel)
        autolink_frame = ttk.Frame(self.hitboxPropertiesPanel)
        funnel_frame = ttk.Frame(self.hitboxPropertiesPanel)
        
        self.hitboxPropertiesPanel.add(self.properties_frame,text="Properties")
        self.hitboxPropertiesPanel.add(self.damage_frame,text="Damage")
        self.hitboxPropertiesPanel.add(self.charge_frame,text="Charge")
        
        self.name_data.trace('w', self.changeVariable) 
Example #4
Source File: tkk_tab.py    From PCWG with MIT License 6 votes vote down vote up
def demo():
    root = tk.Tk()
    root.title("ttk.Notebook")

    nb = ttk.Notebook(root)

    # adding Frames as pages for the ttk.Notebook 
    # first page, which would get widgets gridded into it
    page1 = ttk.Frame(nb)

    # second page
    page2 = ttk.Frame(nb)

    nb.add(page1, text='One')
    nb.add(page2, text='Two')

    nb.pack(expand=1, fill="both")

    root.mainloop() 
Example #5
Source File: tkinter.py    From peniot with MIT License 6 votes vote down vote up
def __init__(self, parent_window):
        Frame.__init__(self, parent_window)
        # Configure the window
        self.configure(background=window_background_color)
        # Create the header
        Header(self).grid(row=0, columnspan=4)

        s = ttk.Style()
        s.configure(".", font=("Arial", 15))

        tab_control = ttk.Notebook(self)
        attack_tab = TabFrame(tab_control, ExportOptions.ATTACK)
        tab_control.add(attack_tab, text="Attack")

        attacksuite_tab = TabFrame(tab_control, ExportOptions.ATTACK_SUITE)
        tab_control.add(attacksuite_tab, text="Attack Suite")

        protocol_tab = TabFrame(tab_control, ExportOptions.PROTOCOL)
        tab_control.add(protocol_tab, text="Protocol")

        tab_control.grid(row=1, column=0, columnspan=4, rowspan=3, sticky=W + E + S + N)
        CustomButton(self, back_to_menu_label, lambda: change_frame(self, ExtensionPage(root)), 7, None, E, 1)
        self.grid() 
Example #6
Source File: test_widgets.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs) 
Example #7
Source File: plot.py    From evo_slam with GNU General Public License v3.0 5 votes vote down vote up
def tabbed_tk_window(self):
        from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
        import sys
        if sys.version_info[0] < 3:
            import Tkinter as tkinter
            import ttk
        else:
            import tkinter
            from tkinter import ttk
        self.root_window = tkinter.Tk()
        self.root_window.title(self.title)
        # quit if the window is deleted
        self.root_window.protocol("WM_DELETE_WINDOW", self.root_window.quit)
        nb = ttk.Notebook(self.root_window)
        nb.grid(row=1, column=0, sticky='NESW')
        for name, fig in self.figures.items():
            fig.tight_layout()
            tab = ttk.Frame(nb)
            canvas = FigureCanvasTkAgg(self.figures[name], master=tab)
            canvas.draw()
            canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH,
                                        expand=True)
            toolbar = NavigationToolbar2Tk(canvas, tab)
            toolbar.update()
            canvas._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH,
                                  expand=True)
            for axes in fig.get_axes():
                if isinstance(axes, Axes3D):
                    # must explicitly allow mouse dragging for 3D plots
                    axes.mouse_init()
            nb.add(tab, text=name)
        nb.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)
        self.root_window.mainloop()
        self.root_window.destroy() 
Example #8
Source File: pcwg_tool_reborn.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, parent):

        self.loadImages()

        #add notebook (holds tabs)
        self.nb = ttk.Notebook(parent)
        self.nb.pressed_index = None 
Example #9
Source File: pcwg_tool_reborn.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, parent, console):

        self.console = console
        self.loadImages()

        self.style = self.createClosableTabStyle()

        parent.bind_class("TNotebook", "<ButtonPress-1>", self.btn_press, True)
        parent.bind_class("TNotebook", "<ButtonRelease-1>", self.btn_release)

        #add notebook (holds tabs)
        self.nb = ttk.Notebook(parent, style="ButtonNotebook")
        self.nb.pressed_index = None

        self.tabs = {} 
Example #10
Source File: closable_Tab_with_menu.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, parent):

        self.loadImages()

        #add notebook (holds tabs)
        self.nb = ttk.Notebook(parent)
        self.nb.pressed_index = None 
Example #11
Source File: closable_Tab_with_menu.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, parent, console):

        self.console = console
        self.loadImages()

        self.style = self.createClosableTabStyle()

        parent.bind_class("TNotebook", "<ButtonPress-1>", self.btn_press, True)
        parent.bind_class("TNotebook", "<ButtonRelease-1>", self.btn_release)

        #add notebook (holds tabs)
        self.nb = ttk.Notebook(parent, style="ButtonNotebook")
        self.nb.pressed_index = None

        self.tabs = {} 
Example #12
Source File: builderWindow.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,_parent,_root):
        ttk.Notebook.__init__(self, _parent)
        self.root = _root
        
        fighter_properties = FighterPropertiesPanel(self,_root)
        fighter_actions = ActionListPanel(self,_root)
        
        
        self.panel_windows = {
            'Properties': fighter_properties,
            'Actions': fighter_actions
            }
        
        for name,window in self.panel_windows.iteritems():
            self.add(window,text=name,sticky=N+S+E+W) 
Example #13
Source File: plot.py    From evo with GNU General Public License v3.0 5 votes vote down vote up
def tabbed_tk_window(self):
        from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
        import sys
        if sys.version_info[0] < 3:
            import Tkinter as tkinter
            import ttk
        else:
            import tkinter
            from tkinter import ttk
        self.root_window = tkinter.Tk()
        self.root_window.title(self.title)
        # quit if the window is deleted
        self.root_window.protocol("WM_DELETE_WINDOW", self.root_window.quit)
        nb = ttk.Notebook(self.root_window)
        nb.grid(row=1, column=0, sticky='NESW')
        for name, fig in self.figures.items():
            fig.tight_layout()
            tab = ttk.Frame(nb)
            canvas = FigureCanvasTkAgg(self.figures[name], master=tab)
            canvas.draw()
            canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH,
                                        expand=True)
            toolbar = NavigationToolbar2Tk(canvas, tab)
            toolbar.update()
            canvas._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH,
                                  expand=True)
            for axes in fig.get_axes():
                if isinstance(axes, Axes3D):
                    # must explicitly allow mouse dragging for 3D plots
                    axes.mouse_init()
            nb.add(tab, text=name)
        nb.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)
        self.root_window.mainloop()
        self.root_window.destroy() 
Example #14
Source File: test_widgets.py    From oss-ftp with MIT License 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs) 
Example #15
Source File: test_widgets.py    From BinderFilter with MIT License 5 votes vote down vote up
def setUp(self):
        support.root_deiconify()
        self.nb = ttk.Notebook(padding=0)
        self.child1 = ttk.Label()
        self.child2 = ttk.Label()
        self.nb.add(self.child1, text='a')
        self.nb.add(self.child2, text='b') 
Example #16
Source File: DICAT.py    From DICAT with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master, side=LEFT):

        self.dir_opt = {}

        # Title of the application
        master.title("DICAT")

        # Use notebook (nb) from ttk from Tkinter to create tabs
        self.nb = ttk.Notebook(master)

        # Add frames as pages for ttk.Notebook
        self.page1 = ttk.Frame(self.nb)

        # Second page, DICOM anonymizer
        self.page2 = ttk.Frame(self.nb)

        # Third page, Scheduler
        self.page3 = ttk.Frame(self.nb)

        # Fourth page, ID key
        self.page4 = ttk.Frame(self.nb)

        # Add the pages to the notebook
        self.nb.add(self.page1, text='Welcome to DicAT!')
        self.nb.add(self.page2, text='DICOM de-identifier')
        self.nb.add(self.page3, text='Scheduler', state='hidden') # hide scheduler for now
        self.nb.add(self.page4, text='ID key')

        # Draw
        self.nb.pack(expand=1, fill='both')

        # Draw content of the different tabs' frame
        self.dicom_deidentifier_tab()
        self.id_key_frame()
        self.welcome_page() 
Example #17
Source File: builderWindow.py    From universalSmashSystem with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self,_parent,_root):
        BuilderPanel.__init__(self, _parent, _root)
        self.config(bg="red",height=200)
        self.selected = None
        self.parent.subaction_panel.selected_string.trace('w',self.onSelect)
        
        self.new_subaction_frame = ttk.Notebook(self)
        
        self.control_window = ttk.Frame(self.new_subaction_frame)
        self.sprite_window = ttk.Frame(self.new_subaction_frame)
        self.behavior_window = ttk.Frame(self.new_subaction_frame)
        self.hitbox_window = ttk.Frame(self.new_subaction_frame)
        self.article_window = ttk.Frame(self.new_subaction_frame)
        
        subact_windows = {'Control': self.control_window,
                         'Sprite': self.sprite_window,
                         'Behavior': self.behavior_window,
                         'Hitbox': self.hitbox_window,
                         'Article': self.article_window
                         }
        
        for name,window in subact_windows.iteritems():
            self.new_subaction_frame.add(window,text=name)
            
        subaction_lists = {'Control':[],
                          'Sprite':[],
                          'Behavior':[],
                          'Hitbox':[],
                          'Article':[]}
        
        for name,subact in engine.subaction.SubactionFactory.subaction_dict.iteritems():
            if subact.subact_group in subact_windows.keys():
                short_name = (name[:19] + '..') if len(name) > 22 else name
                button = Button(subact_windows[subact.subact_group],text=short_name,command=lambda subaction=subact: self.addSubaction(subaction))
                subaction_lists[subact.subact_group].append(button)
                
        for group in subaction_lists.values():
            x = 0
            y = 0
            for button in group:
                button.grid(row=y,column=x,sticky=E+W)
                x += 1
                if x > 1:
                    y += 1
                    x = 0
        
        self.sub_frame = self.new_subaction_frame
        self.sub_frame.pack(fill=BOTH)