Skip to content

Commit 415db2f

Browse files
author
James Boulton
committed
Table works.
1 parent cdfde84 commit 415db2f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

dashio/iotcontrol/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ControlName(Enum):
5454
LOG = "LOG"
5555
LBL = "LBL"
5656
MAP = "MAP"
57+
TABLE = "TBL"
5758

5859

5960
class Icon(Enum):

dashio/iotcontrol/table.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ def __init__(
131131
precision, by default Precision.OFF
132132
font_size : int, by default 12
133133
The size of the font.
134-
134+
label_width_percent : int
135+
Label width as a percent.
136+
colmns : int
137+
Number of table columns including the label.
138+
column_headings : List
139+
The headings for the table columns.
135140
column_no : int, optional default is 1. Must be 1..3
136141
The Dash App reports its screen size in columns. column_no allows you to specify which column no to load into.
137142
Each control can store three configs that define how the device looks for Dash apps installed on single column
@@ -191,16 +196,16 @@ def from_cfg_dict(cls, cfg_dict: dict, column_no=1):
191196

192197
def _send_row(self, table_row: TableRow) -> str:
193198
header_str = self._control_hdr_str
194-
columns = '\t'.join(map(str, table_row.columns[:self._max_columns]))
199+
columns = '\t'.join(map(str, table_row.columns[:self._max_columns - 1]))
195200
if table_row.units is not None:
196201
row_label = table_row.label
197202
if table_row.label is None:
198203
row_label = ""
199-
return f"{header_str}\t{len(self._rows)}\t{columns}\t{row_label}\t{table_row.units}\n"
204+
return f"{header_str}{len(self._rows)}\t{columns}\t{row_label}\t{table_row.units}\n"
200205
else:
201206
if table_row.label is None:
202-
return f"{header_str}\t{len(self._rows)}\t{columns}\n"
203-
return f"{header_str}\t{len(self._rows)}\t{columns}\t{row_label}\n"
207+
return f"{header_str}{len(self._rows)}\t{columns}\n"
208+
return f"{header_str}{len(self._rows)}\t{columns}\t{row_label}\n"
204209

205210
def add_table_row(self, table_row: TableRow):
206211
"""Add a row to the table and send it"""

0 commit comments

Comments
 (0)