Python tkinter.ttk 模块,Notebook() 实例源码

我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用tkinter.ttk.Notebook()

项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        

        scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD)
        scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.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)

        self.createButtons()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def notebook_callback(event):
    clear_display_area()

    current_notebook = str(event.widget)
    tab_no = str(event.widget.index("current") + 1)   

    if current_notebook.endswith('notebook'):
        active_notebook = 'Notebook 1'
    elif current_notebook.endswith('notebook2'):
        active_notebook = 'Notebook 2'
    else:
        active_notebook = ''

    if active_notebook is 'Notebook 1':  
        if   tab_no == '1': display_tab1()
        elif tab_no == '2': display_tab2()
        elif tab_no == '3': display_tab3()
        else: display_button(active_notebook, tab_no)
    else:
        display_button(active_notebook, tab_no)


#-----------------------------------------------------------
#  Create GUI
#-----------------------------------------------------------
项目:DnD    作者:the-nick-of-time    | 项目源码 | 文件源码
def __init__(self, window):
        self.container = window
        self.buttons = tk.Frame(window)
        self.QUIT = tk.Button(self.buttons, text='QUIT', fg='red',
                              command=self.writequit)
        self.long_rest = tk.Button(self.buttons, text='Long rest',
                                   command=lambda: self.rest('long'))
        self.short_rest = tk.Button(self.buttons, text='Short rest',
                                    command=lambda: self.rest('short'))
        self.next_turn = tk.Button(self.buttons, text='Next turn',
                                   command=lambda: self.rest('turn'))
        self.core = ttk.Notebook(window)
        self.core.bind("<<NotebookTabChanged>>", self.tab_update)
        ######
        self.frontpage = tk.Frame(self.core)
        self.featurespage = tk.Frame(self.core)
        self.attackpage = tk.Frame(self.core)
        self.inventorypage = tk.Frame(self.core)
        self.spellspage = tk.Frame(self.core)
        # self.draw_static()
        self.startup_begin()
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def on_tab_changed(self, event):
        """
        Close the previous tab and initialize a new one
        :param event: tab event
        :return: None
        """
        tab_id = self.notebook.select()
        tab_index = self.notebook.index(tab_id)
        tab_name = self.notebook.tab(tab_index, "text")
        LoggerGui.debug("Notebook tab changed to \"%s\" with id %d", tab_name, tab_index)
        self.tab_id = tab_id.split(".")[len(tab_id.split(".")) - 1]  # Parse notebook/tab id to only tab id
        if self.notebook.children[self.tab_id].kill_other_tabs():
            for tab in self.notebook.children:
                if tab != self.tab_id:
                    self.notebook.children[tab].deactivate()
        self.notebook.children[self.tab_id].activate()
项目:serialplot    作者:crxguy52    | 项目源码 | 文件源码
def __init__(self, parent, controller):

        ttk.Notebook.__init__(self, parent)
        self.controller = controller

        datalist = list(range(1,7))
        datalist.insert(0,'-')

        #Create the pages
        serialcfgframe = SerialTab(self, self.controller)
        datacfgframe = DataTab(self, self.controller)
        graph1frame = GraphTab(self, self.controller, 1)
        graph2frame = GraphTab(self, self.controller, 2)
        graph3frame = GraphTab(self, self.controller, 3)

        #Add them to the notebook
        self.add(datacfgframe, text='Data')            
        self.add(serialcfgframe, text='Serial')
        self.add(graph1frame, text='Graph 1')
        self.add(graph2frame, text='Graph 2')
        self.add(graph3frame, text='Graph 3')
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, app_main, **kwargs):
        super().__init__(master, **kwargs)

        # style = Style()
        # if we do this we also need to hide the #0 column because it adds indention for possible children
        # style.configure("Treeview.Heading", padding=(10, 0))

        # self.protocol('WM_DELETE_WINDOW', self.onClose)
        # self.nb_tabs = Notebook(self)

        # self.create_iprice_tab()
        self.prices_editor = PricesEditor(self)
        self.currency_editor = CurrencyEditor(self)
        self.settings_editor = SettingsEditor(self, app_main)
        # self.add(self.frm_iprices_tab, text='Item Prices', sticky='nsew')

        self.add(self.settings_editor, text='General', sticky='nsew')
        self.add(self.prices_editor, text='Prices', sticky='nsew')
        self.add(self.currency_editor, text='Currency', sticky='nsew')
        self.bind('<<NotebookTabChanged>>', self.onTabChange)

        self.settings_editor_id, self.prices_tab_id, self.currency_tab_id = self.tabs()
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def eventViewerPlace(self):
        eventViewerFrame = ttk.Frame(self)               
        eventViewerFrame.pack(in_=self, side='top',fill='both', expand='Y')

        self.eventMainView = ttk.Notebook(eventViewerFrame, name='notebook')

        #Event Tab Text Box - Tab 0
        tab0 = ttk.Frame(self.eventMainView)
        self.eventMainView.add(tab0, text="Tasks")

        self.eventMainView.pack(fill='both', expand=Y, side='top')

        self.eventsBox = Text(tab0, wrap=WORD, width=40, height=10)
        self.eventsBox.pack(fill=BOTH, expand=Y)

        #self.eventsBox.config(state=DISABLED)


        #Note Tab Text Box - Tab 1
        tab1 = ttk.Frame(self.eventMainView)
        self.eventMainView.add(tab1, text="Notes")

        self.eventMainView.pack(fill='both', expand=Y, side='top')

        self.notesBox = Text(tab1, wrap=WORD, width=40, height=10)
        vscroll = ttk.Scrollbar(tab1, orient=VERTICAL, command=self.notesBox.yview)
        self.notesBox['yscroll'] = vscroll.set
        vscroll.pack(side=RIGHT, fill=Y)
        self.notesBox.pack(fill=BOTH, expand=Y)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs)
项目:MacroClick    作者:lkmokadam    | 项目源码 | 文件源码
def initialize(parent):
    top = parent
    nb = ttk.Notebook(top)
    nb.grid(row=0, column=0)
    return top, nb
项目:MacroClick    作者:lkmokadam    | 项目源码 | 文件源码
def create_tabs(parent, tabs_list_with_frame):
    # tabs_list_with_frame should contain list of dict contain tab name and frame
    frames_list = []
    nb = ttk.Notebook(parent)
    nb.grid(row=0, column=0)
    for element in tabs_list_with_frame:
        frame = tk.Frame()
        nb.add(frame, text=element)
        frames_list.append(frame)
    return frames_list
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
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')
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.title("Translation Book v3")
        self.geometry("500x300")

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

        self.languages_menu = tk.Menu(self.menu, tearoff=0, bg="lightgrey", fg="black")
        self.languages_menu.add_command(label="Add New", command=self.show_new_language_popup)
        self.languages_menu.add_command(label="Portuguese", command=lambda: self.add_new_tab(LanguageTab(self, "Portuguese", "pt")))

        self.menu.add_cascade(label="Languages", menu=self.languages_menu)

        self.config(menu=self.menu)

        self.notebook = Notebook(self)

        self.language_tabs = []

        english_tab = tk.Frame(self.notebook)

        self.translate_button = tk.Button(english_tab, text="Translate", command=self.translate)
        self.translate_button.pack(side=tk.BOTTOM, fill=tk.X)

        self.english_entry = tk.Text(english_tab, bg="white", fg="black")
        self.english_entry.pack(side=tk.TOP, expand=1)

        self.notebook.add(english_tab, text="English")

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.title("Translation Book v1")
        self.geometry("500x300")

        self.notebook = Notebook(self)

        english_tab = tk.Frame(self.notebook)
        italian_tab = tk.Frame(self.notebook)

        self.translate_button = tk.Button(english_tab, text="Translate", command=self.translate)
        self.translate_button.pack(side=tk.BOTTOM, fill=tk.X)

        self.english_entry = tk.Text(english_tab, bg="white", fg="black")
        self.english_entry.pack(side=tk.TOP, expand=1)

        self.italian_copy_button = tk.Button(italian_tab, text="Copy to Clipboard", command=self.copy_to_clipboard)
        self.italian_copy_button.pack(side=tk.BOTTOM, fill=tk.X)

        self.italian_translation = tk.StringVar(italian_tab)
        self.italian_translation.set("")

        self.italian_label = tk.Label(italian_tab, textvar=self.italian_translation, bg="lightgrey", fg="black")
        self.italian_label.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.notebook.add(english_tab, text="English")
        self.notebook.add(italian_tab, text="Italian")

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs)
项目:drc-sim    作者:rolandoislas    | 项目源码 | 文件源码
def __init__(self):
        """
        Main Gui Entrance
        """
        tkinter.Tk.report_callback_exception = self.throw
        # Main window
        self.destroyed = False
        LoggerGui.info("Initializing GUI")
        self.main_window = tkinter.Tk()
        self.main_window.wm_title("DRC Sim Server")
        icon = tkinter.PhotoImage(data=Resource("image/icon.gif").resource)
        self.main_window.tk.call("wm", "iconphoto", self.main_window, icon)
        self.main_window.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.main_window.resizable(False, False)
        # Notebook
        self.tab_id = None
        self.notebook = Notebook(self.main_window, width=300, height=150)
        self.notebook.grid(column=0, row=0)
        self.notebook.bind("<<NotebookTabChanged>>", self.on_tab_changed)
        # Run Server Frame
        self.frame_run_server = FrameRunServer(self.notebook)
        self.notebook.add(self.frame_run_server, text="Run Server")
        # Get Key Frame
        self.frame_get_key = FrameGetKey(self.notebook)
        self.notebook.add(self.frame_get_key, text="Get Key")
        # Log Frame
        self.frame_log = FrameLog(self.notebook)
        self.notebook.add(self.frame_log, text="Log")
        # About Frame
        self.frame_about = FrameAbout(self.notebook)
        self.notebook.add(self.frame_about, text="About")
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_notebook(self, height: int=None, padding: list=[], width: int=None, index: int or str="end", **kwargs):
        """Insert a ttk.Notebook into the game."""
        widget = ttk.Notebook(self.text, height=height, padding=padding, width=width, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Notebook(self.root, **kwargs)
项目:tkpf    作者:marczellm    | 项目源码 | 文件源码
def create(self, parent):
        return ttk.Notebook(parent)
项目:birdbody    作者:magnusnissel    | 项目源码 | 文件源码
def draw_ui(self):
        self.root.title("Birdbody - Create corpora from tweets")
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=1)
        self.grid(row=0, column=0, sticky="news")
        self.maximize()
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        # --- status bar --- #
        self.status_var = tk.StringVar()
        self.status_bar = ttk.Label(self, textvariable=self.status_var)
        self.status_bar.grid(column=0, row=1, sticky="news")
        # --- main notebook --- #
        self.book = ttk.Notebook(self)
        self.book.bind('<<NotebookTabChanged>>', self.tab_change)
        self.book.grid(column=0, row=0, sticky="news")
        self.user_tweets_frame = tk.Frame()
        self.settings_frame = tk.Frame()
        self.file_frame = tk.Frame()
        self.tweet_id_frame = tk.Frame()
        self.streaming_frame = tk.Frame()
        self.book.add(self.user_tweets_frame, text="Tweets by users")
        self.book.add(self.streaming_frame, text="Stream tweets")
        self.book.add(self.tweet_id_frame, text="Tweets by ID")
        self.book.add(self.file_frame, text="File management")
        self.book.add(self.settings_frame, text="Settings")

        self.draw_settings()
        self.draw_user_tweets()
        self.draw_tweet_id()
        self.draw_streaming()
        self.draw_file_management()
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent, discord_token, discord_client_id):
        """
        Create a new main window frame.

        Args:
            parent: A tk or ttk object
        """
        super(Frame, self).__init__(parent)

        logger.debug("Initialising frame")

        # Status bar
        statusbar = StatusBar(self)
        statusbar.grid(column=0, row=1, sticky="W E S")

        # Create the main control panel
        nav = ttk.Notebook(self)
        module_frame = ModuleFrame(nav)
        nav.add(GlobalFrame(nav, discord_token, discord_client_id, module_frame, statusbar), text="Global")
        nav.add(module_frame, text="Modules")
        nav.grid(column=0, row=0, sticky="W E N S")

        def on_closing():
            """Called when the window closes"""
            try:
                from ._client import client
                if client.loop:
                    asyncio.run_coroutine_threadsafe(client.logout(), client.loop)
            except RuntimeError:
                pass
            except Exception as e:
                logger.exception(e)

            parent.destroy()
            import sys
            sys.exit(0)

        parent.protocol("WM_DELETE_WINDOW", on_closing)

        # Configure stretch ratios
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # Welcome!
        logger.info("Welcome to Modis v{} ({})".format(datatools.version, datatools.version_nickname))
        # Update with version data
        state, response = datatools.get_compare_version()
        logger.info("{}\n".format(response))
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
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()     
#======================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        

        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')

        self.action = ttk.Button(self.monty, text="Click Me!")   
        self.action.grid(column=2, row=1)

        ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number)
        numberChosen['values'] = (42)
        numberChosen.grid(column=1, row=1)
        numberChosen.current(0)

        scrolW = 30; scrolH = 3
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.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()     
#==========================
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)

        dates_sql = "SELECT DISTINCT date FROM pymodoros ORDER BY date DESC"
        dates = self.master.runQuery(dates_sql, None, True)

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks_sql = "SELECT * FROM pymodoros WHERE date LIKE ?"
            date_like = date + "%"
            data = (date_like,)

            tasks = self.master.runQuery(tasks_sql, data, True)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))


            tree.pack(fill=tk.BOTH, expand=1)
            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)
        self.tab_trees = {}

        style = ttk.Style()
        style.configure("Treeview", font=(None,12))
        style.configure("Treeview.Heading", font=(None, 14))

        dates = self.master.get_unique_dates()

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks = self.master.get_tasks_by_date(date)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))

            tree.pack(fill=tk.BOTH, expand=1)
            tree.bind("<Double-Button-1>", self.confirm_delete)
            self.tab_trees[date] = tree

            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.title("Translation Book v2")
        self.geometry("500x300")

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

        self.languages_menu = tk.Menu(self.menu, tearoff=0, bg="lightgrey", fg="black")
        self.languages_menu.add_command(label="Portuguese", command=self.add_portuguese_tab)

        self.menu.add_cascade(label="Languages", menu=self.languages_menu)

        self.config(menu=self.menu)

        self.notebook = Notebook(self)

        english_tab = tk.Frame(self.notebook)
        italian_tab = tk.Frame(self.notebook)

        self.italian_translation = tk.StringVar(italian_tab)
        self.italian_translation.set("")

        self.translate_button = tk.Button(english_tab,
                                          text="Translate",
                                          command=lambda langs=["it"],
                                                         elems=[self.italian_translation]:
                                                            self.translate(langs, None, elems))
        self.translate_button.pack(side=tk.BOTTOM, fill=tk.X)

        self.english_entry = tk.Text(english_tab, bg="white", fg="black")
        self.english_entry.pack(side=tk.TOP, expand=1)

        self.italian_copy_button = tk.Button(italian_tab, text="Copy to Clipboard", command=self.copy_to_clipboard)
        self.italian_copy_button.pack(side=tk.BOTTOM, fill=tk.X)

        self.italian_label = tk.Label(italian_tab, textvar=self.italian_translation, bg="lightgrey", fg="black")
        self.italian_label.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.notebook.add(english_tab, text="English")
        self.notebook.add(italian_tab, text="Italian")

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)

        dates_sql = "SELECT DISTINCT date FROM pymodoros ORDER BY date DESC"
        dates = self.master.runQuery(dates_sql, None, True)

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks_sql = "SELECT * FROM pymodoros WHERE date LIKE ?"
            date_like = date + "%"
            data = (date_like,)

            tasks = self.master.runQuery(tasks_sql, data, True)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))

            tree.pack(fill=tk.BOTH, expand=1)

            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:pyTrack    作者:clamytoe    | 项目源码 | 文件源码
def main():
    """Assemble the GUI"""
    global TAB_1, TAB_2, TAB_3, TAB_4, TABS
    init_globals()

    # create window instance
    win = tk.Tk()
    win.title('Time Tracker')

    # tabs
    TABS = ttk.Notebook(win)

    TAB_1 = ttk.Frame(TABS)
    TAB_2 = ttk.Frame(TABS)
    TAB_3 = ttk.Frame(TABS)
    TAB_4 = ttk.Frame(TABS)
    TABS.add(TAB_1, text='Main')
    TABS.add(TAB_2, text='Add')
    TABS.add(TAB_3, text='Remove')
    TABS.add(TAB_4, text='About')
    TABS.pack(expand=1, fill='both')

    # setup_menu(win)
    setup_tab1(TAB_1)
    setup_tab4(TAB_4)

    # detect when the user switches between the tabs
    def tab_switch(event):
        if event.widget.identify(event.x, event.y) == 'label':
            index = event.widget.index('@%d, %d' % (event.x, event.y))
            title = event.widget.tab(index, "text")

            # only way I found to reload the tabs is to recreate them :(
            if title == 'Main':
                if not ACTIVE_PROJECT:
                    init_globals()
                    setup_tab1(TAB_1)
            elif title == 'Add':
                init_globals()
                setup_tab2(TAB_2)
            elif title == 'Remove':
                init_globals()
                setup_tab3(TAB_3)

    TABS.bind('<Button-1>', tab_switch)
    TABS.pack(fill='both', expand=True)

    # disable resizing
    win.resizable(0, 0)

    # try to keep on top
    win.wm_attributes('-topmost', 1)

    # start application
    win.mainloop()