Table¶
- class Table(width: NUM, height: NUM, headings: Tuple[str], widths: Tuple[float], alignments: Tuple[str], position: FLOAT, draggable: bool, return_clicked_cells: bool, func: callable)¶
Tables are panes that can be used to gain further functionality from charts. They are intended to be used for watchlists, order management, or position management. It should be accessed from the
create_tablecommon method.The
TableandRowobjects act as dictionaries, and can be manipulated as such.width/heightEither given as a percentage (a
floatbetween 0 and 1) or as an integer representing pixel size.widthsGiven as a
floatbetween 0 and 1.positionUsed as you would with
create_subchart, representing how the table will float within the window.draggableIf
True, then the window can be dragged to any position within the window.return_clicked_cellsIf
True, an additional parameter will be emitted to thefuncgiven, containing the heading name of the clicked cell.funcIf given, this will be called when a row is clicked, returning the
Rowobject in question.
- new_row(*values, id: int) Row¶
Creates a new row within the table, and returns a
Rowobject.if
idis passed it should be unique to all other rows. Otherwise, theidwill be randomly generated.Rows can be passed a string (header) item or a tuple to set multiple headings:
row['Symbol'] = 'AAPL' row['Symbol', 'Action'] = 'AAPL', 'BUY'
- clear()¶
Clears and deletes all table rows.
- format(column: str, format_str: str)¶
Sets the format to be used for the given column.
Table.VALUEshould be used as a placeholder for the cell value. For example:table.format('Daily %', f'{table.VALUE} %') table.format('PL', f'$ {table.VALUE}')
- visible(visible: bool)¶
Sets the visibility of the Table.
Tip
All of these methods can be applied to the
headerparameter.Tables can also have a footer containing a number of text boxes. To initialize this, call the
footerattribute with the number of textboxes to be used:table.footer(3) # Footer will be displayed, with 3 text boxes.
To edit the textboxes, treat
footeras a list:table.footer[0] = 'Text Box 1' table.footer[1] = 'Text Box 2' table.footer[2] = 'Text Box 3'
When calling footer, the
funcparameter can also be used to convert each textbox into a button:def on_footer_click(table, box_index): print(f'Box number {box_index+1} was pressed.') table.footer(3, func=on_footer_click)