%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/stretchy.cpython-310.pyc

o

K��^b�@sFdZddlZddlmZmZGdd�dejd�ZGdd�dej�ZdS)	aCustom overlay that only takes the space it needs but can still scroll.

There are a couple of dialogs in subiquity that basically have the form:

 +------ dialog title --------+
 |                            |
 | potentially quite long     |
 | block of text that might   |
 | take several lines and so  |
 | need to be scrollable      |
 |                            |
 |  maybe another widget      |
 |                            |
 |       [ OK     ]           |
 |       [ Cancel ]           |
 |                            |
 +----------------------------+

The way urwid works makes doing this nicely hard.  Simply putting the
text in a ListBox "works" but because the listbox is a box widget we
can't let it choose its height: either we'll end up having the text
scrollable in some situations where there is enough space on the
screen to show it all or when the screen is large there will be a
massive ugly space between the text and the following widgets.

Because you can't make a widget that behaves the way we want, this
module gives a way of providing a list of widgets to display in a Pile
and and nominating one of them to be made scrollable. A title, a list
of widgets and index to be scrollable is bundled up into an object
called a "stretchy" but is a bad name but at least easily greppable.
�N)�ListBox�Pilec@s@eZdZddgZdd�Zdd�Zdd�Zed	d
��Zdd�Z	d
S)�Stretchy�opened�closedcCs||_||_||_||_dS)z�
        title: goes in the LineBox
        widgets: list of widgets to put in the pile
        stretchy_index: index into widgets of widget to wrap in ListBox
        focus_index: index into widgets of initial focus
        N)�title�widgets�stretchy_index�focus_index)�selfrrr	r
�r�1/usr/share/subiquity/subiquitycore/ui/stretchy.py�__init__9s
zStretchy.__init__cC�dS)z1Called when the stretchy is placed on the screen.Nr�rrrr
rEszStretchy.openedcCr)z4Called when the stretchy is removed from the screen.Nrrrrr
rIszStretchy.closedcCs|j|jS�N)rr	rrrr
�
stretchy_wLszStretchy.stretchy_wcs0t�|d�fdd��t�|d�fdd��dS)Nrc�
��d�S)Nr)�enterr��contextrr
�<lambda>Q�
z)Stretchy.attach_context.<locals>.<lambda>rcr)Nr)�exitrrrr
rRr)�urwid�connect_signal)rrrrr
�attach_contextPszStretchy.attach_contextN)
�__name__�
__module__�__qualname__�signalsrrr�propertyrrrrrr
r5s
r)�	metaclassc@sHeZdZdZeejg�Zdd�Zdd�Z	e
dd��Zdd	�Zd
d�Z
dS)
�StretchyOverlayTc	s�|�_��_t�jg��_��fdd��t�fdd�t�j�D��}�j|_	t
jt
jt
j
t
jt
j|ddd�dddd	��jd
�ddd�dddd	��_dS)Ncs|�jkrdd�jfSd|fS)N�weight��pack)r	�listbox)�i�w)r�stretchyrr
�entry^s
z'StretchyOverlay.__init__.<locals>.entrycsg|]	\}}�||��qSrr)�.0r(r))r+rr
�
<listcomp>esz,StretchyOverlay.__init__.<locals>.<listcomp>�)�left�rightr%)�relative�d)�top�bottom�height)r�)�bottom_wr*rrr'r�	enumeraterr
�focus_positionr�Filler�Padding�LineBoxr�top_w)rr7r*�
inner_piler)r+rr*r
rYs0�����	�zStretchyOverlay.__init__c
Cs�|\}}t|d�}|d}d}t|jj�D]*\}}	||jjkr qtj|	��vr3|	�|f|�}
||
7}q|	�	d|�}||d7}q||krL||dfdfS|jj
�|f|�}|||krc|||fdfS||dfdfS)N�P��rr%FT)�minr8r*rr	r�FLOW�sizing�rowsr&r)
r�size�focus�maxcol�maxrow�outercol�innercol�
fixed_rowsr(�widgetrE�w_size�stretchy_ideal_rowsrrr
�	_top_sizeus$

zStretchyOverlay._top_sizecCs|jSr)r=rrrr
rG�szStretchyOverlay.focuscCs4|�|d�\}}|p|jj��|jj_|j�||�S)NT)	rPr*r�
selectabler'�base_widget�_selectabler=�keypress)rrF�key�top_size�scrollbar_visiblerrr
rT�s�zStretchyOverlay.keypressc	Cs�|j�|d�}|��r|��st�|�S|�||�\}}|j�||�}t�|�}|d|dd}|d|dd}t�||||�S)NFrr.r%)	r7�render�colsrEr�CompositeCanvasrPr=�
CanvasOverlay)	rrFrG�bottom_crV�_�top_cr/r3rrr
rX�s

zStretchyOverlay.renderN)rrrrS�	frozensetr�BOX�_sizingrrPr!rGrTrXrrrr
r#Us!
r#)	�__doc__r�subiquitycore.ui.containerrr�MetaSignalsr�Widgetr#rrrr
�<module>s
! 

Zerion Mini Shell 1.0