flet-datatable2 0.1.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flet-datatable2 might be problematic. Click here for more details.

@@ -0,0 +1,864 @@
1
+ from typing import Any, List, Optional, Union
2
+
3
+ from flet.core.alignment import Alignment
4
+ from flet.core.animation import AnimationValue
5
+ from flet.core.badge import BadgeValue
6
+ from flet.core.border import Border, BorderSide
7
+ from flet.core.box import BoxDecoration
8
+ from flet.core.constrained_control import ConstrainedControl
9
+ from flet.core.control import Control, OptionalNumber
10
+ from flet.core.gradients import Gradient
11
+ from flet.core.ref import Ref
12
+ from flet.core.text_style import TextStyle
13
+ from flet.core.theme import CheckboxTheme
14
+ from flet.core.tooltip import TooltipValue
15
+ from flet.core.types import (
16
+ BorderRadiusValue,
17
+ ClipBehavior,
18
+ ColorEnums,
19
+ ColorValue,
20
+ ControlStateValue,
21
+ DurationValue,
22
+ IconEnums,
23
+ IconValue,
24
+ OffsetValue,
25
+ OptionalControlEventCallable,
26
+ ResponsiveNumber,
27
+ RotateValue,
28
+ ScaleValue,
29
+ )
30
+
31
+ from flet_datatable2.datacolumn2 import DataColumn2
32
+ from flet_datatable2.datarow2 import DataRow2
33
+
34
+
35
+ class DataTable2(ConstrainedControl):
36
+ """In-place replacement of standard Flet [DataTable](https://flet.dev/docs/controls/datatable).
37
+
38
+ Has the header row always fixed and core of the table (with data rows) scrollable and stretching to max width/height of it's container.
39
+ By using [DataColumn2](datacolumn2.md) instead of [DataColumn](https://flet.dev/docs/controls/datatable#datacolumn) it is possible to control relative column sizes (setting them to S, M and L).
40
+ [DataRow2](datarow2.md) provides row-level tap event handlers.
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ columns: List[DataColumn2],
46
+ rows: Optional[List[DataRow2]] = None,
47
+ empty: Optional[Control] = None,
48
+ bottom_margin: OptionalNumber = None,
49
+ lm_ratio: OptionalNumber = None,
50
+ sm_ratio: OptionalNumber = None,
51
+ fixed_left_columns: Optional[int] = None,
52
+ fixed_top_rows: Optional[int] = None,
53
+ fixed_columns_color: Optional[ColorValue] = None,
54
+ fixed_corner_color: Optional[ColorValue] = None,
55
+ min_width: OptionalNumber = None,
56
+ sort_ascending: Optional[bool] = None,
57
+ show_checkbox_column: Optional[bool] = None,
58
+ show_heading_checkbox: Optional[bool] = None,
59
+ heading_checkbox_theme: Optional[CheckboxTheme] = None,
60
+ data_row_checkbox_theme: Optional[CheckboxTheme] = None,
61
+ sort_column_index: Optional[int] = None,
62
+ sort_arrow_icon: Optional[IconValue] = None,
63
+ sort_arrow_animation_duration: Optional[DurationValue] = None,
64
+ show_bottom_border: Optional[bool] = None,
65
+ is_horizontal_scroll_bar_visible: Optional[bool] = None,
66
+ is_vertical_scroll_bar_visible: Optional[bool] = None,
67
+ border: Optional[Border] = None,
68
+ border_radius: Optional[BorderRadiusValue] = None,
69
+ horizontal_lines: Optional[BorderSide] = None,
70
+ vertical_lines: Optional[BorderSide] = None,
71
+ checkbox_horizontal_margin: OptionalNumber = None,
72
+ checkbox_alignment: Optional[Alignment] = None,
73
+ column_spacing: OptionalNumber = None,
74
+ data_row_color: ControlStateValue[ColorValue] = None,
75
+ data_row_height: OptionalNumber = None,
76
+ # data_row_min_height: OptionalNumber = None,
77
+ # data_row_max_height: OptionalNumber = None,
78
+ data_text_style: Optional[TextStyle] = None,
79
+ bgcolor: Optional[ColorValue] = None,
80
+ gradient: Optional[Gradient] = None,
81
+ divider_thickness: OptionalNumber = None,
82
+ heading_row_color: ControlStateValue[ColorValue] = None,
83
+ heading_row_height: OptionalNumber = None,
84
+ heading_text_style: Optional[TextStyle] = None,
85
+ heading_row_decoration: Optional[BoxDecoration] = None,
86
+ horizontal_margin: OptionalNumber = None,
87
+ clip_behavior: Optional[ClipBehavior] = None,
88
+ on_select_all: OptionalControlEventCallable = None,
89
+ #
90
+ # ConstrainedControl
91
+ #
92
+ ref: Optional[Ref] = None,
93
+ key: Optional[str] = None,
94
+ width: OptionalNumber = None,
95
+ height: OptionalNumber = None,
96
+ left: OptionalNumber = None,
97
+ top: OptionalNumber = None,
98
+ right: OptionalNumber = None,
99
+ bottom: OptionalNumber = None,
100
+ expand: Union[None, bool, int] = None,
101
+ expand_loose: Optional[bool] = None,
102
+ col: Optional[ResponsiveNumber] = None,
103
+ opacity: OptionalNumber = None,
104
+ rotate: Optional[RotateValue] = None,
105
+ scale: Optional[ScaleValue] = None,
106
+ offset: Optional[OffsetValue] = None,
107
+ aspect_ratio: OptionalNumber = None,
108
+ animate_opacity: Optional[AnimationValue] = None,
109
+ animate_size: Optional[AnimationValue] = None,
110
+ animate_position: Optional[AnimationValue] = None,
111
+ animate_rotation: Optional[AnimationValue] = None,
112
+ animate_scale: Optional[AnimationValue] = None,
113
+ animate_offset: Optional[AnimationValue] = None,
114
+ on_animation_end: OptionalControlEventCallable = None,
115
+ tooltip: Optional[TooltipValue] = None,
116
+ badge: Optional[BadgeValue] = None,
117
+ visible: Optional[bool] = None,
118
+ disabled: Optional[bool] = None,
119
+ data: Any = None,
120
+ ):
121
+ ConstrainedControl.__init__(
122
+ self,
123
+ ref=ref,
124
+ key=key,
125
+ width=width,
126
+ height=height,
127
+ left=left,
128
+ top=top,
129
+ right=right,
130
+ bottom=bottom,
131
+ expand=expand,
132
+ expand_loose=expand_loose,
133
+ col=col,
134
+ opacity=opacity,
135
+ rotate=rotate,
136
+ scale=scale,
137
+ offset=offset,
138
+ aspect_ratio=aspect_ratio,
139
+ animate_opacity=animate_opacity,
140
+ animate_size=animate_size,
141
+ animate_position=animate_position,
142
+ animate_rotation=animate_rotation,
143
+ animate_scale=animate_scale,
144
+ animate_offset=animate_offset,
145
+ on_animation_end=on_animation_end,
146
+ tooltip=tooltip,
147
+ badge=badge,
148
+ visible=visible,
149
+ disabled=disabled,
150
+ data=data,
151
+ )
152
+
153
+ self.columns = columns
154
+ self.rows = rows
155
+ self.empty = empty
156
+ self.fixed_left_columns = fixed_left_columns
157
+ self.fixed_top_rows = fixed_top_rows
158
+ self.fixed_columns_color = fixed_columns_color
159
+ self.fixed_corner_color = fixed_corner_color
160
+ self.bottom_margin = bottom_margin
161
+ self.lm_ration = lm_ratio
162
+ self.sm_ratio = sm_ratio
163
+ self.min_width = min_width
164
+ self.border = border
165
+ self.border_radius = border_radius
166
+ self.horizontal_lines = horizontal_lines
167
+ self.is_horizontal_scroll_bar_visible = is_horizontal_scroll_bar_visible
168
+ self.is_vertical_scroll_bar_visible = is_vertical_scroll_bar_visible
169
+ self.vertical_lines = vertical_lines
170
+ self.bgcolor = bgcolor
171
+ self.gradient = gradient
172
+ self.divider_thickness = divider_thickness
173
+ self.checkbox_horizontal_margin = checkbox_horizontal_margin
174
+ self.checkbox_alignment = checkbox_alignment
175
+ self.heading_checkbox_theme = heading_checkbox_theme
176
+ self.data_row_checkbox_theme = data_row_checkbox_theme
177
+ self.column_spacing = column_spacing
178
+ self.data_row_color = data_row_color
179
+ # self.data_row_min_height = data_row_min_height
180
+ # self.data_row_max_height = data_row_max_height
181
+ self.data_row_height = data_row_height
182
+ self.data_text_style = data_text_style
183
+ self.heading_row_color = heading_row_color
184
+ self.heading_row_height = heading_row_height
185
+ self.heading_text_style = heading_text_style
186
+ self.horizontal_margin = horizontal_margin
187
+ self.show_bottom_border = show_bottom_border
188
+ self.show_checkbox_column = show_checkbox_column
189
+ self.show_heading_checkbox = show_heading_checkbox
190
+ self.sort_ascending = sort_ascending
191
+ self.sort_column_index = sort_column_index
192
+ self.on_select_all = on_select_all
193
+ self.clip_behavior = clip_behavior
194
+ self.sort_arrow_icon = sort_arrow_icon
195
+ self.sort_arrow_animation_duration = sort_arrow_animation_duration
196
+ self.heading_row_decoration = heading_row_decoration
197
+
198
+ def _get_control_name(self):
199
+ return "datatable2"
200
+
201
+ def __contains__(self, item):
202
+ return item in self.__columns or item in self.__rows
203
+
204
+ def before_update(self):
205
+ super().before_update()
206
+ visible_columns = list(filter(lambda column: column.visible, self.__columns))
207
+ visible_rows = list(filter(lambda row: row.visible, self.__rows))
208
+ assert (
209
+ len(visible_columns) > 0
210
+ ), "columns must contain at minimum one visible DataColumn"
211
+ assert all(
212
+ len(list(filter(lambda c: c.visible, row.cells))) == len(visible_columns)
213
+ for row in visible_rows
214
+ ), f"each visible DataRow must contain exactly as many visible DataCells as there are visible DataColumns ({len(visible_columns)})"
215
+ # assert (
216
+ # self.data_row_min_height is None
217
+ # or self.data_row_max_height is None
218
+ # or (self.data_row_min_height <= self.data_row_max_height)
219
+ # ), "data_row_min_height must be less than or equal to data_row_max_height"
220
+ assert (
221
+ self.divider_thickness is None or self.divider_thickness >= 0
222
+ ), "divider_thickness must be greater than or equal to 0"
223
+ assert self.sort_column_index is None or (
224
+ 0 <= self.sort_column_index < len(visible_columns)
225
+ ), f"sort_column_index must be greater than or equal to 0 and less than the number of columns ({len(visible_columns)})"
226
+ self._set_attr_json("border", self.__border)
227
+ self._set_attr_json("gradient", self.__gradient)
228
+ self._set_attr_json("borderRadius", self.__border_radius)
229
+ self._set_attr_json("horizontalLines", self.__horizontal_lines)
230
+ self._set_attr_json("verticalLines", self.__vertical_lines)
231
+ self._set_attr_json("dataRowColor", self.__data_row_color)
232
+ self._set_attr_json("headingRowColor", self.__heading_row_color)
233
+ self._set_attr_json("dataTextStyle", self.__data_text_style)
234
+ self._set_attr_json("headingTextStyle", self.__heading_text_style)
235
+ self._set_attr_json("headingCheckboxTheme", self.__heading_checkbox_theme)
236
+ self._set_attr_json("dataRowCheckboxTheme", self.__data_row_checkbox_theme)
237
+ self._set_attr_json(
238
+ "sortArrowAnimationDuration", self.__sort_arrow_animation_duration
239
+ )
240
+ self._set_attr_json("checkboxAlignment", self.__checkbox_alignment)
241
+ self._set_attr_json("headingRowDecoration", self.__heading_row_decoration)
242
+
243
+ def _get_children(self):
244
+ children = self.__columns + self.__rows
245
+
246
+ if isinstance(self.__empty, Control):
247
+ self.__empty._set_attr_internal("n", "empty")
248
+ children.append(self.__empty)
249
+ return children
250
+
251
+ # empty
252
+ @property
253
+ def empty(self) -> Control:
254
+ """
255
+ **NEW**
256
+
257
+ Placeholder control which is displayed whenever the data rows are empty. The widget will be displayed below heading row.
258
+ """
259
+ return self.__empty
260
+
261
+ @empty.setter
262
+ def empty(self, value: Control):
263
+ self.__empty = value
264
+
265
+ # columns
266
+ @property
267
+ def columns(self) -> List[DataColumn2]:
268
+ """
269
+ A list of [DataColumn2](datacolumn2.md) controls describing table columns.
270
+ """
271
+ return self.__columns
272
+
273
+ @columns.setter
274
+ def columns(self, value: List[DataColumn2]):
275
+ assert all(
276
+ isinstance(column, DataColumn2) for column in value
277
+ ), "columns must contain only DataColumn instances"
278
+ self.__columns = value
279
+
280
+ # rows
281
+ @property
282
+ def rows(self) -> Optional[List[DataRow2]]:
283
+ """
284
+ A list of [DataRow2](datarow2.md) controls defining table rows.
285
+ """
286
+ return self.__rows
287
+
288
+ @rows.setter
289
+ def rows(self, value: Optional[List[DataRow2]]):
290
+ self.__rows = value if value is not None else []
291
+ assert all(
292
+ isinstance(row, DataRow2) for row in self.__rows
293
+ ), "rows must contain only DataRow instances"
294
+
295
+ # fixed_left_columns
296
+ @property
297
+ def fixed_left_columns(self) -> Optional[int]:
298
+ """
299
+ **NEW**
300
+
301
+ The number of sticky columns fixed at the left side of the table. Check box column (if enabled) is also counted.
302
+ """
303
+ return self._get_attr("fixedLeftColumns")
304
+
305
+ @fixed_left_columns.setter
306
+ def fixed_left_columns(self, value: Optional[int]):
307
+ self._set_attr("fixedLeftColumns", value)
308
+
309
+ # fixed_top_rows
310
+ @property
311
+ def fixed_top_rows(self) -> Optional[int]:
312
+ """
313
+ **NEW**
314
+
315
+ The number of sticky rows fixed at the top of the table. The heading row is counted/included.
316
+ By defult the value is 1 which means header row is fixed.
317
+ Set to 0 in order to unstick the header, set to >1 in order to fix data rows (i.e. in order to fix both header and the first data row use value of 2).
318
+ """
319
+ return self._get_attr("fixedTopRows")
320
+
321
+ @fixed_top_rows.setter
322
+ def fixed_top_rows(self, value: Optional[int]):
323
+ self._set_attr("fixedTopRows", value)
324
+
325
+ # fixed_columns_color
326
+ @property
327
+ def fixed_columns_color(self) -> Optional[ColorValue]:
328
+ """
329
+ **NEW**
330
+
331
+ Backgound color of the sticky columns fixed via `fixed_left_columns`.
332
+ """
333
+ return self.__fixed_columns_color
334
+
335
+ @fixed_columns_color.setter
336
+ def fixed_columns_color(self, value: Optional[ColorValue]):
337
+ self.__fixed_columns_color = value
338
+ self._set_enum_attr("fixedColumnsColor", value, ColorEnums)
339
+
340
+ # fixed_corner_color
341
+ @property
342
+ def fixed_corner_color(self) -> Optional[ColorValue]:
343
+ """
344
+ **NEW**
345
+
346
+ Backgound color of the top left corner which is fixed when both `fixed_top_rows` and `fixed_left_columns` are greater than 0.
347
+ """
348
+ return self.__fixed_corner_color
349
+
350
+ @fixed_corner_color.setter
351
+ def fixed_corner_color(self, value: Optional[ColorValue]):
352
+ self.__fixed_corner_color = value
353
+ self._set_enum_attr("fixedCornerColor", value, ColorEnums)
354
+
355
+ # bottom_margin
356
+ @property
357
+ def bottom_margin(self) -> OptionalNumber:
358
+ """
359
+ **NEW**
360
+
361
+ If set, the table will have empty space added after the the last row.
362
+ """
363
+ return self._get_attr("bottomMargin")
364
+
365
+ @bottom_margin.setter
366
+ def bottom_margin(self, value: OptionalNumber):
367
+ self._set_attr("bottomMargin", value)
368
+
369
+ # sort_arrow_icon
370
+ @property
371
+ def sort_arrow_icon(self):
372
+ """
373
+ **NEW**
374
+
375
+ Icon to be displayed when sorting is applied to a column. If not set, the default icon is `Icons.ARROW_UPWARD`.
376
+ """
377
+ return self.__sort_arrow_icon
378
+
379
+ @sort_arrow_icon.setter
380
+ def sort_arrow_icon(self, value):
381
+ self.__sort_arrow_icon = value
382
+ self._set_enum_attr("sortArrowIcon", value, IconEnums)
383
+
384
+ # sort_arrow_animation_duration
385
+ @property
386
+ def sort_arrow_animation_duration(self) -> Optional[DurationValue]:
387
+ """
388
+ **NEW**
389
+
390
+ When changing sort direction an arrow icon in the header is rotated clockwise. The value defines the duration of the rotation animation.
391
+ If not set, the default animation duration is 150 ms.
392
+ """
393
+ return self.__sort_arrow_animation_duration
394
+
395
+ @sort_arrow_animation_duration.setter
396
+ def sort_arrow_animation_duration(self, value: Optional[DurationValue]):
397
+ self.__sort_arrow_animation_duration = value
398
+
399
+ # lm_ratio
400
+ @property
401
+ def lm_ratio(self) -> OptionalNumber:
402
+ """
403
+ **NEW**
404
+
405
+ Determines ratio of Large column's width to Medium column's width. I.e. 2.0 means that Large column is twice wider than Medium column.
406
+
407
+ The default value is `1.2`.
408
+ """
409
+ return self._get_attr("lmRatio")
410
+
411
+ @lm_ratio.setter
412
+ def lm_ratio(self, value: OptionalNumber):
413
+ self._set_attr("lmRatio", value)
414
+
415
+ # sm_ratio
416
+ @property
417
+ def sm_ratio(self) -> OptionalNumber:
418
+ """
419
+ **NEW**
420
+
421
+ Determines ratio of Small column's width to Medium column's width. I.e. 0.5 means that Small column is twice narrower than Medium column.
422
+
423
+ The default value is `0.67`.
424
+ """
425
+ return self._get_attr("smRatio")
426
+
427
+ @sm_ratio.setter
428
+ def sm_ratio(self, value: OptionalNumber):
429
+ self._set_attr("smRatio", value)
430
+
431
+ # min_width
432
+ @property
433
+ def min_width(self) -> OptionalNumber:
434
+ """
435
+ **NEW**
436
+
437
+ If set, the table will stop shrinking below the threshold and provide horizontal scrolling.
438
+ Useful for the cases with narrow screens (e.g. portrait phone orientation) and lots of columns.
439
+ """
440
+ return self._get_attr("minWidth")
441
+
442
+ @min_width.setter
443
+ def min_width(self, value: OptionalNumber):
444
+ self._set_attr("minWidth", value)
445
+
446
+ # border
447
+ @property
448
+ def border(self) -> Optional[Border]:
449
+ """
450
+ See DataTable [border](https://flet.dev/docs/controls/datatable#border).
451
+ """
452
+ return self.__border
453
+
454
+ @border.setter
455
+ def border(self, value: Optional[Border]):
456
+ self.__border = value
457
+
458
+ # border_radius
459
+ @property
460
+ def border_radius(self) -> Optional[BorderRadiusValue]:
461
+ """
462
+ See DataTable [border_radius](https://flet.dev/docs/controls/datatable#border_radius).
463
+ """
464
+ return self.__border_radius
465
+
466
+ @border_radius.setter
467
+ def border_radius(self, value: Optional[BorderRadiusValue]):
468
+ self.__border_radius = value
469
+
470
+ # horizontal_lines
471
+ @property
472
+ def horizontal_lines(self) -> Optional[BorderSide]:
473
+ """
474
+ See DataTable [horizontal_lines](https://flet.dev/docs/controls/datatable#horizontal_lines).
475
+ """
476
+ return self.__horizontal_lines
477
+
478
+ @horizontal_lines.setter
479
+ def horizontal_lines(self, value: Optional[BorderSide]):
480
+ self.__horizontal_lines = value
481
+
482
+ # vertical_lines
483
+ @property
484
+ def vertical_lines(self) -> Optional[BorderSide]:
485
+ """
486
+ See DataTable [vertical_lines](https://flet.dev/docs/controls/datatable#vertical_lines).
487
+ """
488
+ return self.__vertical_lines
489
+
490
+ @vertical_lines.setter
491
+ def vertical_lines(self, value: Optional[BorderSide]):
492
+ self.__vertical_lines = value
493
+
494
+ # checkbox_horizontal_margin
495
+ @property
496
+ def checkbox_horizontal_margin(self) -> OptionalNumber:
497
+ """
498
+ See DataTable [checkbox_horizontal_margin](https://flet.dev/docs/controls/datatable#checkbox_horizontal_margin).
499
+ """
500
+ return self._get_attr("checkboxHorizontalMargin")
501
+
502
+ @checkbox_horizontal_margin.setter
503
+ def checkbox_horizontal_margin(self, value: OptionalNumber):
504
+ self._set_attr("checkboxHorizontalMargin", value)
505
+
506
+ # checkbox_alignment
507
+ @property
508
+ def checkbox_alignment(self) -> Optional[Alignment]:
509
+ """
510
+ **NEW**
511
+
512
+ Alignment of the checkbox if it is displayed. Defaults to the `alignment.center`.
513
+ """
514
+ return self.__checkbox_alignment
515
+
516
+ @checkbox_alignment.setter
517
+ def checkbox_alignment(self, value: Optional[Alignment]):
518
+ self.__checkbox_alignment = value
519
+
520
+ # heading_checkbox_theme
521
+ @property
522
+ def heading_checkbox_theme(self) -> Optional[CheckboxTheme]:
523
+ """
524
+ **NEW**
525
+
526
+ Overrides theme of the checkbox that is displayed in the top left corner of the heading (if checkboxes are enabled).
527
+ Value is an instance of [CheckboxTheme](https://flet.dev/docs/reference/types/checkboxtheme).
528
+ """
529
+ return self.__heading_checkbox_theme
530
+
531
+ @heading_checkbox_theme.setter
532
+ def heading_checkbox_theme(self, value: Optional[CheckboxTheme]):
533
+ self.__heading_checkbox_theme = value
534
+
535
+ # data_row_checkbox_theme
536
+ @property
537
+ def data_row_checkbox_theme(self) -> Optional[CheckboxTheme]:
538
+ """
539
+ **NEW**
540
+
541
+ Overrides theme of the checkboxes that are displayed in the checkbox column in each data row (if checkboxes are enabled).
542
+ Value is an instance of [CheckboxTheme](https://flet.dev/docs/reference/types/checkboxtheme).
543
+ """
544
+ return self.__data_row_checkbox_theme
545
+
546
+ @data_row_checkbox_theme.setter
547
+ def data_row_checkbox_theme(self, value: Optional[CheckboxTheme]):
548
+ self.__data_row_checkbox_theme = value
549
+
550
+ # column_spacing
551
+ @property
552
+ def column_spacing(self) -> OptionalNumber:
553
+ """
554
+ See DataTable [column_spacing](https://flet.dev/docs/controls/datatable#column_spacing).
555
+ """
556
+ return self._get_attr("columnSpacing")
557
+
558
+ @column_spacing.setter
559
+ def column_spacing(self, value: OptionalNumber):
560
+ self._set_attr("columnSpacing", value)
561
+
562
+ # divider_thickness
563
+ @property
564
+ def divider_thickness(self) -> float:
565
+ """
566
+ See DataTable [divider_thickness](https://flet.dev/docs/controls/datatable#divider_thickness).
567
+ """
568
+ return self._get_attr("dividerThickness", data_type="float", def_value=1.0)
569
+
570
+ @divider_thickness.setter
571
+ def divider_thickness(self, value: OptionalNumber):
572
+ self._set_attr("dividerThickness", value)
573
+
574
+ # horizontal_margin
575
+ @property
576
+ def horizontal_margin(self) -> OptionalNumber:
577
+ """
578
+ See DataTable [horizontal_margin](https://flet.dev/docs/controls/datatable#horizontal_margin).
579
+ """
580
+ return self._get_attr("horizontalMargin")
581
+
582
+ @horizontal_margin.setter
583
+ def horizontal_margin(self, value: OptionalNumber):
584
+ self._set_attr("horizontalMargin", value)
585
+
586
+ # heading_row_decoration
587
+ @property
588
+ def heading_row_decoration(self) -> Optional[BoxDecoration]:
589
+ """
590
+ **NEW**
591
+
592
+ Decoration to be applied to the heading row.
593
+ Value is an instance of [BoxDecoration](https://flet.dev/docs/reference/types/boxdecoration).
594
+
595
+ When both `heading_row_color` and 'heading_row_decoration' are provided:
596
+
597
+ * `heading_row_decoration` takes precedence if there're 0 or 1 fixed rows
598
+ * `headeing_row_color` is applied to fixed top starting from the second row.
599
+ * When there're both fixed top rows and fixed left columns with `fixed_corner_color` provided, this decoration overrides top left corner cell color.
600
+
601
+ """
602
+ return self.__heading_row_decoration
603
+
604
+ @heading_row_decoration.setter
605
+ def heading_row_decoration(self, value: Optional[BoxDecoration]):
606
+ self.__heading_row_decoration = value
607
+
608
+ # data_row_color
609
+ @property
610
+ def data_row_color(self) -> ControlStateValue[str]:
611
+ """
612
+ See DataTable [data_row_color](https://flet.dev/docs/controls/datatable#data_row_color).
613
+ """
614
+ return self.__data_row_color
615
+
616
+ @data_row_color.setter
617
+ def data_row_color(self, value: ControlStateValue[str]):
618
+ self.__data_row_color = value
619
+
620
+ # data_row_height
621
+ @property
622
+ def data_row_height(self) -> OptionalNumber:
623
+ """
624
+ **NEW**
625
+ The height of each row (excluding the row that contains column headings).
626
+
627
+ Note that, unlike in Flet [DataTable](https://flet.dev/docs/controls/datatable), there's no capability to define min/max height of a row. This is an implementation tradeoff making it possible to have performant sticky columns.
628
+ """
629
+ return self._get_attr("dataRowHeight")
630
+
631
+ @data_row_height.setter
632
+ def data_row_height(self, value: OptionalNumber):
633
+ self._set_attr("dataRowHeight", value)
634
+
635
+ # data_text_style
636
+ @property
637
+ def data_text_style(self) -> Optional[TextStyle]:
638
+ """
639
+ See DataTable [data_text_style](https://flet.dev/docs/controls/datatable#data_text_style).
640
+ """
641
+ return self.__data_text_style
642
+
643
+ @data_text_style.setter
644
+ def data_text_style(self, value: Optional[TextStyle]):
645
+ self.__data_text_style = value
646
+
647
+ # bgcolor
648
+ @property
649
+ def bgcolor(self) -> Optional[ColorValue]:
650
+ """
651
+ See DataTable [bgcolor](https://flet.dev/docs/controls/datatable#bgcolor).
652
+ """
653
+ return self.__bgcolor
654
+
655
+ @bgcolor.setter
656
+ def bgcolor(self, value: Optional[ColorValue]):
657
+ self.__bgcolor = value
658
+ self._set_enum_attr("bgColor", value, ColorEnums)
659
+
660
+ # gradient
661
+ @property
662
+ def gradient(self) -> Optional[Gradient]:
663
+ """
664
+ See DataTable [gradient](https://flet.dev/docs/controls/datatable#gradient).
665
+ """
666
+ return self.__gradient
667
+
668
+ @gradient.setter
669
+ def gradient(self, value: Optional[Gradient]):
670
+ self.__gradient = value
671
+
672
+ # heading_row_color
673
+ @property
674
+ def heading_row_color(self) -> ControlStateValue[str]:
675
+ """
676
+ See DataTable [heading_row_color](https://flet.dev/docs/controls/datatable#heading_row_color).
677
+ """
678
+ return self.__heading_row_color
679
+
680
+ @heading_row_color.setter
681
+ def heading_row_color(self, value: ControlStateValue[str]):
682
+ self.__heading_row_color = value
683
+
684
+ # heading_row_height
685
+ @property
686
+ def heading_row_height(self) -> OptionalNumber:
687
+ """
688
+ See DataTable [heading_row_height](https://flet.dev/docs/controls/datatable#heading_row_height).
689
+ """
690
+ return self._get_attr("headingRowHeight")
691
+
692
+ @heading_row_height.setter
693
+ def heading_row_height(self, value: OptionalNumber):
694
+ self._set_attr("headingRowHeight", value)
695
+
696
+ # heading_text_style
697
+ @property
698
+ def heading_text_style(self) -> Optional[TextStyle]:
699
+ """
700
+ See DataTable [heading_text_style](https://flet.dev/docs/controls/datatable#heading_text_style).
701
+ """
702
+ return self.__heading_text_style
703
+
704
+ @heading_text_style.setter
705
+ def heading_text_style(self, value: Optional[TextStyle]):
706
+ self.__heading_text_style = value
707
+
708
+ # show_bottom_border
709
+ @property
710
+ def show_bottom_border(self) -> bool:
711
+ """
712
+ See DataTable [show_bottom_border](https://flet.dev/docs/controls/datatable#show_bottom_border).
713
+ """
714
+ return self._get_attr("showBottomBorder", data_type="bool", def_value=False)
715
+
716
+ @show_bottom_border.setter
717
+ def show_bottom_border(self, value: Optional[bool]):
718
+ self._set_attr("showBottomBorder", value)
719
+
720
+ # show_checkbox_column
721
+ @property
722
+ def show_checkbox_column(self) -> bool:
723
+ """
724
+ See DataTable [show_checkbox_column](https://flet.dev/docs/controls/datatable#show_checkbox_column).
725
+ """
726
+ return self._get_attr("showCheckboxColumn", data_type="bool", def_value=False)
727
+
728
+ @show_checkbox_column.setter
729
+ def show_checkbox_column(self, value: Optional[bool]):
730
+ self._set_attr("showCheckboxColumn", value)
731
+
732
+ # show_heading_checkbox
733
+ @property
734
+ def show_heading_checkbox(self) -> bool:
735
+ """
736
+ **NEW**
737
+
738
+ Whether to display heading checkbox or not, if the checkbox column is present. Defaults to `True`.
739
+ """
740
+ return self._get_attr("showHeadingCheckbox", data_type="bool", def_value=False)
741
+
742
+ @show_heading_checkbox.setter
743
+ def show_heading_checkbox(self, value: Optional[bool]):
744
+ self._set_attr("showHeadingCheckbox", value)
745
+
746
+ # sort_ascending
747
+ @property
748
+ def sort_ascending(self) -> bool:
749
+ """
750
+ See DataTable [sort_ascending](https://flet.dev/docs/controls/datatable#sort_ascending).
751
+ """
752
+ return self._get_attr("sortAscending", data_type="bool", def_value=False)
753
+
754
+ @sort_ascending.setter
755
+ def sort_ascending(self, value: Optional[bool]):
756
+ self._set_attr("sortAscending", value)
757
+
758
+ # is_horizontal_scroll_bar_visible
759
+ @property
760
+ def is_horizontal_scroll_bar_visible(self) -> bool:
761
+ """
762
+ **NEW**
763
+
764
+ Determines whether the horizontal scroll bar is visible.
765
+ """
766
+ return self._get_attr("isHorizontalScrollBarVisible", data_type="bool")
767
+
768
+ @is_horizontal_scroll_bar_visible.setter
769
+ def is_horizontal_scroll_bar_visible(self, value: Optional[bool]):
770
+ self._set_attr("isHorizontalScrollBarVisible", value)
771
+
772
+ # is_vertical_scroll_bar_visible
773
+ @property
774
+ def is_vertical_scroll_bar_visible(self) -> bool:
775
+ """
776
+ **NEW**
777
+
778
+ Determines whether the vertical scroll bar is visible.
779
+ """
780
+ return self._get_attr(
781
+ "isVerticalScrollBarVisible", data_type="bool", def_value=False
782
+ )
783
+
784
+ @is_vertical_scroll_bar_visible.setter
785
+ def is_vertical_scroll_bar_visible(self, value: Optional[bool]):
786
+ self._set_attr("isVerticalScrollBarVisible", value)
787
+
788
+ # sort_column_index
789
+ @property
790
+ def sort_column_index(self) -> Optional[int]:
791
+ """
792
+ See DataTable [sort_column_index](https://flet.dev/docs/controls/datatable#sort_column_index).
793
+ """
794
+ return self._get_attr("sortColumnIndex")
795
+
796
+ @sort_column_index.setter
797
+ def sort_column_index(self, value: Optional[int]):
798
+ self._set_attr("sortColumnIndex", value)
799
+
800
+ # clip_behavior
801
+ @property
802
+ def clip_behavior(self) -> Optional[ClipBehavior]:
803
+ """
804
+ See DataTable [clip_behavior](https://flet.dev/docs/controls/datatable#clip_behavior).
805
+ """
806
+ return self.__clip_behavior
807
+
808
+ @clip_behavior.setter
809
+ def clip_behavior(self, value: Optional[ClipBehavior]):
810
+ self.__clip_behavior = value
811
+ self._set_enum_attr("clipBehavior", value, ClipBehavior)
812
+
813
+ # on_select_all
814
+ @property
815
+ def on_select_all(self) -> OptionalControlEventCallable:
816
+ """
817
+ See DataTable [on_select_all](https://flet.dev/docs/controls/datatable#on_select_all).
818
+ """
819
+ return self._get_event_handler("select_all")
820
+
821
+ @on_select_all.setter
822
+ def on_select_all(self, handler: OptionalControlEventCallable):
823
+ self._add_event_handler("select_all", handler)
824
+ self._set_attr("onSelectAll", True if handler is not None else None)
825
+
826
+
827
+ # class Item(Control):
828
+ # def __init__(self, obj):
829
+ # Control.__init__(self)
830
+ # assert obj, "obj cannot be empty"
831
+ # self.obj = obj
832
+
833
+ # def _set_attr(self, name, value, dirty=True):
834
+ # if value is None:
835
+ # return
836
+
837
+ # orig_val = self._get_attr(name)
838
+ # if orig_val is not None:
839
+ # if isinstance(orig_val, bool):
840
+ # value = str(value).lower() == "true"
841
+ # elif isinstance(orig_val, float):
842
+ # value = float(str(value))
843
+
844
+ # self._set_attr_internal(name, value, dirty=False)
845
+ # if isinstance(self.obj, dict):
846
+ # self.obj[name] = value
847
+ # else:
848
+ # setattr(self.obj, name, value)
849
+
850
+ # def _fetch_attrs(self):
851
+ # # reflection
852
+ # obj = self.obj if isinstance(self.obj, dict) else vars(self.obj)
853
+
854
+ # for name, val in obj.items():
855
+ # data_type = (
856
+ # type(val).__name__ if isinstance(val, (bool, float)) else "string"
857
+ # )
858
+ # orig_val = self._get_attr(name, data_type=data_type)
859
+
860
+ # if val != orig_val:
861
+ # self._set_attr_internal(name, val, dirty=True)
862
+
863
+ # def _get_control_name(self):
864
+ # return "item"