%PDF- %PDF-
Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/ |
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/table.cpython-310.pyc |
o K��^E � @ s� d Z ddlmZ ddlZddlmZmZmZmZ ddl m Z ddlZddlZe� d�ZejG dd� d��Zd d � ZG dd� de�Zd d� ZG dd� de�ZG dd� de�ZG dd� de�Zedkr�ddlmZ ed� eee�d�dejddd�fe�d�g�ee�d�ejddd�e�d �e�d!�g�ged"d#d$�ed"d%d&�d'�d(d)�Zed*efe�d+�g�Zd,d-� Zejeed.�Ze� � dS dS )/aI A table widget. One of the principles of urwid is that widgets get their size from their container rather than deciding it for themselves. At times (as in stretchy.py) this does not make for the best UI. This module defines TablePile and TableListBox widgets that by default only take up as much horizontal space as needed for their cells. If the table wants more horizontal space than is present, there is a degree of customization available as to what to do: you can tell which column to allow to shrink, and to omit another column to try to keep the shrinking column above a given threshold. You can also let columns take all available space, as is the urwid default. Other features include cells that span multiple columns and binding tables together so that they use the same widths for their columns. There is not a lot of care about how the various features interact, so be careful, or rather do not be surprised when things break. Gotchas that have occurred to me during implementation: 1. This code needs to know the "natural width" of anything you put into a table. Don't be surprised if widget_width needs extending. 2. Having a cell that spans multiple columns span a column that can shrink or be omitted will be confusing. 3. Binding tables together that have different column options will similarly not do anything sensible. 4. You can wrap table rows in decorators that do not affect their size (AttrMap, etc) but do not use ones that do affect size (Padding, etc) or things will get confusing. 5. I haven't tested this code with more than one column that can shrink or more than one column that can be omitted. Example: ``` v = TablePile([ TableRow([ urwid.Text("aa"), (2, urwid.Text("0123456789"*5, wrap='clip')), urwid.Text('eeee')]), TableRow([ urwid.Text("ccc"), urwid.Text("0123456789"*4, wrap='clip'), urwid.Text('fff'*10), urwid.Text('g')]), ], { 0: ColSpec(omittable=True), 1: ColSpec(can_shrink=True, min_width=10), }, spacing=4) ``` � )�defaultdictN)�Columns�ListBox�Pile� WidgetWrap)�widget_widthzsubiquitycore.ui.tablec @ sL e Zd ZdZejdd�Zejdd�Zejdd�Zejdd�Z ejdd�Z dS )�ColSpeczDetails about a column.T)�defaultFr N)�__name__� __module__�__qualname__�__doc__�attr�ib�pack� can_shrink� min_width� omittable�rpad� r r �./usr/share/subiquity/subiquitycore/ui/table.pyr Y s r c s>