%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__/selector.cpython-310.pyc

o

K��^��@s�ddlmZmZmZmZmZmZmZm	Z	ddl
mZmZm
Z
ddlmZddlmZGdd�de
�ZGdd�de
�ZGd	d
�d
e�ZGdd�d�ZGd
d�de�ZGdd�de
�ZdS)�)�ACTIVATE�AttrWrap�CompositeCanvas�connect_signal�LineBox�Padding�
PopUpLauncher�Text)�Columns�ListBox�
WidgetWrap)�Color)�widget_widthcsDeZdZdgZdd�Zd
�fdd�	Zdd�Zd	d
�Zdd�Z�Z	S)�ClickableThing�clickcC�dS�NT���selfrr�1/usr/share/subiquity/subiquitycore/ui/selector.py�
selectable(�zClickableThing.selectableFcs*t��||�}|rt|�}|�|�|_|S�N)�super�renderr�get_cursor_coords�cursor)r�size�focus�c��	__class__rrr+s
zClickableThing.rendercCr)z�
        Return the position of the cursor if visible.  This method
        is required for widgets that display a cursor.
        )rrr)rrrrrr3sz ClickableThing.get_cursor_coordscCrrr)rr�x�yrrr�move_cursor_to_coords:rz$ClickableThing.move_cursor_to_coordscCs |j|tkr	|S|�d�dS)Nr)�_command_mapr�_emit�rr�keyrrr�keypress=szClickableThing.keypress)F)
�__name__�
__module__�__qualname__�signalsrrrr%r*�
__classcell__rrr!rr%srcs4eZdZdZ�fdd�Zdd�Z�fdd�Z�ZS)�_PopUpSelectDialogz.A list of PopUpButtons with a box around them.c
s�||_g}t|jj�D]O\}}|jr)t|j�}t|d|j|�||kr&d}nd}n|j}d}tdt	d�f|dt	|�fg�}|jrGt
|dd�}nt
|d�}t||jjj
d	�}|�|�qt|�}	||	j_t��t�t|	���dS)
Nru◂ ����menu_button�menu_button focus�
info_minor)�width)�parent�	enumerate�_options�enabledr�labelrrr
r	r�UrwidPadding�_paddingr7�appendr�base_widget�focus_positionr�__init__r
�bodyr)
rr8�	cur_index�group�i�option�btn�rhs�row�list_boxr!rrrBFs0


�
z_PopUpSelectDialog.__init__cCs||j_|j��dSr)r8�index�close_pop_up)rrHrLrrrrcsz_PopUpSelectDialog.clickcs$|dkr|j��dSt��||�S)N�esc)r8rMrr*r(r!rrr*gsz_PopUpSelectDialog.keypress)r+r,r-�__doc__rBrr*r/rrr!rr0Cs
r0c@seZdZdS)�
SelectorErrorN)r+r,r-rrrrrPnsrPc@seZdZdd�ZdS)�OptioncCst|t�s-t|t�r|j|_|j|_|j|_n[t|t�r&||_d|_||_nLtd|����t|�dkrA|d|_d|_|d|_n1t|�dkrW|d|_|d|_|d|_nt|�dkrm|d|_|d|_|d|_ntd|��t|jt�r�t	t
|j��|_dSdS)NTzinvalid option r2rr3�zinvalid option %r)�
isinstance�tuplerQr<r;�value�strrP�lenr	�_�r�valrrrrBts4









�zOption.__init__N)r+r,r-rBrrrrrQrsrQcs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�	_Launchercs||_t��|�dSr)r8rrB)rr8�childr!rrrB�sz_Launcher.__init__cC�
|j��Sr)r8�
create_pop_uprrrrr^��
z_Launcher.create_pop_upcCr]r)r8�get_pop_up_parametersrrrrr`�r_z_Launcher.get_pop_up_parameters)r+r,r-rBr^r`r/rrr!rr[�sr[cs�eZdZdZdgZd#�fdd�	Zdd�Zdd	�Zd
d�Ze	dd
��Z
e
jdd
��Z
e	dd��Zejdd��Zdd�Z
dd�Zdd�Ze	dd��Zejdd��Zdd�Zdd�Zdd �Zd!d"�Z�ZS)$�Selectorz�A widget that allows the user to chose between options by popping
       up a list of options.

    (A bit like <select> in an HTML form).
    �selectrcs�ttd��|_tttdtd�f|jdtd�fgdd�dd��|_g}|D]	}|�t|��q$||_	|�
|�t��t
||j��dS)	Nr1r2�[rRu▾ ])�dividecharsr4r5)rr	�_iconr=rr
r>r?rQ�options�
_set_indexrrBr[)r�optsrLrf�optr!rrrB�s"

���
zSelector.__init__cCs|jjSr)r>r7rrrr�get_natural_width�szSelector.get_natural_widthcCs|j|tkr	|S|��dSr)r&r�open_pop_upr(rrrr*�szSelector.keypresscCs|j|j|j_||_dSr)r:r<re�_w�_indexrYrrrrg�s
zSelector._set_indexcCs|jSr)rmrrrrrL�szSelector.indexcCs"|�d|j|j�|�|�dS)Nrb)r'r:rUrgrYrrrrL�scCs|jdd�Sr�r:rrrrrf��zSelector.optionscCs&||_tdd�|jD��d|j_dS)NcSsg|]}t|j��qSr)rr<)�.0�orrr�
<listcomp>�sz$Selector.options.<locals>.<listcomp>�)r:�maxr>r7rYrrrrf�s��cC�"|jD]}|j|kr|SqdSr)r:r<)rr<rirrr�option_by_label��


��zSelector.option_by_labelcCrur)r:rU)rrUrirrr�option_by_value�rwzSelector.option_by_valuecCs
|j|Srrn)rrLrrr�option_by_index�r_zSelector.option_by_indexcCs|j|jjSr)r:rmrUrrrrrU�rozSelector.valuecCs8t|j�D]\}}|j|kr|�|�dSqtd|��)Nzcannot set value to %r)r9r:rUrg�AttributeError)rrZrFrirrrrU�s

�
cCst||j�Sr)r0rLrrrrr^�szSelector.create_pop_upcCs$d|jd|jjt|j�dd�S)Nrr2r3)�left�top�
overlay_width�overlay_height)rLr>r7rWr:rrrrr`�s�zSelector.get_pop_up_parameterscC�|j��dSr)rlrkrrrrrk�zSelector.open_pop_upcCrr)rlrMrrrrrMr�zSelector.close_pop_up)r)r+r,r-rOr.rBrjr*rg�propertyrL�setterrfrvrxryrUr^r`rkrMr/rrr!rra�s4





raN)�urwidrrrrrrr=rr	�subiquitycore.ui.containerr
rr�subiquitycore.ui.utilsr
�subiquitycore.ui.widthrrr0�	ExceptionrPrQr[rarrrr�<module>s(+ 

Zerion Mini Shell 1.0