gui.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目: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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号