当前位置: 首页>>代码示例>>Python>>正文


Python Notebook.bind方法代码示例

本文整理汇总了Python中ttk.Notebook.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Notebook.bind方法的具体用法?Python Notebook.bind怎么用?Python Notebook.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ttk.Notebook的用法示例。


在下文中一共展示了Notebook.bind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_control

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import bind [as 别名]
def show_control(master, data):
    """Выводит блокнот управления с пятью закладками"""

    if data.is_restart:
        reload(control_a)
        reload(control_b)
        reload(control_c)
        reload(control_d)
        reload(control_e)
        reload(control_f)

    from control_a import show_goods
    from control_b import show_calc
    from control_c import show_sales_goods
    from control_d import show_sales
    from control_e import show_others
    from control_f import show_plus


    def tab_changes(tab):
        """функция, срабатывающая при нажатии закладок переключения
        между правыми (основными) фреймами"""

        window_names = controlTabs.tabs()
        index = window_names.index(controlTabs.select())

        if not FLAGS[index]:
            CONTROL[index](workArea[index], data)                   #нужна ли эта дата?
            FLAGS[index] = True
        else:
            CONTROL[index].renew()


    CONTROL = (show_goods, show_calc, show_sales_goods,
               show_sales, show_others, show_plus)

    FLAGS = [False, False, False, False, False, False]

    heads = (u' Товары ', u' Калькуляции ',
             u' Акционные товары ', u' Акционные цены ',
             u' Категории, скидки, причины списания ', u' Дополнительно ')

    workArea = []

    controlTabs = Notebook(master)
    for q in range (6):
        frame = Canvas(controlTabs, relief=GROOVE, highlightthickness=0)
        if USE_BACKGROUND:
            frame.create_image(0,0, anchor='nw', image=data.photo)
        controlTabs.add(frame, text=heads[q])
        workArea.append(frame)
    controlTabs.pack(side=TOP, fill=BOTH, expand=YES)
    controlTabs.bind('<<NotebookTabChanged>>', tab_changes)
    Style().configure("TNotebook.Tab", font=('Verdana', FONT_SIZE))
开发者ID:sychov,项目名称:conditer,代码行数:56,代码来源:control.py

示例2: Application

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import bind [as 别名]
class Application(tk.Frame):
    def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.master = master
        self.master.title("Netstat Live")
        self.pack(fill=tk.BOTH, expand=tk.Y)
        
        master.protocol("WM_DELETE_WINDOW", self.app_quit)
        self._app_quit = False
        
        self._freeze = False
        
        self.tabs = Notebook(self)
        
        self.tabs_frames = OrderedDict()
        self.tabs_frames['TCP4'] = {'query': netstat_tcp4}
        self.tabs_frames['UDP4'] = {'query': netstat_udp4}
        self.tabs_frames['TCP6'] = {'query': netstat_tcp6}
        self.tabs_frames['UDP6'] = {'query': netstat_udp6}
        
        for tab in self.tabs_frames:
            # Creating tabs
            self.tabs_frames[tab]['tab'] = tk.Frame(self.tabs)
            self.tabs.add(self.tabs_frames[tab]['tab'], text=tab)
            #self.tabs_frames[tab]['tab'].pack(fill=tk.BOTH)
            # Adding Treeview widget to tabs
            self.tabs_frames[tab]['tbl'] = Treeview(self.tabs_frames[tab]['tab'])
            self.tabs_frames[tab]['tbl']['columns'] = ('Pid', 'User', 'Local addr', 'Remote addr', 'State')
            for column in self.tabs_frames[tab]['tbl']['columns']:
                self.tabs_frames[tab]['tbl'].heading(column, text=column)
                self.tabs_frames[tab]['tbl'].column(column, width=150)
            self.tabs_frames[tab]['scrollbar_y'] = Scrollbar(self.tabs_frames[tab]['tab'], orient=tk.VERTICAL, command=self.tabs_frames[tab]['tbl'].yview)
            self.tabs_frames[tab]['tbl']['yscroll'] = self.tabs_frames[tab]['scrollbar_y'].set
            self.tabs_frames[tab]['scrollbar_y'].pack(side=tk.RIGHT, fill=tk.Y)
            self.tabs_frames[tab]['tbl'].pack(expand=tk.Y, fill=tk.BOTH)
            # Bind right click event for displaying context menu
            self.tabs_frames[tab]['tbl'].bind('<Button-3>', self.context_menu_popup)
            self.tabs_frames[tab]['tbl'].bind('<Button-1>', self.context_menu_unpost)
            # Creating queue for each tab
            self.tabs_frames[tab]['queue'] = Queue(maxsize=1)
        self.tabs.pack(fill=tk.BOTH, expand=tk.Y)
        
        # Freeze button
        self.buttons = tk.Frame(master)
        self.buttons.pack(side=tk.BOTTOM, fill=tk.BOTH)
        self.freeze_btn = tk.Button(self.buttons, text='Freeze', command=self.freeze_btn_handler)
        self.freeze_btn.pack(side=tk.RIGHT)
        
        # Check dependencies
        self._xclip = True
        self._whois = True
        try:
            out = subprocess.check_output(['xclip', '-h'], stderr=subprocess.STDOUT)
        except:
            self._xclip = False
        try:
            out = subprocess.check_output(['whois', '--version'], stderr=subprocess.STDOUT)
        except:
            self._whois = False
        
        # Connections list context menu
        self._remote_addr = ''
        self.context_menu = tk.Menu(self, tearoff=0)
        if self._xclip:
            self.context_menu.add_command(label='Copy remote addr.', command=self.xclip)
        if self._whois:
            self.context_menu.add_command(label='Whois', command=self.whois)
        self.tabs.bind('<Button-1>', self.context_menu_unpost)
        
        self.poll = Thread(target=self.thread)
        self.poll.start()
        
    def context_menu_popup(self, event):
        current_tab = self.get_active_tab()
        tbl = self.tabs_frames[current_tab]['tbl']
        item = tbl.identify_row(event.y)
        if item and len(tbl.get_children(item)) == 0:
            tbl.selection_set(item)
            # Get remote addr value
            self._remote_addr = tbl.set(item, column='Remote addr')
            self.context_menu.post(event.x_root, event.y_root)
        else:
            # Mouse pointer is not over item
            pass
    
    def context_menu_unpost(self, event):
        self.context_menu.unpost()

    def get_active_tab(self):
        try:
            current_tab = self.tabs.tab(self.tabs.select(), 'text')
            return current_tab
        except RuntimeError:
            # Sometimes raised on KeyboardInterrupt
            sys.stderr.write('Terminated.\n')
            self._app_quit = True
            sys.exit(0)
    
    def thread(self):
        while not self._app_quit:
#.........这里部分代码省略.........
开发者ID:rekcuFniarB,项目名称:netstatlive,代码行数:103,代码来源:netstatlive.py

示例3: show_main_frame

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import bind [as 别名]
    def show_main_frame(root):
        """Создаем основное окно программы"""

        #------------------------------------------------------------
        def press(button):
            """функция, срабатывающая при нажатии кнопок переключения
            между правыми (основными) фреймами"""

            index = BUTTONS.index(button)
            window_names = rightFrameTabs.tabs()
            rightFrameTabs.select(window_names[index])

        #--------------------------------------------------------------
        def tab_changes(tab):
            """функция, срабатывающая при нажатии закладок переключения
            между правыми (основными) фреймами"""

            window_names = rightFrameTabs.tabs()
            index = window_names.index(rightFrameTabs.select())
            button = BUTTONS[index]

            for but in BUTTONS:
                if but <> button:
                    but['style'] = 'Default.TButton'
                else:
                    but['style'] = 'Chosen.TButton'

            if button == button_rule:
                if not checks_exist('Остались незакрытые счета!\nВы уверены, ' +
                   ' что хотите перейти в раздел "Управление"?\nвсе незакрытые'+
                   ' счета в таком случае будут для вас потеряны!'):
                    press(button_sell)

            if not FLAGS[index]:
                SHOW[index](workArea[index],data)
                FLAGS[index] = True

        #-------------------------------------------------------------

        leftFrame = Canvas(root, width=PANEL_WIDTH, highlightthickness=0)
        leftFrame.pack(side=LEFT, fill=Y)
        leftFrame.pack_propagate(False)
        if USE_BACKGROUND:
            leftFrame.create_image(0,0, anchor='nw', image=data.photo)

        heads = (u'Продажи', u'Отчеты', u'Приход', u'Списание', u'Сверка',
                 u'Управление', u'Настройки',)

        workArea = []
        rightFrameTabs = Notebook(root, style='Hidden.TNotebook')
        for q in range (7):
            frame = Canvas(rightFrameTabs, relief=GROOVE)
            rightFrameTabs.add(frame, text=heads[q])
            workArea.append(frame)
        rightFrameTabs.pack(side=TOP, fill=BOTH, expand=YES)
        rightFrameTabs.bind('<<NotebookTabChanged>>', tab_changes)

        button_sell = Button(leftFrame, text = u'\nПРОДАЖИ\n',
                             command=lambda: press(button_sell))
        button_sell.pack(side=TOP, padx=10, pady=10, fill=X)
        button_comings = Button(leftFrame, text = u'\nПРИХОД\n',
                                command=lambda: press(button_comings))
        button_comings.pack(side=TOP, padx=10, pady=10, fill=X)
        button_lost = Button(leftFrame, text = u'\nСПИСАНИЕ\n',
                             command=lambda: press(button_lost))
        button_lost.pack(side=TOP, padx=10, pady=10, fill=X)
        button_inventory = Button(leftFrame, text = u'\nСВЕРКА\n',
                                  command=lambda: press(button_inventory))
        button_inventory.pack(side=TOP, padx=10, pady=10, fill=X)
        button_reports = Button(leftFrame, text = u'\nОТЧЕТЫ\n',
                         command=lambda: press(button_reports))
        button_reports.pack(side=TOP, padx=10, pady=10, fill=X)
        button_rule = Button(leftFrame, text = u'\nУПРАВЛЕНИЕ\n',
                             command=lambda: press(button_rule))
        button_rule.pack(side=TOP, padx=10, pady=10, fill=X)
        button_exit = Button(leftFrame, text = u'\nВЫХОД\n', command=shutdown,
                                style='Default.TButton')
        button_exit.pack(side=BOTTOM, padx=10, pady=10, fill=X)
        button_options = Button(leftFrame, text = u'\nНАСТРОЙКА\n',
                             command=lambda: press(button_options))
        button_options.pack(side=BOTTOM, padx=10, pady=10, fill=X)

        BUTTONS = (button_sell, button_reports, button_comings,
                     button_lost, button_inventory, button_rule, button_options)
        SHOW = (show_sell, show_report, show_incoming, show_lost, show_verify,
                        show_control, show_options)
        FLAGS = [True, False, False, False, False, False, True]
        styles()
        press(button_sell)

        return workArea
开发者ID:sychov,项目名称:conditer,代码行数:93,代码来源:gui.py


注:本文中的ttk.Notebook.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。