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


Python Notebook.tab方法代码示例

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


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

示例1: Metadator

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import tab [as 别名]
class Metadator(Tk):
    def __init__(self):
        u"""
        Main window constructor
        Creates 1 frame and 2 labeled subframes
        """
        # first: the log
        # see: http://sametmax.com/ecrire-des-logs-en-python/
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.DEBUG)  # all errors will be get
        log_form = logging.Formatter('%(asctime)s || %(levelname)s || %(message)s')
        logfile = RotatingFileHandler('Metadator_LOG.log', 'a', 5000000, 1)
        logfile.setLevel(logging.DEBUG)
        logfile.setFormatter(log_form)
        self.logger.addHandler(logfile)
        self.logger.info('\n\t ======== Metadator ========')  # first messages
        self.logger.info('Starting the UI')

        # checking the path to GDAL in the path
        if "GDAL_DATA" not in env.keys():
            try:
                gdal.SetConfigOption(str('GDAL_DATA'),
                                     str(path.abspath(r'data/gdal')))
            except:
                print("Oups! Something has gone wrong...\
                      see: https://github.com/Guts/Metadator/issues/21")
        else:
            pass

        # basics settings
        Tk.__init__(self)           # constructor of parent graphic class
        self.title(u'Metadator {0}'.format(MetadatorVersion))
        self.style = Style()        # more friendly windows style
        if opersys == 'win32':
            self.logger.info('Op. system: {0}'.format(platform.platform()))
            self.iconbitmap('Metadator.ico')    # windows icon
            self.uzer = env.get(u'USERNAME')
        elif opersys == 'linux2':
            self.logger.info('Op. system: {0}'.format(platform.platform()))
            self.uzer = env.get(u'USER')
            icon = Image("photo", file=r'data/img/metadator.gif')
            self.call('wm', 'iconphoto', self._w, icon)
            self.minsize(580, 100)
            self.style.theme_use('clam')
        elif opersys == 'darwin':
            self.logger.info('Op. system: {0}'.format(platform.platform()))
            self.uzer = env.get(u'USER')
        else:
            self.logger.warning('Operating system not tested')
            self.logger.info('Op. system: {0}'.format(platform.platform()))
        self.resizable(width=False, height=False)
        self.focus_force()

        self.logger.info('GDAL version: {}'.format(gdal.__version__))

        # variables
        self.def_rep = ""       # folder to search for
        self.def_lang = 'FR'    # language to start
        self.def_doc = IntVar()     # to export into Word
        self.def_xls = IntVar()     # to export into Excel 2003
        self.def_xml = IntVar()     # to export into ISO 19139
        self.def_cat = IntVar()     # to merge all output Word files
        self.def_odt = IntVar()     # to export into OpenDocumentText
        self.def_dict = IntVar()    # to make a dictionnary of data
        self.def_kass = IntVar()    # to handle field name case sensitive
        self.def_stat = IntVar()    # to active/disable stats fields
        self.li_pro = []            # list for profiles in language selected
        self.li_shp = []            # list for shapefiles path
        self.li_tab = []            # list for MapInfo tables path
        self.num_folders = 0        # number of folders explored
        self.today = strftime("%Y-%m-%d")   # date of the day
        self.dico_layer = OD()      # dictionary about layer properties
        self.dico_profil = OD()     # dictionary from profile selected
        self.dico_fields = OD()     # dictionary for fields information
        self.dico_rekur = OD()      # dictionary of recurring attributes
        self.dico_err = OD()     # errors list
        self.dico_help = OD()                # dictionary of help texts
        li_lang = [lg for lg in listdir(r'locale')]   # available languages
        self.blabla = OD()      # texts dictionary

        # GUI fonts
        ft_tit = tkFont.Font(family="Times", size=10, weight=tkFont.BOLD)

        # fillfulling
        self.load_settings()
        self.load_texts(self.def_lang)
        self.li_profiles(self.def_lang)
        self.li_rekurs(self.def_lang)
        self.recup_help(self.def_lang)

        # Tabs
        self.nb = Notebook(self)
        self.tab_globals = Frame(self.nb)   # tab_id = 0
        self.tab_options = Frame(self.nb)   # tab_id = 1
        self.tab_attribs = Frame(self.nb)   # tab_id = 2
        self.nb.add(self.tab_globals,
                    text=self.blabla.get('gui_tab1'), padding=3)
        self.nb.add(self.tab_options,
                    text=self.blabla.get('gui_tab2'), padding=3)
        self.nb.add(self.tab_attribs,
#.........这里部分代码省略.........
开发者ID:Guts,项目名称:Metadator,代码行数:103,代码来源:Metadator.py

示例2: Application

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import tab [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: __init__

# 需要导入模块: from ttk import Notebook [as 别名]
# 或者: from ttk.Notebook import tab [as 别名]
    def __init__(self):

        self.tasks = None
        self.mainTerminated = None
        self.results = None
        self.awaited = None

        self.reqParser = RawQueryParser()

        self.defaultCfg = defaultCfg
        self.stlist = STAT_TYPES.keys()

        # set main window parameters
        mainWindow = SmartTk()
        mainWindow.title(_WindowLabels.window_title)
        self.root = mainWindow
        mainWindow.minsize(650, 450)

        # there are two frames with different finctions.
        # In fact, they work separately but use the same set of settings.
        generalframe = SettingHybrid(mainWindow)
        tabframe = Frame(mainWindow)

        self.settings = generalframe

        nb = Notebook(tabframe)
        nbUrlTab = Frame()
        nbFileEditingTab = Frame()
        nbStatTab = StatTypeFrame()
        self.statTab = nbStatTab
        self.homeDir = None


        qField = ParameterInputText(nbFileEditingTab)
        self.qField = qField
        qReadingButton = Button(nbFileEditingTab, text = u'OK', command = self.get_request_from_raw_query_window)

        self.urlText = CopyPasteText(nbUrlTab)
        urlButton = Button(nbUrlTab, text = u'OK', command = self.get_query_from_url_window)

        self.urlText.pack(fill=BOTH, expand=1)
        urlButton.pack()

        self.b1 = urlButton
        self.b2 = qReadingButton

        nb.add(nbFileEditingTab, text = tabs['file'])
        nb.add(nbUrlTab, text = tabs['url'])
        nb.add(nbStatTab, text = tabs['st'])

        minTabFrameWidth = 0
        for tab in nb.tabs():
            minTabFrameWidth += len(nb.tab(tab)['text'])

        self.root.config(width = minTabFrameWidth + 200)

        qField.pack(fill=BOTH, expand=1)
        qReadingButton.pack()
        #nbUrlTab.pack()
        nb.pack(fill=BOTH, expand=1)

        self.nb = nb # to manage tabs

        generalframe.pack(expand=0, side = 'left')
        tabframe.pack(fill=BOTH, expand=1)

        generalframe.bind_to_statistics_frame(nbStatTab)

        self.enable_keyboard_managing()
        self._add_menu()
开发者ID:sleepofnodreaming,项目名称:ruscorporaXML,代码行数:72,代码来源:tabgui.py


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