AlkantarClanX12

Your IP : 3.129.45.144


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/tabbedpages.cpython-35.pyc



��Yf�G�@s�dZddlTGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�Zdd�Ze	d
kr�ddl
mZee�dS)aAn 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.

�)�*c@seZdZdS)�InvalidNameErrorN)�__name__�
__module__�__qualname__�rr�8/opt/alt/python35/lib64/python3.5/idlelib/tabbedpages.pyrsrc@seZdZdS)�AlreadyExistsErrorN)rrrrrrrr	
sr	c@s�eZdZdZdddddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
Gdd�de�ZdS)�TabSetzjA widget containing tabs (buttons) in one or more rows.

    Only one tab may be selected at a time.

    N��FcKs�tj|||�||_||_||_||_||_i|_i|_|rjt	|�|_
n	g|_
d|_g|_t|dddddt
d|jd��|_|jjdtd	td
d�|j�dS)aConstructor 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.

        N�height��borderwidthr�relief�
background�side�fill�expandF)�Frame�__init__�select_command�n_rows�max_tabs_per_row�expand_tabs�page_set�_tabs�_tab2row�list�
_tab_names�
_selected_tab�	_tab_rows�FLAT�cgetZ
padding_frame�pack�TOP�X�
_arrange_tabs)�selfrrZtabsrrr�kwrrrrs$										zTabSet.__init__cCsS|std|��||jkr5td|��|jj|�|j�dS)z.Add a new tab with the name given in tab_name.zInvalid Tab name: '%s'zTab named '%s' already existsN)rrr	�appendr')r(�tab_namerrr�add_tabDszTabSet.add_tabcCs=||jkrtd|��|jj|�|j�dS)zRemove the tab named <tab_name>zNo such Tab: '%sN)r�KeyError�remover')r(r+rrr�
remove_tabNszTabSet.remove_tabcCs�||jkrdS|dk	r>||jkr>td|��|jdk	ra|j|jj�d|_|dk	r�||_|j|}|j�|j|}|j�|jdtdt	dd�dS)z1Show the tab named <tab_name> as the selected oneNzNo such Tab: '%srrrr)
r rr-�
set_normal�set_selectedr�pack_forgetr$r%r&)r(r+�tab�tab_rowrrr�set_selected_tabVs		



zTabSet.set_selected_tabcCs�|s
dSt|�}|jdtdtdd�|jj|�xx|D]p}tj||j||�}|r�|jdt	dtdd�n|jdt	�||j
|<||j|<qIWd|_dS)NrrrrT)
rr$r%r&r!r*r
�	TabButtonr�LEFTrr�is_last_in_row)r(�	tab_namesrr4r+r3rrr�_add_tab_rowls

zTabSet._add_tab_rowcCs6x&|jr(|jj�}|j�qWi|_dS)N)r!�pop�destroyr)r(r4rrr�_reset_tab_rows�szTabSet._reset_tab_rowscCsBx$|jr&|jj�dj�qW|j�|js>dS|jdk	rh|jdkrh|j}nt|j�d|jd}|jp�|dk}d}xht	|�D]Z}t|j�|d||d}|j|||�}||7}|j
||�q�W|j}|jd�||jkr>|j|�dS)aW
        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.

        rNr)
r�popitemr<r=rr�lenrr�ranger:r r5)r(rr�iZ	row_indexZn_tabsr9�selectedrrrr'�s&
	#
	
zTabSet._arrange_tabsc@sgeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
dd�Z
dS)zTabSet.TabButtonzA simple tab-like widget.rcCs�tj||d|jdt�||_||_||_d|_t|d|d|j	dddd	d
t
dt
dd
dddd
�	|_|jjdt
dtdd�|j�|j�dS)z�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.

            rrF�text�command�padxr�padyrZ	takefocusZindicatoronZhighlightthicknessrZselectcolor�rrrTN)rr�bw�RAISED�namer�tab_setr8ZRadiobutton�
_select_eventZFALSEZbuttonr$r7r&�_init_masksr0)r(rJrr4rKrrrr�s					
zTabSet.TabButton.__init__cGs|j|j�dS)asEvent 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)rrJ)r(�argsrrrrL�szTabSet.TabButton._select_eventcCs|jdd�dS)zAssume selected lookrBTN)�_place_masks)r(rrrr1�szTabSet.TabButton.set_selectedcCs|jdd�dS)zAssume normal lookrBFN)rO)r(rrrr0�szTabSet.TabButton.set_normalc
Cs|jj}|jjd�}t|dddtd|�|_t|dddtd|�|_t|jd|jdt	�|j_
|jj
jddd|jdd|jd	|jd
�t|dddtd|�|_t|jd|jdt	�|j_
dS)Nrrrr�x�y�widthrr
�)rKr�pages_framer#rr"�mask�msklrHrIZml�place�mskr�mr)r(rrrrrrM�szTabSet.TabButton._init_masksFcCs�|j}|r||j7}|jjd|ddddddddd	dd
dddd|�	|jjd|ddd|jddddd	dd
|jddd|�	|jj}|r�|js�|j�|j�|j�|j�kr�||j8}|j	jd|ddddddddd	dd
|jddd|�	|j	j
jd|jd|jd
d
|jd||jd
�|jj�dS)NZin_ZrelxgrPrZrelyg�?rQZrelwidthrRZ	relheightr
r)rHrUrWrVrKrr8Zwinfo_rootxZwinfo_widthrXrY�lower)r(rBr
rrrrrO�s4	




#zTabSet.TabButton._place_masksN)rrr�__doc__rHrrLr1r0rMrOrrrrr6�sr6)
rrrr[rr,r/r5r:r=r'rr6rrrrr
s	,
(r
c@s�eZdZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�Zd
eddd
dd�Z	dd�Z
dd�Zdd�Zd
S)�
TabbedPageSetajA 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.

    c@s@eZdZdZdZdd�Zdd�Zdd�Zd	S)
zTabbedPageSet.Pagez{Abstract base class for TabbedPageSet's pages.

        Subclasses must override the _show() and _hide() methods.

        FcCst|dddt�|_dS)Nrrr)rrI�frame)r(rrrrr9szTabbedPageSet.Page.__init__cCs
t�dS)N)�NotImplementedError)r(rrr�_show<szTabbedPageSet.Page._showcCs
t�dS)N)r^)r(rrr�_hide?szTabbedPageSet.Page._hideN)rrrr[�	uses_gridrr_r`rrrr�Page1s
rbc@s4eZdZdZdZdd�Zdd�ZdS)zTabbedPageSet.PageRemovezAPage class using the grid placement manager's "remove" mechanism.TcCs#|jjdddddt�dS)N�rowr�column�sticky)r]�grid�NSEW)r(rrrr_FszTabbedPageSet.PageRemove._showcCs|jj�dS)N)r]Zgrid_remove)r(rrrr`IszTabbedPageSet.PageRemove._hideN)rrrr[rar_r`rrrr�
PageRemoveBsrhcsFeZdZdZdZ�fdd�Zdd�Zdd�Z�S)	zTabbedPageSet.PageLiftz?Page class using the grid placement manager's "lift" mechanism.TcsIttj|�j|�|jjdddddt�|jj�dS)Nrcrrdre)�superr\�PageLiftrr]rfrgrZ)r(r)�	__class__rrrPszTabbedPageSet.PageLift.__init__cCs|jj�dS)N)r]Zlift)r(rrrr_UszTabbedPageSet.PageLift._showcCs|jj�dS)N)r]rZ)r(rrrr`XszTabbedPageSet.PageLift._hide)rrrr[rarr_r`rr)rkrrjLs
rjc@s.eZdZdZdd�Zdd�ZdS)zTabbedPageSet.PagePackForgetzAPage class using the pack placement manager's "forget" mechanism.cCs|jjdtdd�dS)NrrT)r]r$�BOTH)r(rrrr_]sz"TabbedPageSet.PagePackForget._showcCs|jj�dS)N)r]r2)r(rrrr``sz"TabbedPageSet.PagePackForget._hideN)rrrr[r_r`rrrr�PagePackForget[srmNrrFc		KsJtj|||�||_i|_g|_d|_d|_|jddd�|jddd�t|�|_	|j	j
dddddt�|jjr�|j	jddd�|j	jddd�t
||jd|d	|d
|�|_|rx|D]}|j|�qW|jj
dddddt�|j|j�dS)a�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.

        NrZweightrrcrdrerrr)rr�
page_class�pages�_pages_order�
_current_page�
_default_pageZcolumnconfigureZrowconfigurerTrfrgrar
�change_page�_tab_set�add_page)	r(�parent�
page_namesrnrrrr)rJrrrrcs* 					
zTabbedPageSet.__init__cCs�|std|��||jkr5td|��|j|j�|j|<|jj|�|jj|�t	|j�dkr�||_
|j|�dS)z0Add a new page with the name given in page_name.zInvalid TabPage name: '%s'z!TabPage named '%s' already existsrN)rror	rnrTrpr*rtr,r?rrrs)r(�	page_namerrrru�s
	zTabbedPageSet.add_pagecCs�||jkrtd|��|jj|�t|j�dkrf||jkro|jd|_n	d|_||jkr�|j|j�|jj	|�|jj
|�}|jj�dS)z2Destroy the page whose name is given in page_name.zNo such TabPage: '%srN)
ror-rpr.r?rrrqrsrtr/r;r]r<)r(rxZpagerrr�remove_page�s	zTabbedPageSet.remove_pagecCs�|j|krdS|dk	r>||jkr>td|��|jdk	ra|j|jj�d|_|dk	r�||_|j|j�|jj|�dS)z/Show the page whose name is given in page_name.NzNo such TabPage: '%s')rqror-r`r_rtr5)r(rxrrrrs�s		zTabbedPageSet.change_page)
rrrr[�objectrbrhrjrmrruryrsrrrrr\ s
;r\c	s�t�}ttttjd|j����\}}}}|jd||df�|jd�t|dddgdd	d
d���j	dt
d
tdt�t
�jdjdddd�j	�t
�jdjdddd�j	�t
�jdjdd�j	�t|��t|ddd��fdd��}t|ddd��fdd��}t
|dd�}|j	dddd�|j	dddd�|j	dd��j	dd�|j�dS)Nz[x+]z+%d+%d�zTest tabbed pagesrwZFoobarZBazrrrFrrrrCZFoorF�ZBarzAdd PagerDcs�j�j��S)N)ru�getr)�entryPgName�tabPagerr�<lambda>�sz_tabbed_pages.<locals>.<lambda>zRemove Pagecs�j�j��S)N)ryr}r)r~rrrr��szname of page to add/remove:rEr)ZTkr�map�int�re�splitZgeometry�titler\r$r%ZTRUErlZLabelror]ZEntryZButtonZmainloop)	rv�rootrRr
rPrQZ	buttonAddZbuttonRemoveZlabelPgNamer)r~rr�
_tabbed_pages�s*	3
	&& r��__main__)�runN)r[Ztkinter�	Exceptionrr	rr
r\r�rZidlelib.idle_test.htestr�rrrr�<module>	s
��