%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2599/usr/lib/python3/dist-packages/urwid/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2599/usr/lib/python3/dist-packages/urwid/__pycache__/wimp.cpython-38.pyc

U

��dZ0U�@s.ddlmZmZddlmZmZmZmZmZddl	m
Z
ddlmZddl
mZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�ded�e�Z!Gdd�de�Z"dd�Z#e$dk�r*e#�dS)�)�division�print_function)�Text�
WidgetWrap�delegate_to_widget_mixin�BOX�FLOW)�CompositeCanvas)�connect_signal)�Columns�Overlay)�is_mouse_press)�calc_coords)�disconnect_signal)�python3_repr)�WidgetDecoration)�ACTIVATEc@s4eZdZdZd
dd�Zddd�Zdd	�Zd
d�ZdS)�SelectableIconT�cCs|j�|�||_dS)a�
        :param text: markup for this widget; see :class:`Text` for
                     description of text markup
        :param cursor_position: position the cursor will appear in the
                                text when this widget is in focus

        This is a text widget that is selectable.  A cursor
        displayed at a fixed location in the text when in focus.
        This widget has no special handling of keyboard or mouse input.
        N)�_SelectableIcon__super�__init__�_cursor_position)�self�textZcursor_position�r�,/usr/lib/python3/dist-packages/urwid/wimp.pyr&szSelectableIcon.__init__FcCs*|j�||�}|r&t|�}|�|�|_|S)a�
        Render the text content of this widget with a cursor when
        in focus.

        >>> si = SelectableIcon(u"[!]")
        >>> si
        <SelectableIcon selectable flow widget '[!]'>
        >>> si.render((4,), focus=True).cursor
        (1, 0)
        >>> si = SelectableIcon("((*))", 2)
        >>> si.render((8,), focus=True).cursor
        (2, 0)
        >>> si.render((2,), focus=True).cursor
        (0, 1)
        )r�renderr	�get_cursor_coordsZcursor)r�size�focus�crrrr4s
zSelectableIcon.rendercCsL|jt|j�krdS|\}|�|�}t|j||j�\}}||krDdS||fS)z�
        Return the position of the cursor if visible.  This method
        is required for widgets that display a cursor.
        N)r�lenrZget_line_translationr)rrZmaxcolZtrans�x�yrrrrKs
z SelectableIcon.get_cursor_coordscCs|S)zn
        No keys are handled by this widget.  This method is
        required for selectable widgets.
        r�rr�keyrrr�keypress[szSelectableIcon.keypressN)r)F)�__name__�
__module__�__qualname__�_selectablerrrr&rrrrr$s


rc@seZdZdS)�
CheckBoxErrorN)r'r(r)rrrrr+bsr+c@s�eZdZdd�Zed�ed�ed�d�ZdZdd	gZd!dd
�Zdd�Z	dd�Z
dd�Zdd�Ze
e�Zd"dd�Zdd�Ze
ee�Zdd�Zdd�Zdd �ZdS)#�CheckBoxcCs
ttg�S�N��	frozensetr�rrrr�sizingfszCheckBox.sizingz[X]z[ ]z[#]�TF�mixed��change�
postchangeFNcCsL|j�d�td�|_||_d|_|r4t|d||�|�|�|�|�dS)a�
        :param label: markup for check box label
        :param state: False, True or "mixed"
        :param has_mixed: True if "mixed" is a state to cycle through
        :param on_state_change: shorthand for connect_signal()
                                function call for a single callback
        :param user_data: user_data for on_state_change

        Signals supported: ``'change'``, ``"postchange"``

        Register signal handler with::

          urwid.connect_signal(check_box, 'change', callback, user_data)

        where callback is callback(check_box, new_state [,user_data])
        Unregister signal handlers with::

          urwid.disconnect_signal(check_box, 'change', callback, user_data)

        >>> CheckBox(u"Confirm")
        <CheckBox selectable flow widget 'Confirm' state=False>
        >>> CheckBox(u"Yogourt", "mixed", True)
        <CheckBox selectable flow widget 'Yogourt' state='mixed'>
        >>> cb = CheckBox(u"Extra onions", True)
        >>> cb
        <CheckBox selectable flow widget 'Extra onions' state=True>
        >>> cb.render((20,), focus=True).text # ... = b in Python 3
        [...'[X] Extra onions    ']
        N�r5)	�_CheckBox__superrr�_label�	has_mixed�_stater
�	set_label�	set_state)r�label�stater:�on_state_change�	user_datarrrrts

zCheckBox.__init__cCs|j��t|j�gSr-)r8�_repr_wordsrr>r0rrrrB�s�zCheckBox._repr_wordscCst|j��|jd�S)N)r?)�dictr8�_repr_attrsr?r0rrrrD�s
�zCheckBox._repr_attrscCs|j�|�dS)au
        Change the check box label.

        label -- markup for label.  See Text widget for description
        of text markup.

        >>> cb = CheckBox(u"foo")
        >>> cb
        <CheckBox selectable flow widget 'foo' state=False>
        >>> cb.set_label(('bright_attr', u"bar"))
        >>> cb
        <CheckBox selectable flow widget 'bar' state=False>
        N�r9Zset_text�rr>rrrr<�szCheckBox.set_labelcCs|jjS)a>
        Return label text.

        >>> cb = CheckBox(u"Seriously")
        >>> print(cb.get_label())
        Seriously
        >>> print(cb.label)
        Seriously
        >>> cb.set_label([('bright_attr', u"flashy"), u" normal"])
        >>> print(cb.label)  #  only text is returned
        flashy normal
        �r9rr0rrr�	get_label�s
zCheckBox.get_labelTcCs�|j|krdS||jkr0tdt|�t|�f��|j}|rN|dk	rN|�d|�||_td|j|j|f|jg�|_d|j_	|r�|dk	r�|�d|�dS)a�
        Set the CheckBox state.

        state -- True, False or "mixed"
        do_callback -- False to suppress signal from this change

        >>> changes = []
        >>> def callback_a(cb, state, user_data):
        ...     changes.append("A %r %r" % (state, user_data))
        >>> def callback_b(cb, state):
        ...     changes.append("B %r" % state)
        >>> cb = CheckBox('test', False, False)
        >>> key1 = connect_signal(cb, 'change', callback_a, "user_a")
        >>> key2 = connect_signal(cb, 'change', callback_b)
        >>> cb.set_state(True) # both callbacks will be triggered
        >>> cb.state
        True
        >>> disconnect_signal(cb, 'change', callback_a, "user_a")
        >>> cb.state = False
        >>> cb.state
        False
        >>> cb.set_state(True)
        >>> cb.state
        True
        >>> cb.set_state(False, False) # don't send signal
        >>> changes
        ["A True 'user_a'", 'B True', 'B False', 'B True']
        Nz%s Invalid state: %sr5�fixedrr6)
r;�statesr+�repr�_emitr�reserve_columnsr9Z_wZ	focus_col)rr?�do_callbackZ	old_staterrrr=�s$

��zCheckBox.set_statecCs|jS)z!Return the state of the checkbox.)r;r0rrr�	get_state�szCheckBox.get_statecCs|j|tkr|S|��dS)a�
        Toggle state on 'activate' command.

        >>> assert CheckBox._command_map[' '] == 'activate'
        >>> assert CheckBox._command_map['enter'] == 'activate'
        >>> size = (10,)
        >>> cb = CheckBox('press me')
        >>> cb.state
        False
        >>> cb.keypress(size, ' ')
        >>> cb.state
        True
        >>> cb.keypress(size, ' ')
        >>> cb.state
        False
        N)�_command_mapr�toggle_stater$rrrr&�szCheckBox.keypresscCsV|jdkr|�d�n<|jdkr>|jr2|�d�qR|�d�n|jdkrR|�d�dS)aM
        Cycle to the next valid state.

        >>> cb = CheckBox("3-state", has_mixed=True)
        >>> cb.state
        False
        >>> cb.toggle_state()
        >>> cb.state
        True
        >>> cb.toggle_state()
        >>> cb.state
        'mixed'
        >>> cb.toggle_state()
        >>> cb.state
        False
        FTr3N)r?r=r:r0rrrrQs


zCheckBox.toggle_statecCs |dkst|�sdS|��dS)a
        Toggle state on button 1 press.

        >>> size = (20,)
        >>> cb = CheckBox("clickme")
        >>> cb.state
        False
        >>> cb.mouse_event(size, 'mouse press', 1, 2, 0, True)
        True
        >>> cb.state
        True
        rFT)r
rQ�rrZeventZbuttonr"r#rrrr�mouse_event0s
zCheckBox.mouse_event)FFNN)T)r'r(r)r1rrJrM�signalsrrBrDr<rH�propertyr>r=rOr?r&rQrSrrrrr,es,��
*
2
r,c@sDeZdZed�ed�ed�d�ZdZddd	�Zddd�Zd
d�ZdS)�RadioButtonz(X)z( )z(#)r2r4�
first TrueNcCs6|dkr|}||_|j�||d||�|�|�dS)a
        :param group: list for radio buttons in same group
        :param label: markup for radio button label
        :param state: False, True, "mixed" or "first True"
        :param on_state_change: shorthand for connect_signal()
                                function call for a single 'change' callback
        :param user_data: user_data for on_state_change

        This function will append the new radio button to group.
        "first True" will set to True if group is empty.

        Signals supported: ``'change'``, ``"postchange"``

        Register signal handler with::

          urwid.connect_signal(radio_button, 'change', callback, user_data)

        where callback is callback(radio_button, new_state [,user_data])
        Unregister signal handlers with::

          urwid.disconnect_signal(radio_button, 'change', callback, user_data)

        >>> bgroup = [] # button group
        >>> b1 = RadioButton(bgroup, u"Agree")
        >>> b2 = RadioButton(bgroup, u"Disagree")
        >>> len(bgroup)
        2
        >>> b1
        <RadioButton selectable flow widget 'Agree' state=True>
        >>> b2
        <RadioButton selectable flow widget 'Disagree' state=False>
        >>> b2.render((15,), focus=True).text # ... = b in Python 3
        [...'( ) Disagree   ']
        rWFN)�group�_RadioButton__superr�append)rrXr>r?r@rArrrrJs$�zRadioButton.__init__TcCsR|j|krdS|j�||�|dk	r(dS|jD]}||kr<q.|jr.|�d�q.dS)a�
        Set the RadioButton state.

        state -- True, False or "mixed"

        do_callback -- False to suppress signal from this change

        If state is True all other radio buttons in the same button
        group will be set to False.

        >>> bgroup = [] # button group
        >>> b1 = RadioButton(bgroup, u"Agree")
        >>> b2 = RadioButton(bgroup, u"Disagree")
        >>> b3 = RadioButton(bgroup, u"Unsure")
        >>> b1.state, b2.state, b3.state
        (True, False, False)
        >>> b2.set_state(True)
        >>> b1.state, b2.state, b3.state
        (False, True, False)
        >>> def relabel_button(radio_button, new_state):
        ...     radio_button.set_label(u"Think Harder!")
        >>> key = connect_signal(b3, 'change', relabel_button)
        >>> b3
        <RadioButton selectable flow widget 'Unsure' state=False>
        >>> b3.set_state(True) # this will trigger the callback
        >>> b3
        <RadioButton selectable flow widget 'Think Harder!' state=True>
        NTF)r;rYr=rX)rr?rN�cbrrrr=xs

zRadioButton.set_statecCs|�d�dS)a�
        Set state to True.

        >>> bgroup = [] # button group
        >>> b1 = RadioButton(bgroup, "Agree")
        >>> b2 = RadioButton(bgroup, "Disagree")
        >>> b1.state, b2.state
        (True, False)
        >>> b2.toggle_state()
        >>> b1.state, b2.state
        (False, True)
        >>> b2.toggle_state()
        >>> b1.state, b2.state
        (False, True)
        TN)r=r0rrrrQ�szRadioButton.toggle_state)rWNN)T)	r'r(r)rrJrMrr=rQrrrrrVCs��
.
.rVc@sdeZdZdd�Zed�Zed�ZdgZddd�Zd	d
�Z	dd�Z
d
d�Zee�Z
dd�Zdd�ZdS)�ButtoncCs
ttg�Sr-r.r0rrrr1�sz
Button.sizing�<�>�clickNcCs\tdd�|_tdd|jf|jdd|jfgdd�}|j�|�|rNt|d||�|�|�dS)a�
        :param label: markup for button label
        :param on_press: shorthand for connect_signal()
                         function call for a single callback
        :param user_data: user_data for on_press

        Signals supported: ``'click'``

        Register signal handler with::

          urwid.connect_signal(button, 'click', callback, user_data)

        where callback is callback(button [,user_data])
        Unregister signal handlers with::

          urwid.disconnect_signal(button, 'click', callback, user_data)

        >>> Button(u"Ok")
        <Button selectable flow widget 'Ok'>
        >>> b = Button("Cancel")
        >>> b.render((15,), focus=True).text # ... = b in Python 3
        [...'< Cancel      >']
        r7rrIr)Zdividecharsr_N)	rr9r�button_left�button_right�_Button__superrr
r<)rr>Zon_pressrAZcolsrrrr�s

��zButton.__init__cCs|j��t|j�gSr-)rbrBrr>r0rrrrB�s�zButton._repr_wordscCs|j�|�dS)z�
        Change the button label.

        label -- markup for button label

        >>> b = Button("Ok")
        >>> b.set_label(u"Yup yup")
        >>> b
        <Button selectable flow widget 'Yup yup'>
        NrErFrrrr<�szButton.set_labelcCs|jjS)z�
        Return label text.

        >>> b = Button(u"Ok")
        >>> print(b.get_label())
        Ok
        >>> print(b.label)
        Ok
        rGr0rrrrH�s
zButton.get_labelcCs |j|tkr|S|�d�dS)aD
        Send 'click' signal on 'activate' command.

        >>> assert Button._command_map[' '] == 'activate'
        >>> assert Button._command_map['enter'] == 'activate'
        >>> size = (15,)
        >>> b = Button(u"Cancel")
        >>> clicked_buttons = []
        >>> def handle_click(button):
        ...     clicked_buttons.append(button.label)
        >>> key = connect_signal(b, 'click', handle_click)
        >>> b.keypress(size, 'enter')
        >>> b.keypress(size, ' ')
        >>> clicked_buttons # ... = u in Python 2
        [...'Cancel', ...'Cancel']
        r_N)rPrrLr$rrrr&szButton.keypresscCs"|dkst|�sdS|�d�dS)a
        Send 'click' signal on button 1 press.

        >>> size = (15,)
        >>> b = Button(u"Ok")
        >>> clicked_buttons = []
        >>> def handle_click(button):
        ...     clicked_buttons.append(button.label)
        >>> key = connect_signal(b, 'click', handle_click)
        >>> b.mouse_event(size, 'mouse press', 1, 4, 0, True)
        True
        >>> b.mouse_event(size, 'mouse press', 2, 4, 0, True) # ignored
        False
        >>> clicked_buttons # ... = u in Python 2
        [...'Ok']
        rFr_T)r
rLrRrrrrSs
zButton.mouse_event)NN)r'r(r)r1rr`rarTrrBr<rHrUr>r&rSrrrrr\�s
'
r\c@s>eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zddd
�ZdS)�
PopUpLaunchercCs|j�|�d|_dSr-)�_PopUpLauncher__superr�_pop_up_widget�rZoriginal_widgetrrrr8szPopUpLauncher.__init__cCstd��dS)z�
        Subclass must override this method and return a widget
        to be used for the pop-up.  This method is called once each time
        the pop-up is opened.
        �"Subclass must override this methodN��NotImplementedErrorr0rrr�
create_pop_up<szPopUpLauncher.create_pop_upcCstd��dS)z�
        Subclass must override this method and have it return a dict, eg:

        {'left':0, 'top':1, 'overlay_width':30, 'overlay_height':4}

        This method is called each time this widget is rendered.
        rgNrhr0rrr�get_pop_up_parametersDsz#PopUpLauncher.get_pop_up_parameterscCs|��|_|��dSr-)rjre�_invalidater0rrr�open_pop_upNs
zPopUpLauncher.open_pop_upcCsd|_|��dSr-)rerlr0rrr�close_pop_upRszPopUpLauncher.close_pop_upFcCs4|j�||�}|jr0t|�}|j|jf|���|Sr-)rdrrer	Z
set_pop_uprk)rrr�canvrrrrVs
zPopUpLauncher.renderN)F)	r'r(r)rrjrkrmrnrrrrrrc6s
rc�_original_widgetc@sfeZdZeeg�ZdZdd�Zdd�Zddd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zddd�ZdS)�PopUpTargetTcCs|j�|�d|_|j|_dSr-)Z_PopUpTarget__superr�_pop_uprp�_current_widgetrfrrrrdszPopUpTarget.__init__c
Cs�|jj||d�}||_|��}|r~|\}}\}}}	|j|krb||_t||jd|f|d|f|	�|_q�|j�d|f|d|f|	�nd|_|j|_dS)N�rz
fixed leftz	fixed top)rprZ_cache_original_canvasZ
get_pop_uprrrrsZset_overlay_parameters)
rrrroZpop_up�left�top�wZ
overlay_widthZoverlay_heightrrr�_update_overlayis2�
��zPopUpTarget._update_overlayFcCs|�||�|jj||d�S)Nrt)rxrsr�rrrrrrr}szPopUpTarget.rendercCs|�|d�|j�|�S�NT)rxrsr�rrrrrr�szPopUpTarget.get_cursor_coordscCs|�|d�|j�|�Srz)rxrs�get_pref_colr{rrrr|�szPopUpTarget.get_pref_colcCs|�|d�|j�||�Srz)rxrsr&r$rrrr&�szPopUpTarget.keypresscCs|�|d�|j�|||�Srz)rxrs�move_cursor_to_coords)rrr"r#rrrr}�sz!PopUpTarget.move_cursor_to_coordscCs"|�||�|j�||||||�Sr-)rxrsrSrRrrrrS�szPopUpTarget.mouse_eventNcCs|�||�|j�|�Sr-)rxrs�packryrrrr~�szPopUpTarget.pack)F)NF)r'r(r)�setrZ_sizingr*rrxrrr|r&r}rSr~rrrrrq^s

rqcCsddl}|��dS)Nr)�doctestZtestmod)r�rrr�_test�sr��__main__N)%Z
__future__rrZurwid.widgetrrrrrZurwid.canvasr	Z
urwid.signalsr
Zurwid.containerrrZ
urwid.utilr
Zurwid.text_layoutrrZurwid.split_reprrZurwid.decorationrZurwid.command_maprr�	Exceptionr+r,rVr\rcrqr�r'rrrr�<module>s.>_v}�(:


Zerion Mini Shell 1.0