HOME


Mini Shell 1.0
DIR: /snap/core20/current/usr/share/subiquity/subiquitycore/ui/__pycache__/
Upload File :
Current File : //snap/core20/current/usr/share/subiquity/subiquitycore/ui/__pycache__/selector.cpython-38.pyc
U

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�clickcCsdS�NT���selfrr�1/usr/share/subiquity/subiquitycore/ui/selector.py�
selectable(szClickableThing.selectableFcs*t��||�}|r&t|�}|�|�|_|S�N)�super�renderr�get_cursor_coordsZcursor)r�sizeZfocus�c��	__class__rrr+s
zClickableThing.rendercCsdS)z�
        Return the position of the cursor if visible.  This method
        is required for widgets that display a cursor.
        )rrr)rrrrrr3sz ClickableThing.get_cursor_coordscCsdSrr)rr�x�yrrr�move_cursor_to_coords:sz$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__rrrrr%srcs4eZdZdZ�fdd�Zdd�Z�fdd�Z�ZS)�_PopUpSelectDialogz.A list of PopUpButtons with a box around them.c
s�||_g}t|jj�D]�\}}|jrRt|j�}t|d|j|�||krLd}q\d}n
|j}d}tdt	d�f|dt	|�fg�}|jr�t
|dd�}n
t
|d�}t||jjj
d	�}|�|�qt|�}	||	j_t��t�t|	���dS)
Nru◂ ����menu_button�menu_button focusZ
info_minor)�width)�parent�	enumerate�_options�enabledr�labelrrr
r	r�UrwidPadding�_paddingr2�appendrZbase_widgetZfocus_positionr�__init__r
Zbodyr)
rr3Z	cur_index�group�iZoption�btnZrhs�rowZlist_boxrrrr;Fs0


�
z_PopUpSelectDialog.__init__cCs||j_|j��dSr)r3�index�close_pop_up)rr>r@rrrrcsz_PopUpSelectDialog.clickcs&|dkr|j��nt��||�SdS)NZesc)r3rArr&r$rrrr&gsz_PopUpSelectDialog.keypress)r'r(r)�__doc__r;rr&r+rrrrr,Csr,c@seZdZdS)�
SelectorErrorN)r'r(r)rrrrrCnsrCc@seZdZdd�ZdS)�OptioncCst|t�sXt|t�r.|j|_|j|_|j|_q�t|t�rL||_d|_||_q�td|��n�t|�dkr�|d|_d|_|d|_nbt|�dkr�|d|_|d|_|d|_n6t|�dkr�|d|_|d|_|d|_n
td|��t|jt�r�t	t
|j��|_dS)NTzinvalid option %rr.rr/�)�
isinstance�tuplerDr7r6�value�strrC�lenr	�_�r�valrrrr;ts2









zOption.__init__N)r'r(r)r;rrrrrDrsrDcs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�	_Launchercs||_t��|�dSr)r3rr;)rr3Zchildrrrr;�sz_Launcher.__init__cCs
|j��Sr)r3�
create_pop_uprrrrrO�sz_Launcher.create_pop_upcCs
|j��Sr)r3�get_pop_up_parametersrrrrrP�sz_Launcher.get_pop_up_parameters)r'r(r)r;rOrPr+rrrrrN�srNcs�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|��qH||_	|�
|�t��t
||j��dS)	Nr-r.�[rEu▾ ])Zdividecharsr0r1)rr	�_iconr8rr
r9r:rD�options�
_set_indexrr;rN)rZoptsr@rU�optrrrr;�s$

���
zSelector.__init__cCs|jjSr)r9r2rrrr�get_natural_width�szSelector.get_natural_widthcCs|j|tkr|S|��dSr)r"r�open_pop_upr$rrrr&�szSelector.keypresscCs|j|j|j_||_dSr)r5r7rT�_w�_indexrLrrrrV�szSelector._set_indexcCs|jSr)r[rrrrr@�szSelector.indexcCs"|�d|j|j�|�|�dS)NrR)r#r5rHrVrLrrrr@�scCs|jdd�Sr�r5rrrrrU�szSelector.optionscCs&||_tdd�|jD��d|j_dS)NcSsg|]}t|j��qSr)rr7)�.0�orrr�
<listcomp>�sz$Selector.options.<locals>.<listcomp>�)r5�maxr9r2rLrrrrU�s��cCs"|jD]}|j|kr|SqdSr)r5r7)rr7rWrrr�option_by_label�s

zSelector.option_by_labelcCs"|jD]}|j|kr|SqdSr)r5rH)rrHrWrrr�option_by_value�s

zSelector.option_by_valuecCs
|j|Srr\)rr@rrr�option_by_index�szSelector.option_by_indexcCs|j|jjSr)r5r[rHrrrrrH�szSelector.valuecCs<t|j�D]"\}}|j|kr
|�|�dSq
td|��dS)Nzcannot set value to %r)r4r5rHrV�AttributeError)rrMr=rWrrrrH�s


cCst||j�Sr)r,r@rrrrrO�szSelector.create_pop_upcCs$d|jd|jjt|j�dd�S)Nrr.r/)�left�topZ
overlay_widthZoverlay_height)r@r9r2rJr5rrrrrP�s�zSelector.get_pop_up_parameterscCs|j��dSr)rZrYrrrrrYszSelector.open_pop_upcCs|j��dSr)rZrArrrrrAszSelector.close_pop_up)r)r'r(r)rBr*r;rXr&rV�propertyr@�setterrUrbrcrdrHrOrPrYrAr+rrrrrQ�s2





rQN)Zurwidrrrrrrr8rr	Zsubiquitycore.ui.containerr
rrZsubiquitycore.ui.utilsr
Zsubiquitycore.ui.widthrrr,�	ExceptionrCrDrNrQrrrr�<module>s(+