%PDF- %PDF-
Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/ |
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/stretchy.cpython-310.pyc |
o K��^b � @ sF d Z ddlZddlmZmZ G dd� dejd�ZG dd� dej�ZdS ) a Custom 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@ e Zd ZddgZdd� Zdd� Zdd� Zed d � �Zdd� Z d S )�Stretchy�opened�closedc C s || _ || _|| _|| _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)�selfr r r r � r �1/usr/share/subiquity/subiquitycore/ui/stretchy.py�__init__9 s zStretchy.__init__c C � dS )z1Called when the stretchy is placed on the screen.Nr �r r r r r E s zStretchy.openedc C r )z4Called when the stretchy is removed from the screen.Nr r r r r r I s zStretchy.closedc C s | j | j S �N)r r r r r r � stretchy_wL s zStretchy.stretchy_wc s0 t �| d� fdd�� t �| d� fdd�� d S )Nr c � � � d�S )Nr )�enterr ��contextr r �<lambda>Q � z)Stretchy.attach_context.<locals>.<lambda>r c r )Nr )�exitr r r r r R r )�urwid�connect_signal)r r r r r �attach_contextP s zStretchy.attach_contextN) �__name__� __module__�__qualname__�signalsr r r �propertyr r r r r r r 5 s r )� metaclassc @ sH e Zd ZdZeejg�Zdd� Zdd� Z e dd� �Zdd � Zd d� Z dS ) �StretchyOverlayTc s� |�_ ��_t�jg��_��fdd�� t� fdd�t�j�D ��}�j|_ t jt jt j t jt j|ddd�dddd ��jd �ddd�dddd ��_d S )Nc s | �j krdd� jfS d|fS )N�weight� �pack)r �listbox)�i�w)r �stretchyr r �entry^ s z'StretchyOverlay.__init__.<locals>.entryc s g | ] \}}� ||��qS r r )�.0r( r) )r+ r r � <listcomp>e s z,StretchyOverlay.__init__.<locals>.<listcomp>� )�left�rightr% )�relative�d )�top�bottom�height)r � )�bottom_wr* r r r'