ž pyMa÷Fc@sàdZddlTGdd„deƒZGdd„deƒZGdd„deƒZGd d „d eƒZed krÜe ƒZ ee d d dgddde ƒZ e j dededeƒee jd jddddƒj ƒee jd jddddƒj ƒee jdjddƒj ƒee ƒZee ddddd„ƒZee ddddd„ƒZee ddƒZej d d!dd!ƒej d d!dd!ƒej d d!ƒej d d!ƒe jƒnd"S(#uAn implementation of tabbed pages using only standard Tkinter. Originally developed for use in IDLE. Based on tabpage.py. Classes exported: TabbedPageSet -- A Tkinter implementation of a tabbed-page widget. TabSet -- A widget containing tabs (buttons) in one or more rows. i(u*cBs|EeZdZdS(uInvalidNameErrorN(u__name__u __module__u __qualname__(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuInvalidNameError suInvalidNameErrorcBs|EeZdZdS(uAlreadyExistsErrorN(u__name__u __module__u __qualname__(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuAlreadyExistsError suAlreadyExistsErrorcBs|EeZdZdZdddddd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z Gdd„de ƒZdS(uTabSetujA widget containing tabs (buttons) in one or more rows. Only one tab may be selected at a time. iic Ksâtj|||||_||_||_||_||_i|_i|_|rjt |ƒ|_ n g|_ d |_ g|_ t|dddddtd|jdƒƒ|_|jjdtdtd d ƒ|jƒd S( uConstructor arguments: select_command -- A callable which will be called when a tab is selected. It is called with the name of the selected tab as an argument. tabs -- A list of strings, the names of the tabs. Should be specified in the desired tab order. The first tab will be the default and first active tab. If tabs is None or empty, the TabSet will be initialized empty. n_rows -- Number of rows of tabs to be shown. If n_rows <= 0 or is None, then the number of rows will be decided by TabSet. See _arrange_tabs() for details. max_tabs_per_row -- Used for deciding how many rows of tabs are needed, when the number of rows is not constant. See _arrange_tabs() for details. uheightiu borderwidthiureliefu backgroundusideufilluexpandNF(uFrameu__init__uselect_commandun_rowsumax_tabs_per_rowu expand_tabsupage_setu_tabsu_tab2rowulistu _tab_namesuNoneu _selected_tabu _tab_rowsuFLATucgetu padding_frameupackuTOPuXuFalseu _arrange_tabs(uselfupage_setuselect_commandutabsun_rowsumax_tabs_per_rowu expand_tabsukw((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu__init__s$           uTabSet.__init__cCsY|std|ƒ‚n||jkr;td|ƒ‚n|jj|ƒ|jƒdS(u.Add a new tab with the name given in tab_name.uInvalid Tab name: '%s'uTab named '%s' already existsN(uInvalidNameErroru _tab_namesuAlreadyExistsErroruappendu _arrange_tabs(uselfutab_name((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuadd_tabDs uTabSet.add_tabcCs@||jkr"td|ƒ‚n|jj|ƒ|jƒdS(uRemove the tab named uNo such Tab: '%sN(u _tab_namesuKeyErroruremoveu _arrange_tabs(uselfutab_name((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu remove_tabNsuTabSet.remove_tabcCsÖ||jkrdS|dk rA||jkrAtd|ƒ‚n|jdk rg|j|jjƒnd|_|dk rÒ||_|j|}|jƒ|j|}|jƒ|jdt dt ddƒndS(u1Show the tab named as the selected oneNuNo such Tab: '%susideufilluexpandi( u _selected_tabuNoneu_tabsuKeyErroru set_normalu set_selectedu_tab2rowu pack_forgetupackuTOPuX(uselfutab_nameutabutab_row((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuset_selected_tabVs       uTabSet.set_selected_tabcCsÊ|s dSt|ƒ}|jdtdtddƒ|jj|ƒxx|D]p}tj||j||ƒ}|r|jdt dtddƒn|jdt ƒ||j |<||j |dS|jdk rh|jdkrh|j}nt|jƒd|jd}|j p˜|dk}d}xht |ƒD]Z}t|jƒ|d||d}|j|||…}||7}|j ||ƒq®W|j }|j dƒ||jkrA|j |ƒndS(uW Arrange the tabs in rows, in the order in which they were added. If n_rows >= 1, this will be the number of rows used. Otherwise the number of rows will be calculated according to the number of tabs and max_tabs_per_row. In this case, the number of rows may change when adding/removing tabs. iNi(u_tabsupopitemudestroyu_reset_tab_rowsu _tab_namesun_rowsuNoneulenumax_tabs_per_rowu expand_tabsurangeu _add_tab_rowu _selected_tabuset_selected_tab(uselfun_rowsu expand_tabsuiu row_indexun_tabsu tab_namesuselected((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu _arrange_tabs‡s&    #   uTabSet._arrange_tabscBsk|EeZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z dd d„Z dS(uTabSet.TabButtonuA simple tab-like widget.icCsÂtj||d|jdtƒ||_||_||_d|_t |d|d|j ddddd t d t d d d ddd ƒ |_ |j j dtdtddƒ|jƒ|jƒdS(uúConstructor arguments: name -- The tab's name, which will appear in its button. select_command -- The command to be called upon selection of the tab. It is called with the tab's name as an argument. u borderwidthureliefutextucommandupadxiupadyiu takefocusu indicatoronuhighlightthicknessiu selectcoloruusideufilluexpandNFT(uFrameu__init__ubwuRAISEDunameuselect_commandutab_setuFalseuis_last_in_rowu Radiobuttonu _select_eventuFALSEubuttonupackuLEFTuXuTrueu _init_masksu set_normal(uselfunameuselect_commandutab_rowutab_set((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu__init__´s      uTabSet.TabButton.__init__cGs|j|jƒdS(usEvent handler for tab selection. With TabbedPageSet, this calls TabbedPageSet.change_page, so that selecting a tab changes the page. Note that this does -not- call set_selected -- it will be called by TabSet.set_selected_tab, which should be called when whatever the tabs are related to changes. N(uselect_commanduname(uselfuargs((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu _select_eventÍs uTabSet.TabButton._select_eventcCs|jddƒdS(uAssume selected lookuselectedNT(u _place_masksuTrue(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu set_selectedÛsuTabSet.TabButton.set_selectedcCs|jddƒdS(uAssume normal lookuselectedNF(u _place_masksuFalse(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu set_normalßsuTabSet.TabButton.set_normalc Cs|jj}|jjdƒ}t|dddtd|ƒ|_t|dddtd|ƒ|_t|jd|jdt ƒ|j_ |jj j ddd|j dd|jd |jd ƒt|dddtd|ƒ|_ t|j d|jdt ƒ|j _ dS( Nu backgroundu borderwidthiureliefuxuyuwidthiuheighti(utab_setupage_setu pages_frameucgetuFrameuFLATumaskumsklubwuRAISEDumluplaceumskrumr(uselfupage_setu background((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu _init_masksãs    uTabSet.TabButton._init_maskscCs|j}|r||j7}n|jjd|ddddddddd dd dd dd |ƒ |jjd|ddd|j ddddd dd |jd dd |ƒ |jj}|r|j sô|jƒ|jƒ|jƒ|jƒkr||j8}n|j jd|ddddddddd dd |jd dd |ƒ |j j jd|j d|j d d |jd ||jd ƒ|jj ƒdS(Nuin_urelxguxiurelygð?uyurelwidthuwidthu relheightuheighti( ubwumaskuplaceumsklutab_setupage_setuis_last_in_rowu winfo_rootxu winfo_widthumskrumrulower(uselfuselecteduheightupage_set((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu _place_masksøs4           #uTabSet.TabButton._place_masksNF( u__name__u __module__u __qualname__u__doc__ubwu__init__u _select_eventu set_selectedu set_normalu _init_masksuFalseu _place_masks(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu TabButton¯s     u TabButtonNF(u__name__u __module__u __qualname__u__doc__uNoneuFalseu__init__uadd_tabu remove_tabuset_selected_tabu _add_tab_rowu_reset_tab_rowsu _arrange_tabsuFrameu TabButton(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuTabSets ,     (uTabSetcBs±|EeZdZdZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZded d dd d „Z dd„Z dd„Z dd„ZdS(u TabbedPageSetujA Tkinter tabbed-pane widget. Constains set of 'pages' (or 'panes') with tabs above for selecting which page is displayed. Only one page will be displayed at a time. Pages may be accessed through the 'pages' attribute, which is a dictionary of pages, using the name given as the key. A page is an instance of a subclass of Tk's Frame widget. The page widgets will be created (and destroyed when required) by the TabbedPageSet. Do not call the page's pack/place/grid/destroy methods. Pages may be added or removed at any time using the add_page() and remove_page() methods. cBsD|EeZdZdZd Zdd„Zdd„Zdd„ZdS( uTabbedPageSet.Pageu{Abstract base class for TabbedPageSet's pages. Subclasses must override the _show() and _hide() methods. cCst|dddtƒ|_dS(Nu borderwidthiurelief(uFrameuRAISEDuframe(uselfupage_set((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu__init__9suTabbedPageSet.Page.__init__cCs t‚dS(N(uNotImplementedError(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_show<suTabbedPageSet.Page._showcCs t‚dS(N(uNotImplementedError(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_hide?suTabbedPageSet.Page._hideNF( u__name__u __module__u __qualname__u__doc__uFalseu uses_gridu__init__u_showu_hide(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuPage1s   uPagecBs8|EeZdZdZdZdd„Zdd„ZdS(uTabbedPageSet.PageRemoveuAPage class using the grid placement manager's "remove" mechanism.cCs#|jjdddddtƒdS(Nurowiucolumnusticky(uframeugriduNSEW(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_showFsuTabbedPageSet.PageRemove._showcCs|jjƒdS(N(uframeu grid_remove(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_hideIsuTabbedPageSet.PageRemove._hideNT(u__name__u __module__u __qualname__u__doc__uTrueu uses_gridu_showu_hide(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu PageRemoveBs u PageRemovecsJ|EeZdZdZdZ‡fdd†Zdd„Zdd„Z‡S( uTabbedPageSet.PageLiftu?Page class using the grid placement manager's "lift" mechanism.csIttj|ƒj|ƒ|jjdddddtƒ|jjƒdS(Nurowiucolumnusticky(usuperu TabbedPageSetuPageLiftu__init__uframeugriduNSEWulower(uselfupage_set(u __class__(u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu__init__PsuTabbedPageSet.PageLift.__init__cCs|jjƒdS(N(uframeulift(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_showUsuTabbedPageSet.PageLift._showcCs|jjƒdS(N(uframeulower(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_hideXsuTabbedPageSet.PageLift._hideT( u__name__u __module__u __qualname__u__doc__uTrueu uses_gridu__init__u_showu_hide(u __locals__((u __class__u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuPageLiftLs  uPageLiftcBs2|EeZdZdZdd„Zdd„ZdS(uTabbedPageSet.PagePackForgetuAPage class using the pack placement manager's "forget" mechanism.cCs|jjdtddƒdS(NufilluexpandT(uframeupackuBOTHuTrue(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_show]su"TabbedPageSet.PagePackForget._showcCs|jjƒdS(N(uframeu pack_forget(uself((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu_hide`su"TabbedPageSet.PagePackForget._hideN(u__name__u __module__u __qualname__u__doc__u_showu_hide(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuPagePackForget[s uPagePackForgetiic KsPtj|||||_i|_g|_d |_d |_|jdddƒ|j dddƒt|ƒ|_ |j j dddddt ƒ|jj rÏ|j jdddƒ|j j dddƒnt||jd|d|d |ƒ|_|rx|D]}|j|ƒqWn|jj dddddt ƒ|j|jƒd S( uŒConstructor arguments: page_names -- A list of strings, each will be the dictionary key to a page's widget, and the name displayed on the page's tab. Should be specified in the desired page order. The first page will be the default and first active page. If page_names is None or empty, the TabbedPageSet will be initialized empty. n_rows, max_tabs_per_row -- Parameters for the TabSet which will manage the tabs. See TabSet's docs for details. page_class -- Pages can be shown/hidden using three mechanisms: * PageLift - All pages will be rendered one on top of the other. When a page is selected, it will be brought to the top, thus hiding all other pages. Using this method, the TabbedPageSet will not be resized when pages are switched. (It may still be resized when pages are added/removed.) * PageRemove - When a page is selected, the currently showing page is hidden, and the new page shown in its place. Using this method, the TabbedPageSet may resize when pages are changed. * PagePackForget - This mechanism uses the pack placement manager. When a page is shown it is packed, and when it is hidden it is unpacked (i.e. pack_forget). This mechanism may also cause the TabbedPageSet to resize when the page is changed. iuweightiurowucolumnustickyun_rowsumax_tabs_per_rowu expand_tabsN(uFrameu__init__u page_classupagesu _pages_orderuNoneu _current_pageu _default_pageucolumnconfigureu rowconfigureu pages_frameugriduNSEWu uses_griduTabSetu change_pageu_tab_setuadd_page( uselfuparentu page_namesu page_classun_rowsumax_tabs_per_rowu expand_tabsukwuname((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu__init__cs*         uTabbedPageSet.__init__cCs¦|std|ƒ‚n||jkr;td|ƒ‚n|j|jƒ|j|<|jj|ƒ|jj|ƒt |jƒdkr¢||_ |j |ƒndS(u0Add a new page with the name given in page_name.uInvalid TabPage name: '%s'u!TabPage named '%s' already existsiN( uInvalidNameErrorupagesuAlreadyExistsErroru page_classu pages_frameu _pages_orderuappendu_tab_setuadd_tabulenu _default_pageu change_page(uselfu page_name((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuadd_pageŸs uTabbedPageSet.add_pagecCsÊ||jkr"td|ƒ‚n|jj|ƒt|jƒdkrl||jkru|jd|_qun d|_||jkr—|j|jƒn|j j |ƒ|jj |ƒ}|j j ƒdS(u2Destroy the page whose name is given in page_name.uNo such TabPage: '%siN(upagesuKeyErroru _pages_orderuremoveulenu _default_pageuNoneu _current_pageu change_pageu_tab_setu remove_tabupopuframeudestroy(uselfu page_nameupage((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu remove_page¯s uTabbedPageSet.remove_pagecCs­|j|krdS|dk rA||jkrAtd|ƒ‚n|jdk rg|j|jjƒnd|_|dk r™||_|j|jƒn|jj|ƒdS(u/Show the page whose name is given in page_name.NuNo such TabPage: '%s'(u _current_pageuNoneupagesuKeyErroru_hideu_showu_tab_setuset_selected_tab(uselfu page_name((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu change_pageÅs   uTabbedPageSet.change_pageNF(u__name__u __module__u __qualname__u__doc__uobjectuPageu PageRemoveuPageLiftuPagePackForgetuNoneuFalseu__init__uadd_pageu remove_pageu change_page(u __locals__((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu TabbedPageSet s ;  u TabbedPageSetu__main__u page_namesuFoobaruBazun_rowsu expand_tabsusideuexpandufillutextuFooupadyiuBaruAdd PageucommandcCstjtjƒƒS(N(utabPageuadd_pageu entryPgNameuget(((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuâsuu Remove PagecCstjtjƒƒS(N(utabPageu remove_pageu entryPgNameuget(((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyuäsuname of page to add/remove:upadxiN(u__doc__utkinteru ExceptionuInvalidNameErroruAlreadyExistsErroruFrameuTabSetu TabbedPageSetu__name__uTkurootuFalseutabPageupackuTOPuTRUEuBOTHuLabelupagesuframeuEntryu entryPgNameuButtonu buttonAddu buttonRemoveu labelPgNameumainloop(((u8/opt/alt/python33/lib64/python3.3/idlelib/tabbedpages.pyu s2 ÿ¶   &&