Table

Tables display read-only tabular data with pagination. Use F7/F8 to page through large datasets.
Basic Usage
from ux3270.dialog import Table
table = Table("INVENTORY LIST", panel_id="INV01")
table.add_column("ID")
table.add_column("Name")
table.add_column("Qty", align="right")
table.add_column("Status")
table.add_row("001", "Widget A", "100", "Active")
table.add_row("002", "Widget B", "50", "Active")
table.add_row("003", "Gadget C", "0", "Out of Stock")
table.show()
Column Alignment
table.add_column("Amount", align="right") # Right-align numbers
table.add_column("Name", align="left") # Left-align text (default)
Column Width
By default, columns auto-size to fit content. You can specify a fixed width:
Header Fields
Add input fields above the table for filtering or positioning:
table.add_header_field("Position to", length=20)
result = table.show()
position = result["Position to"] if result else ""
Pagination
Tables automatically paginate based on terminal height:
- F7 or Page Up - Previous page
- F8 or Page Down - Next page
The row count message shows current position: ROW 1 TO 10 OF 50
Auto-Truncation
If content is too wide for the terminal, long columns are automatically truncated with a > indicator:
ID Name Description
--- --------------- ---------------------------
001 Widget A This is a very long descrip>
002 Widget B Short desc
API Reference
ux3270.dialog.Table
IBM 3270-style table/list display with pagination.
Displays tabular data with column headers following CUA conventions: - Panel ID at top-left, title centered - Optional header fields (e.g., "Position to" filter) - Column headers in intensified text - Data rows in default (green) color - Row count/pagination info on message line - F7/F8 for page up/down (CUA standard) - Function keys at bottom
The dialog builds a Screen definition and hands control to Screen for all rendering and input handling.
__init__(title='', panel_id='', instruction='')
Initialize a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Table title (displayed in uppercase per IBM convention) |
''
|
panel_id
|
str
|
Optional panel identifier (shown at top-left per CUA) |
''
|
instruction
|
str
|
Optional instruction text |
''
|
add_column(name, width=None, align='left')
Add a column definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Column name (used as header) |
required |
width
|
Optional[int]
|
Display width (None = auto-calculate from content) |
None
|
align
|
Literal['left', 'right']
|
Text alignment ("left" or "right") |
'left'
|
Returns:
| Type | Description |
|---|---|
Table
|
Self for method chaining |
add_row(*values)
Add a row to the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Column values for the row |
()
|
Returns:
| Type | Description |
|---|---|
Table
|
Self for method chaining |
add_header_field(label, length=10, default='', field_type=FieldType.TEXT)
Add a header field (e.g., "Position to" filter).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Field label |
required |
length
|
int
|
Field length |
10
|
default
|
str
|
Default value |
''
|
field_type
|
FieldType
|
Field type |
TEXT
|
Returns:
| Type | Description |
|---|---|
Table
|
Self for method chaining |
get_header_values()
Get current header field values.
show()
Display the table with pagination and wait for user input.
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, str]]
|
Dictionary of header field values, or None if no header fields. |