tksheet 7.2.23__py3-none-any.whl → 7.3.0__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.
- tksheet/__init__.py +1 -1
- tksheet/column_headers.py +33 -43
- tksheet/functions.py +6 -0
- tksheet/main_table.py +68 -62
- tksheet/row_index.py +31 -42
- tksheet/sheet.py +17 -25
- tksheet/sheet_options.py +5 -0
- tksheet/top_left_rectangle.py +14 -7
- {tksheet-7.2.23.dist-info → tksheet-7.3.0.dist-info}/METADATA +36 -12
- tksheet-7.3.0.dist-info/RECORD +20 -0
- tksheet-7.2.23.dist-info/RECORD +0 -20
- {tksheet-7.2.23.dist-info → tksheet-7.3.0.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.2.23.dist-info → tksheet-7.3.0.dist-info}/WHEEL +0 -0
- {tksheet-7.2.23.dist-info → tksheet-7.3.0.dist-info}/top_level.txt +0 -0
tksheet/__init__.py
CHANGED
tksheet/column_headers.py
CHANGED
@@ -61,7 +61,7 @@ class ColumnHeaders(tk.Canvas):
|
|
61
61
|
highlightthickness=0,
|
62
62
|
)
|
63
63
|
self.PAR = kwargs["parent"]
|
64
|
-
self.current_height = None
|
64
|
+
self.current_height = None
|
65
65
|
self.MT = None # is set from within MainTable() __init__
|
66
66
|
self.RI = None # is set from within MainTable() __init__
|
67
67
|
self.TL = None # is set from within TopLeftRectangle() __init__
|
@@ -101,7 +101,6 @@ class ColumnHeaders(tk.Canvas):
|
|
101
101
|
self.cell_options = {}
|
102
102
|
self.rsz_w = None
|
103
103
|
self.rsz_h = None
|
104
|
-
self.new_col_height = 0
|
105
104
|
self.lines_start_at = 0
|
106
105
|
self.currently_resizing_width = False
|
107
106
|
self.currently_resizing_height = False
|
@@ -191,14 +190,17 @@ class ColumnHeaders(tk.Canvas):
|
|
191
190
|
self.lines_start_at -= 1
|
192
191
|
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=False, redraw_table=False)
|
193
192
|
|
194
|
-
def set_height(self, new_height: int, set_TL: bool = False) ->
|
195
|
-
self.current_height = new_height
|
193
|
+
def set_height(self, new_height: int, set_TL: bool = False) -> bool:
|
196
194
|
try:
|
197
195
|
self.config(height=new_height)
|
198
196
|
except Exception:
|
199
|
-
return
|
197
|
+
return False
|
200
198
|
if set_TL and self.TL is not None:
|
201
199
|
self.TL.set_dimensions(new_h=new_height)
|
200
|
+
if expanded := isinstance(self.current_height, int) and new_height > self.current_height:
|
201
|
+
self.MT.recreate_all_selection_boxes()
|
202
|
+
self.current_height = new_height
|
203
|
+
return expanded
|
202
204
|
|
203
205
|
def rc(self, event: object) -> None:
|
204
206
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
@@ -471,12 +473,7 @@ class ColumnHeaders(tk.Canvas):
|
|
471
473
|
)
|
472
474
|
self.MT.create_resize_line(line2x, y1, line2x, y2, width=1, fill=self.PAR.ops.resizing_line_fg, tag="rwl2")
|
473
475
|
elif self.height_resizing_enabled and self.rsz_w is None and self.rsz_h is not None:
|
474
|
-
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
475
476
|
self.currently_resizing_height = True
|
476
|
-
y = event.y
|
477
|
-
if y < self.MT.min_header_height:
|
478
|
-
y = int(self.MT.min_header_height)
|
479
|
-
self.new_col_height = y
|
480
477
|
elif self.MT.identify_col(x=event.x, allow_end=False) is None:
|
481
478
|
self.MT.deselect("all")
|
482
479
|
elif self.col_selection_enabled and self.rsz_w is None and self.rsz_h is None:
|
@@ -504,7 +501,7 @@ class ColumnHeaders(tk.Canvas):
|
|
504
501
|
if self.width_resizing_enabled and self.rsz_w is not None and self.currently_resizing_width:
|
505
502
|
x = self.canvasx(event.x)
|
506
503
|
size = x - self.MT.col_positions[self.rsz_w - 1]
|
507
|
-
if size >= self.
|
504
|
+
if size >= self.PAR.ops.min_column_width and size < self.PAR.ops.max_column_width:
|
508
505
|
self.hide_resize_and_ctrl_lines(ctrl_lines=False)
|
509
506
|
line2x = self.MT.col_positions[self.rsz_w - 1]
|
510
507
|
self.create_resize_line(
|
@@ -539,17 +536,13 @@ class ColumnHeaders(tk.Canvas):
|
|
539
536
|
elif self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
|
540
537
|
evy = event.y
|
541
538
|
if evy > self.current_height:
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
y = self.MT.canvasy(evy - self.current_height)
|
546
|
-
self.new_col_height = evy
|
539
|
+
if evy > self.PAR.ops.max_header_height:
|
540
|
+
evy = int(self.PAR.ops.max_header_height)
|
541
|
+
self.drag_height_resize(evy)
|
547
542
|
else:
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
self.new_col_height = y
|
552
|
-
self.drag_height_resize()
|
543
|
+
if evy < self.MT.min_header_height:
|
544
|
+
evy = int(self.MT.min_header_height)
|
545
|
+
self.drag_height_resize(evy)
|
553
546
|
elif (
|
554
547
|
self.drag_and_drop_enabled
|
555
548
|
and self.col_selection_enabled
|
@@ -596,9 +589,9 @@ class ColumnHeaders(tk.Canvas):
|
|
596
589
|
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=False)
|
597
590
|
try_binding(self.extra_b1_motion_func, event)
|
598
591
|
|
599
|
-
def drag_height_resize(self) -> None:
|
600
|
-
self.set_height(
|
601
|
-
|
592
|
+
def drag_height_resize(self, height: int) -> None:
|
593
|
+
if self.set_height(height, set_TL=True):
|
594
|
+
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=False, redraw_table=False)
|
602
595
|
|
603
596
|
def get_b1_motion_box(self, start_col: int, end_col: int) -> tuple[int, int, int, int, Literal["columns"]]:
|
604
597
|
if end_col >= start_col:
|
@@ -781,10 +774,10 @@ class ColumnHeaders(tk.Canvas):
|
|
781
774
|
new_col_pos = int(self.coords("rwl")[0])
|
782
775
|
old_width = self.MT.col_positions[self.rsz_w] - self.MT.col_positions[self.rsz_w - 1]
|
783
776
|
size = new_col_pos - self.MT.col_positions[self.rsz_w - 1]
|
784
|
-
if size < self.
|
785
|
-
new_col_pos = ceil(self.MT.col_positions[self.rsz_w - 1] + self.
|
786
|
-
elif size > self.
|
787
|
-
new_col_pos = floor(self.MT.col_positions[self.rsz_w - 1] + self.
|
777
|
+
if size < self.PAR.ops.min_column_width:
|
778
|
+
new_col_pos = ceil(self.MT.col_positions[self.rsz_w - 1] + self.PAR.ops.min_column_width)
|
779
|
+
elif size > self.PAR.ops.max_column_width:
|
780
|
+
new_col_pos = floor(self.MT.col_positions[self.rsz_w - 1] + self.PAR.ops.max_column_width)
|
788
781
|
increment = new_col_pos - self.MT.col_positions[self.rsz_w]
|
789
782
|
self.MT.col_positions[self.rsz_w + 1 :] = [
|
790
783
|
e + increment for e in islice(self.MT.col_positions, self.rsz_w + 1, None)
|
@@ -820,9 +813,6 @@ class ColumnHeaders(tk.Canvas):
|
|
820
813
|
self.drag_width_resize()
|
821
814
|
self.currently_resizing_width = False
|
822
815
|
self.hide_resize_and_ctrl_lines(ctrl_lines=False)
|
823
|
-
elif self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
|
824
|
-
self.currently_resizing_height = False
|
825
|
-
self.drag_height_resize()
|
826
816
|
elif (
|
827
817
|
self.drag_and_drop_enabled
|
828
818
|
and self.col_selection_enabled
|
@@ -1019,7 +1009,7 @@ class ColumnHeaders(tk.Canvas):
|
|
1019
1009
|
w = b[2] - b[0] + 7
|
1020
1010
|
h = b[3] - b[1] + 5
|
1021
1011
|
else:
|
1022
|
-
w = self.
|
1012
|
+
w = self.PAR.ops.min_column_width
|
1023
1013
|
h = self.MT.min_header_height
|
1024
1014
|
if datacn in self.cell_options and (
|
1025
1015
|
self.get_cell_kwargs(datacn, key="dropdown") or self.get_cell_kwargs(datacn, key="checkbox")
|
@@ -1077,8 +1067,8 @@ class ColumnHeaders(tk.Canvas):
|
|
1077
1067
|
h = space_bot
|
1078
1068
|
if h < self.MT.min_header_height:
|
1079
1069
|
h = int(self.MT.min_header_height)
|
1080
|
-
elif h > self.
|
1081
|
-
h = int(self.
|
1070
|
+
elif h > self.PAR.ops.max_header_height:
|
1071
|
+
h = int(self.PAR.ops.max_header_height)
|
1082
1072
|
if not only_if_too_small or (only_if_too_small and h > self.current_height):
|
1083
1073
|
self.set_height(h, set_TL=True)
|
1084
1074
|
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
|
@@ -1091,7 +1081,7 @@ class ColumnHeaders(tk.Canvas):
|
|
1091
1081
|
only_if_too_small: bool = False,
|
1092
1082
|
) -> int:
|
1093
1083
|
self.fix_header()
|
1094
|
-
w = self.
|
1084
|
+
w = self.PAR.ops.min_column_width
|
1095
1085
|
datacn = col if self.MT.all_columns_displayed else self.MT.displayed_columns[col]
|
1096
1086
|
# header
|
1097
1087
|
hw, hh_ = self.get_cell_dimensions(datacn)
|
@@ -1128,10 +1118,10 @@ class ColumnHeaders(tk.Canvas):
|
|
1128
1118
|
w = hw
|
1129
1119
|
if only_if_too_small and w < self.MT.col_positions[col + 1] - self.MT.col_positions[col]:
|
1130
1120
|
w = self.MT.col_positions[col + 1] - self.MT.col_positions[col]
|
1131
|
-
if w <= self.
|
1132
|
-
w =
|
1133
|
-
elif w > self.
|
1134
|
-
w = int(self.
|
1121
|
+
if w <= self.PAR.ops.min_column_width:
|
1122
|
+
w = self.PAR.ops.min_column_width
|
1123
|
+
elif w > self.PAR.ops.max_column_width:
|
1124
|
+
w = int(self.PAR.ops.max_column_width)
|
1135
1125
|
return w
|
1136
1126
|
|
1137
1127
|
def set_col_width(
|
@@ -1144,10 +1134,10 @@ class ColumnHeaders(tk.Canvas):
|
|
1144
1134
|
) -> int:
|
1145
1135
|
if width is None:
|
1146
1136
|
width = self.get_col_text_width(col=col, visible_only=visible_only)
|
1147
|
-
if width <= self.
|
1148
|
-
width =
|
1149
|
-
elif width > self.
|
1150
|
-
width = int(self.
|
1137
|
+
if width <= self.PAR.ops.min_column_width:
|
1138
|
+
width = self.PAR.ops.min_column_width
|
1139
|
+
elif width > self.PAR.ops.max_column_width:
|
1140
|
+
width = int(self.PAR.ops.max_column_width)
|
1151
1141
|
if only_if_too_small and width <= self.MT.col_positions[col + 1] - self.MT.col_positions[col]:
|
1152
1142
|
return self.MT.col_positions[col + 1] - self.MT.col_positions[col]
|
1153
1143
|
new_col_pos = self.MT.col_positions[col] + width
|
tksheet/functions.py
CHANGED
@@ -119,6 +119,12 @@ def dropdown_search_function(
|
|
119
119
|
return None
|
120
120
|
|
121
121
|
|
122
|
+
def float_to_int(f: int | float) -> int | float:
|
123
|
+
if f == float("inf"):
|
124
|
+
return f
|
125
|
+
return int(f)
|
126
|
+
|
127
|
+
|
122
128
|
def selection_box_tup_to_dict(box: tuple) -> dict:
|
123
129
|
return {Box_nt(*box[:-1]): box[-1]}
|
124
130
|
|
tksheet/main_table.py
CHANGED
@@ -59,6 +59,7 @@ from .functions import (
|
|
59
59
|
diff_list,
|
60
60
|
down_cell_within_box,
|
61
61
|
event_dict,
|
62
|
+
float_to_int,
|
62
63
|
gen_formatted,
|
63
64
|
get_data_from_clipboard,
|
64
65
|
get_new_indexes,
|
@@ -257,8 +258,6 @@ class MainTable(tk.Canvas):
|
|
257
258
|
self.rc_insert_row_enabled = False
|
258
259
|
self.rc_popup_menus_enabled = False
|
259
260
|
self.edit_cell_enabled = False
|
260
|
-
self.new_row_width = 0
|
261
|
-
self.new_header_height = 0
|
262
261
|
self.CH = kwargs["column_headers_canvas"]
|
263
262
|
self.CH.MT = self
|
264
263
|
self.CH.RI = kwargs["row_index_canvas"]
|
@@ -297,11 +296,6 @@ class MainTable(tk.Canvas):
|
|
297
296
|
self.txt_measure_canvas = tk.Canvas(self)
|
298
297
|
self.txt_measure_canvas_text = self.txt_measure_canvas.create_text(0, 0, text="", font=self.PAR.ops.table_font)
|
299
298
|
|
300
|
-
self.max_row_height = float(kwargs["max_row_height"])
|
301
|
-
self.max_index_width = float(kwargs["max_index_width"])
|
302
|
-
self.max_column_width = float(kwargs["max_column_width"])
|
303
|
-
self.max_header_height = float(kwargs["max_header_height"])
|
304
|
-
|
305
299
|
self.RI.set_width(self.PAR.ops.default_row_index_width)
|
306
300
|
self.set_table_font_help()
|
307
301
|
self.set_header_font_help()
|
@@ -3210,20 +3204,6 @@ class MainTable(tk.Canvas):
|
|
3210
3204
|
run_binding=False,
|
3211
3205
|
)
|
3212
3206
|
self.hide_selection_box(to_hide)
|
3213
|
-
if self.RI.width_resizing_enabled and self.RI.rsz_w is not None and self.RI.currently_resizing_width:
|
3214
|
-
self.delete_resize_lines()
|
3215
|
-
self.RI.delete_resize_lines()
|
3216
|
-
self.RI.currently_resizing_width = False
|
3217
|
-
self.RI.set_width(self.new_row_width, set_TL=True)
|
3218
|
-
self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
|
3219
|
-
self.b1_pressed_loc = None
|
3220
|
-
elif self.CH.height_resizing_enabled and self.CH.rsz_h is not None and self.CH.currently_resizing_height:
|
3221
|
-
self.delete_resize_lines()
|
3222
|
-
self.CH.delete_resize_lines()
|
3223
|
-
self.CH.currently_resizing_height = False
|
3224
|
-
self.CH.set_height(self.new_header_height, set_TL=True)
|
3225
|
-
self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
|
3226
|
-
self.b1_pressed_loc = None
|
3227
3207
|
self.RI.rsz_w = None
|
3228
3208
|
self.CH.rsz_h = None
|
3229
3209
|
if self.b1_pressed_loc is not None:
|
@@ -3546,7 +3526,7 @@ class MainTable(tk.Canvas):
|
|
3546
3526
|
c_pc=c_pc,
|
3547
3527
|
)
|
3548
3528
|
|
3549
|
-
def get_txt_w(self, txt, font=None):
|
3529
|
+
def get_txt_w(self, txt: str, font: None | FontTuple = None) -> int:
|
3550
3530
|
self.txt_measure_canvas.itemconfig(
|
3551
3531
|
self.txt_measure_canvas_text,
|
3552
3532
|
text=txt,
|
@@ -3555,7 +3535,7 @@ class MainTable(tk.Canvas):
|
|
3555
3535
|
b = self.txt_measure_canvas.bbox(self.txt_measure_canvas_text)
|
3556
3536
|
return b[2] - b[0]
|
3557
3537
|
|
3558
|
-
def get_txt_h(self, txt, font=None):
|
3538
|
+
def get_txt_h(self, txt: str, font: None | FontTuple = None) -> int:
|
3559
3539
|
self.txt_measure_canvas.itemconfig(
|
3560
3540
|
self.txt_measure_canvas_text,
|
3561
3541
|
text=txt,
|
@@ -3564,7 +3544,7 @@ class MainTable(tk.Canvas):
|
|
3564
3544
|
b = self.txt_measure_canvas.bbox(self.txt_measure_canvas_text)
|
3565
3545
|
return b[3] - b[1]
|
3566
3546
|
|
3567
|
-
def get_txt_dimensions(self, txt, font=None):
|
3547
|
+
def get_txt_dimensions(self, txt: str, font: None | FontTuple = None) -> int:
|
3568
3548
|
self.txt_measure_canvas.itemconfig(
|
3569
3549
|
self.txt_measure_canvas_text,
|
3570
3550
|
text=txt,
|
@@ -3573,7 +3553,7 @@ class MainTable(tk.Canvas):
|
|
3573
3553
|
b = self.txt_measure_canvas.bbox(self.txt_measure_canvas_text)
|
3574
3554
|
return b[2] - b[0], b[3] - b[1]
|
3575
3555
|
|
3576
|
-
def get_lines_cell_height(self, n, font=None):
|
3556
|
+
def get_lines_cell_height(self, n: int, font: None | FontTuple = None) -> int:
|
3577
3557
|
return (
|
3578
3558
|
self.get_txt_h(
|
3579
3559
|
txt="\n".join("|" for _ in range(n)) if n > 1 else "|",
|
@@ -3582,15 +3562,17 @@ class MainTable(tk.Canvas):
|
|
3582
3562
|
+ 5
|
3583
3563
|
)
|
3584
3564
|
|
3585
|
-
def set_min_column_width(self):
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3565
|
+
def set_min_column_width(self, width: int) -> None:
|
3566
|
+
if width:
|
3567
|
+
self.PAR.ops.min_column_width = width
|
3568
|
+
|
3569
|
+
if self.PAR.ops.min_column_width > self.PAR.ops.max_column_width:
|
3570
|
+
self.PAR.ops.max_column_width = self.PAR.ops.min_column_width + 20
|
3589
3571
|
if (
|
3590
3572
|
isinstance(self.PAR.ops.auto_resize_columns, (int, float))
|
3591
|
-
and self.PAR.ops.auto_resize_columns < self.min_column_width
|
3573
|
+
and self.PAR.ops.auto_resize_columns < self.PAR.ops.min_column_width
|
3592
3574
|
):
|
3593
|
-
self.PAR.ops.auto_resize_columns = self.min_column_width
|
3575
|
+
self.PAR.ops.auto_resize_columns = self.PAR.ops.min_column_width
|
3594
3576
|
|
3595
3577
|
def get_default_row_height(self) -> int:
|
3596
3578
|
if isinstance(self.PAR.ops.default_row_height, str):
|
@@ -3641,7 +3623,6 @@ class MainTable(tk.Canvas):
|
|
3641
3623
|
self.table_xtra_lines_increment = int(self.table_txt_height)
|
3642
3624
|
if self.min_row_height < 12:
|
3643
3625
|
self.min_row_height = 12
|
3644
|
-
self.set_min_column_width()
|
3645
3626
|
|
3646
3627
|
def set_header_font(self, newfont: tuple | None = None) -> tuple[str, int, str]:
|
3647
3628
|
if newfont:
|
@@ -3672,7 +3653,6 @@ class MainTable(tk.Canvas):
|
|
3672
3653
|
and self.PAR.ops.default_header_height < self.min_header_height
|
3673
3654
|
):
|
3674
3655
|
self.PAR.ops.default_header_height = int(self.min_header_height)
|
3675
|
-
self.set_min_column_width()
|
3676
3656
|
self.CH.set_height(self.get_default_header_height(), set_TL=True)
|
3677
3657
|
|
3678
3658
|
def set_index_font(self, newfont: tuple | None = None) -> tuple[str, int, str]:
|
@@ -3742,15 +3722,15 @@ class MainTable(tk.Canvas):
|
|
3742
3722
|
w = b[2] - b[0] + 7
|
3743
3723
|
h = b[3] - b[1] + 5
|
3744
3724
|
else:
|
3745
|
-
w = self.min_column_width
|
3725
|
+
w = self.PAR.ops.min_column_width
|
3746
3726
|
h = self.min_row_height
|
3747
3727
|
if self.get_cell_kwargs(datarn, datacn, key="dropdown") or self.get_cell_kwargs(datarn, datacn, key="checkbox"):
|
3748
3728
|
return w + self.table_txt_height, h
|
3749
3729
|
return w, h
|
3750
3730
|
|
3751
3731
|
def set_cell_size_to_text(self, r, c, only_if_too_small=False, redraw: bool = True, run_binding=False):
|
3752
|
-
min_column_width =
|
3753
|
-
min_rh =
|
3732
|
+
min_column_width = self.PAR.ops.min_column_width
|
3733
|
+
min_rh = self.min_row_height
|
3754
3734
|
w = min_column_width
|
3755
3735
|
h = min_rh
|
3756
3736
|
datacn = self.datacn(c)
|
@@ -3759,13 +3739,13 @@ class MainTable(tk.Canvas):
|
|
3759
3739
|
if tw > w:
|
3760
3740
|
w = tw
|
3761
3741
|
if h < min_rh:
|
3762
|
-
h =
|
3763
|
-
elif h > self.max_row_height:
|
3764
|
-
h = int(self.max_row_height)
|
3742
|
+
h = min_rh
|
3743
|
+
elif h > self.PAR.ops.max_row_height:
|
3744
|
+
h = int(self.PAR.ops.max_row_height)
|
3765
3745
|
if w < min_column_width:
|
3766
|
-
w =
|
3767
|
-
elif w > self.max_column_width:
|
3768
|
-
w = int(self.max_column_width)
|
3746
|
+
w = min_column_width
|
3747
|
+
elif w > self.PAR.ops.max_column_width:
|
3748
|
+
w = int(self.PAR.ops.max_column_width)
|
3769
3749
|
cell_needs_resize_w = False
|
3770
3750
|
cell_needs_resize_h = False
|
3771
3751
|
if only_if_too_small:
|
@@ -3825,8 +3805,10 @@ class MainTable(tk.Canvas):
|
|
3825
3805
|
width: int | None = None,
|
3826
3806
|
slim: bool = False,
|
3827
3807
|
) -> tuple[list[float], list[float]]:
|
3828
|
-
min_column_width =
|
3829
|
-
|
3808
|
+
min_column_width = self.PAR.ops.min_column_width
|
3809
|
+
max_column_width = float_to_int(self.PAR.ops.max_column_width)
|
3810
|
+
max_row_height = float_to_int(self.PAR.ops.max_row_height)
|
3811
|
+
min_rh = self.min_row_height
|
3830
3812
|
h = min_rh
|
3831
3813
|
rhs = defaultdict(lambda: int(min_rh))
|
3832
3814
|
cws = []
|
@@ -3849,9 +3831,9 @@ class MainTable(tk.Canvas):
|
|
3849
3831
|
for datarn in iterrows:
|
3850
3832
|
w_, h = self.RI.get_cell_dimensions(datarn)
|
3851
3833
|
if h < min_rh:
|
3852
|
-
h =
|
3853
|
-
elif h >
|
3854
|
-
h =
|
3834
|
+
h = min_rh
|
3835
|
+
elif h > max_row_height:
|
3836
|
+
h = max_row_height
|
3855
3837
|
if h > rhs[datarn]:
|
3856
3838
|
rhs[datarn] = h
|
3857
3839
|
added_w_space = 1 if slim else 7
|
@@ -3883,15 +3865,15 @@ class MainTable(tk.Canvas):
|
|
3883
3865
|
if tw > w:
|
3884
3866
|
w = tw
|
3885
3867
|
if h < min_rh:
|
3886
|
-
h =
|
3887
|
-
elif h >
|
3888
|
-
h =
|
3868
|
+
h = min_rh
|
3869
|
+
elif h > max_row_height:
|
3870
|
+
h = max_row_height
|
3889
3871
|
if h > rhs[datarn]:
|
3890
3872
|
rhs[datarn] = h
|
3891
3873
|
if w < min_column_width:
|
3892
|
-
w =
|
3893
|
-
elif w >
|
3894
|
-
w =
|
3874
|
+
w = min_column_width
|
3875
|
+
elif w > max_column_width:
|
3876
|
+
w = max_column_width
|
3895
3877
|
cws.append(w)
|
3896
3878
|
self.set_row_positions(itr=rhs.values())
|
3897
3879
|
self.set_col_positions(itr=cws)
|
@@ -5475,8 +5457,8 @@ class MainTable(tk.Canvas):
|
|
5475
5457
|
resized_rows = False
|
5476
5458
|
if self.PAR.ops.auto_resize_columns and self.allow_auto_resize_columns and col_pos_exists:
|
5477
5459
|
max_w = can_width - self.PAR.ops.empty_horizontal
|
5478
|
-
if self.PAR.ops.auto_resize_columns < self.min_column_width:
|
5479
|
-
min_column_width = self.
|
5460
|
+
if self.PAR.ops.auto_resize_columns < self.PAR.ops.min_column_width:
|
5461
|
+
min_column_width = self.PAR.ops.min_column_width
|
5480
5462
|
else:
|
5481
5463
|
min_column_width = self.PAR.ops.auto_resize_columns
|
5482
5464
|
if (len(self.col_positions) - 1) * min_column_width < max_w:
|
@@ -5956,7 +5938,7 @@ class MainTable(tk.Canvas):
|
|
5956
5938
|
rows: bool = True,
|
5957
5939
|
columns: bool = True,
|
5958
5940
|
reverse: bool = False,
|
5959
|
-
) ->
|
5941
|
+
) -> tuple[tuple[int, SelectionBox]]:
|
5960
5942
|
"""
|
5961
5943
|
Most recent selection box should be last
|
5962
5944
|
"""
|
@@ -6409,31 +6391,55 @@ class MainTable(tk.Canvas):
|
|
6409
6391
|
def recreate_all_selection_boxes(self) -> None:
|
6410
6392
|
if not self.selected:
|
6411
6393
|
return
|
6394
|
+
modified = False
|
6412
6395
|
for item, box in self.get_selection_items():
|
6413
6396
|
r1, c1, r2, c2 = box.coords
|
6397
|
+
if not modified:
|
6398
|
+
modified = (
|
6399
|
+
r1 >= len(self.row_positions) - 1
|
6400
|
+
or c1 >= len(self.col_positions) - 1
|
6401
|
+
or r2 > len(self.row_positions) - 1
|
6402
|
+
or c2 > len(self.col_positions) - 1
|
6403
|
+
)
|
6414
6404
|
if r1 >= len(self.row_positions) - 1:
|
6415
6405
|
if len(self.row_positions) > 1:
|
6416
6406
|
r1 = len(self.row_positions) - 2
|
6417
6407
|
else:
|
6418
|
-
r1 =
|
6408
|
+
r1 = 0
|
6419
6409
|
if c1 >= len(self.col_positions) - 1:
|
6420
6410
|
if len(self.col_positions) > 1:
|
6421
6411
|
c1 = len(self.col_positions) - 2
|
6422
6412
|
else:
|
6423
|
-
c1 =
|
6413
|
+
c1 = 0
|
6424
6414
|
if r2 > len(self.row_positions) - 1:
|
6425
6415
|
r2 = len(self.row_positions) - 1
|
6426
6416
|
if c2 > len(self.col_positions) - 1:
|
6427
6417
|
c2 = len(self.col_positions) - 1
|
6428
|
-
self.recreate_selection_box(r1, c1, r2, c2, item)
|
6418
|
+
self.recreate_selection_box(r1, c1, r2, c2, item, run_binding=False)
|
6419
|
+
|
6429
6420
|
if self.selected:
|
6430
6421
|
r = self.selected.row
|
6431
6422
|
c = self.selected.column
|
6432
6423
|
if r < len(self.row_positions) - 1 and c < len(self.col_positions) - 1:
|
6433
|
-
self.set_currently_selected(
|
6424
|
+
self.set_currently_selected(
|
6425
|
+
r,
|
6426
|
+
c,
|
6427
|
+
item=self.selected.fill_iid,
|
6428
|
+
run_binding=False,
|
6429
|
+
)
|
6434
6430
|
else:
|
6435
6431
|
box = self.selection_boxes[self.selected.fill_iid]
|
6436
|
-
self.set_currently_selected(
|
6432
|
+
self.set_currently_selected(
|
6433
|
+
box.coords.from_r,
|
6434
|
+
box.coords.from_c,
|
6435
|
+
item=box.fill_iid,
|
6436
|
+
run_binding=False,
|
6437
|
+
)
|
6438
|
+
if modified:
|
6439
|
+
self.PAR.emit_event(
|
6440
|
+
"<<SheetSelect>>",
|
6441
|
+
data=self.get_select_event(self.being_drawn_item),
|
6442
|
+
)
|
6437
6443
|
|
6438
6444
|
def get_redraw_selections(self, startr: int, endr: int, startc: int, endc: int) -> dict:
|
6439
6445
|
d = defaultdict(set)
|
@@ -6891,7 +6897,7 @@ class MainTable(tk.Canvas):
|
|
6891
6897
|
name="end_edit_table",
|
6892
6898
|
sheet=self.PAR.name,
|
6893
6899
|
widget=self,
|
6894
|
-
cells_table={(datarn, datacn):
|
6900
|
+
cells_table={(datarn, datacn): self.get_cell_data(datarn, datacn)},
|
6895
6901
|
key=event.keysym,
|
6896
6902
|
value=text_editor_value,
|
6897
6903
|
loc=Loc(r, c),
|
tksheet/row_index.py
CHANGED
@@ -74,6 +74,7 @@ class RowIndex(tk.Canvas):
|
|
74
74
|
self.MT = None # is set from within MainTable() __init__
|
75
75
|
self.CH = None # is set from within MainTable() __init__
|
76
76
|
self.TL = None # is set from within TopLeftRectangle() __init__
|
77
|
+
self.current_width = None
|
77
78
|
self.popup_menu_loc = None
|
78
79
|
self.extra_begin_edit_cell_func = None
|
79
80
|
self.extra_end_edit_cell_func = None
|
@@ -95,7 +96,6 @@ class RowIndex(tk.Canvas):
|
|
95
96
|
self.ri_extra_end_drag_drop_func = None
|
96
97
|
self.extra_double_b1_func = None
|
97
98
|
self.row_height_resize_func = None
|
98
|
-
self.new_row_width = 0
|
99
99
|
self.cell_options = {}
|
100
100
|
self.drag_and_drop_enabled = False
|
101
101
|
self.dragged_row = None
|
@@ -178,13 +178,15 @@ class RowIndex(tk.Canvas):
|
|
178
178
|
self.MT.saved_row_heights = {}
|
179
179
|
|
180
180
|
def set_width(self, new_width: int, set_TL: bool = False, recreate_selection_boxes: bool = True) -> None:
|
181
|
-
self.current_width = new_width
|
182
181
|
try:
|
183
182
|
self.config(width=new_width)
|
184
183
|
except Exception:
|
185
184
|
return
|
186
185
|
if set_TL:
|
187
|
-
self.TL.set_dimensions(new_w=new_width
|
186
|
+
self.TL.set_dimensions(new_w=new_width)
|
187
|
+
if isinstance(self.current_width, int) and new_width > self.current_width and recreate_selection_boxes:
|
188
|
+
self.MT.recreate_all_selection_boxes()
|
189
|
+
self.current_width = new_width
|
188
190
|
|
189
191
|
def rc(self, event: object) -> None:
|
190
192
|
self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
|
@@ -480,11 +482,6 @@ class RowIndex(tk.Canvas):
|
|
480
482
|
self.MT.create_resize_line(x1, line2y, x2, line2y, width=1, fill=self.PAR.ops.resizing_line_fg, tag="rhl2")
|
481
483
|
elif self.width_resizing_enabled and self.rsz_h is None and self.rsz_w is True:
|
482
484
|
self.currently_resizing_width = True
|
483
|
-
x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
|
484
|
-
x = int(event.x)
|
485
|
-
if x < self.MT.min_column_width:
|
486
|
-
x = int(self.MT.min_column_width)
|
487
|
-
self.new_row_width = x
|
488
485
|
elif self.MT.identify_row(y=event.y, allow_end=False) is None:
|
489
486
|
self.MT.deselect("all")
|
490
487
|
elif self.row_selection_enabled and self.rsz_h is None and self.rsz_w is None:
|
@@ -513,7 +510,7 @@ class RowIndex(tk.Canvas):
|
|
513
510
|
if self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
|
514
511
|
y = self.canvasy(event.y)
|
515
512
|
size = y - self.MT.row_positions[self.rsz_h - 1]
|
516
|
-
if size >= self.MT.min_row_height and size < self.
|
513
|
+
if size >= self.MT.min_row_height and size < self.PAR.ops.max_row_height:
|
517
514
|
self.hide_resize_and_ctrl_lines(ctrl_lines=False)
|
518
515
|
line2y = self.MT.row_positions[self.rsz_h - 1]
|
519
516
|
self.create_resize_line(
|
@@ -548,18 +545,14 @@ class RowIndex(tk.Canvas):
|
|
548
545
|
elif self.width_resizing_enabled and self.rsz_w is not None and self.currently_resizing_width:
|
549
546
|
evx = event.x
|
550
547
|
if evx > self.current_width:
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
x = self.MT.canvasx(evx - self.current_width)
|
555
|
-
self.new_row_width = evx
|
548
|
+
if evx > self.PAR.ops.max_index_width:
|
549
|
+
evx = int(self.PAR.ops.max_index_width)
|
550
|
+
self.drag_width_resize(evx)
|
556
551
|
else:
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
self.drag_width_resize()
|
562
|
-
if (
|
552
|
+
if evx < self.PAR.ops.min_column_width:
|
553
|
+
evx = self.PAR.ops.min_column_width
|
554
|
+
self.drag_width_resize(evx)
|
555
|
+
elif (
|
563
556
|
self.drag_and_drop_enabled
|
564
557
|
and self.row_selection_enabled
|
565
558
|
and self.MT.anything_selected(exclude_cells=True, exclude_columns=True)
|
@@ -777,9 +770,9 @@ class RowIndex(tk.Canvas):
|
|
777
770
|
and event.x < self.MT.index_txt_height + 4
|
778
771
|
)
|
779
772
|
|
780
|
-
def drag_width_resize(self) -> None:
|
781
|
-
self.set_width(
|
782
|
-
self.MT.main_table_redraw_grid_and_text(redraw_header=
|
773
|
+
def drag_width_resize(self, width: int) -> None:
|
774
|
+
self.set_width(width, set_TL=True)
|
775
|
+
self.MT.main_table_redraw_grid_and_text(redraw_header=False, redraw_row_index=True, redraw_table=False)
|
783
776
|
|
784
777
|
def drag_height_resize(self) -> None:
|
785
778
|
new_row_pos = int(self.coords("rhl")[1])
|
@@ -787,8 +780,8 @@ class RowIndex(tk.Canvas):
|
|
787
780
|
size = new_row_pos - self.MT.row_positions[self.rsz_h - 1]
|
788
781
|
if size < self.MT.min_row_height:
|
789
782
|
new_row_pos = ceil(self.MT.row_positions[self.rsz_h - 1] + self.MT.min_row_height)
|
790
|
-
elif size > self.
|
791
|
-
new_row_pos = floor(self.MT.row_positions[self.rsz_h - 1] + self.
|
783
|
+
elif size > self.PAR.ops.max_row_height:
|
784
|
+
new_row_pos = floor(self.MT.row_positions[self.rsz_h - 1] + self.PAR.ops.max_row_height)
|
792
785
|
increment = new_row_pos - self.MT.row_positions[self.rsz_h]
|
793
786
|
self.MT.row_positions[self.rsz_h + 1 :] = [
|
794
787
|
e + increment for e in islice(self.MT.row_positions, self.rsz_h + 1, None)
|
@@ -822,12 +815,8 @@ class RowIndex(tk.Canvas):
|
|
822
815
|
self.MT.bind("<MouseWheel>", self.MT.mousewheel)
|
823
816
|
if self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
|
824
817
|
self.drag_height_resize()
|
825
|
-
self.currently_resizing_height = False
|
826
818
|
self.hide_resize_and_ctrl_lines(ctrl_lines=False)
|
827
|
-
elif
|
828
|
-
self.currently_resizing_width = False
|
829
|
-
self.drag_width_resize()
|
830
|
-
if (
|
819
|
+
elif (
|
831
820
|
self.drag_and_drop_enabled
|
832
821
|
and self.MT.anything_selected(exclude_cells=True, exclude_columns=True)
|
833
822
|
and self.row_selection_enabled
|
@@ -1092,8 +1081,8 @@ class RowIndex(tk.Canvas):
|
|
1092
1081
|
return self.MT.row_positions[row + 1] - self.MT.row_positions[row]
|
1093
1082
|
if h < self.MT.min_row_height:
|
1094
1083
|
h = int(self.MT.min_row_height)
|
1095
|
-
elif h > self.
|
1096
|
-
h = int(self.
|
1084
|
+
elif h > self.PAR.ops.max_row_height:
|
1085
|
+
h = int(self.PAR.ops.max_row_height)
|
1097
1086
|
return h
|
1098
1087
|
|
1099
1088
|
def set_row_height(
|
@@ -1108,8 +1097,8 @@ class RowIndex(tk.Canvas):
|
|
1108
1097
|
height = self.get_row_text_height(row=row, visible_only=visible_only)
|
1109
1098
|
if height < self.MT.min_row_height:
|
1110
1099
|
height = int(self.MT.min_row_height)
|
1111
|
-
elif height > self.
|
1112
|
-
height = int(self.
|
1100
|
+
elif height > self.PAR.ops.max_row_height:
|
1101
|
+
height = int(self.PAR.ops.max_row_height)
|
1113
1102
|
if only_if_too_small and height <= self.MT.row_positions[row + 1] - self.MT.row_positions[row]:
|
1114
1103
|
return self.MT.row_positions[row + 1] - self.MT.row_positions[row]
|
1115
1104
|
new_row_pos = self.MT.row_positions[row] + height
|
@@ -1143,8 +1132,8 @@ class RowIndex(tk.Canvas):
|
|
1143
1132
|
iterable = self.MT.displayed_rows
|
1144
1133
|
if (new_w := max(map(itemgetter(0), map(self.get_cell_dimensions, iterable)), default=w)) > w:
|
1145
1134
|
w = new_w
|
1146
|
-
if w > self.
|
1147
|
-
w = int(self.
|
1135
|
+
if w > self.PAR.ops.max_index_width:
|
1136
|
+
w = int(self.PAR.ops.max_index_width)
|
1148
1137
|
return w
|
1149
1138
|
|
1150
1139
|
def set_width_of_index_to_text(
|
@@ -1165,8 +1154,8 @@ class RowIndex(tk.Canvas):
|
|
1165
1154
|
w = tw
|
1166
1155
|
elif text is None:
|
1167
1156
|
w = self.get_index_text_width(only_rows=only_rows)
|
1168
|
-
if w > self.
|
1169
|
-
w = int(self.
|
1157
|
+
if w > self.PAR.ops.max_index_width:
|
1158
|
+
w = int(self.PAR.ops.max_index_width)
|
1170
1159
|
self.set_width(w, set_TL=True)
|
1171
1160
|
self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
|
1172
1161
|
return w
|
@@ -1637,7 +1626,7 @@ class RowIndex(tk.Canvas):
|
|
1637
1626
|
outline=fill,
|
1638
1627
|
tag="dd",
|
1639
1628
|
draw_outline=not dd_drawn,
|
1640
|
-
draw_arrow=
|
1629
|
+
draw_arrow=True,
|
1641
1630
|
open_=dd_coords == r,
|
1642
1631
|
)
|
1643
1632
|
else:
|
@@ -1656,7 +1645,7 @@ class RowIndex(tk.Canvas):
|
|
1656
1645
|
outline=fill,
|
1657
1646
|
tag="dd",
|
1658
1647
|
draw_outline=not dd_drawn,
|
1659
|
-
draw_arrow=
|
1648
|
+
draw_arrow=True,
|
1660
1649
|
open_=dd_coords == r,
|
1661
1650
|
)
|
1662
1651
|
else:
|
@@ -1676,7 +1665,7 @@ class RowIndex(tk.Canvas):
|
|
1676
1665
|
outline=fill,
|
1677
1666
|
tag="dd",
|
1678
1667
|
draw_outline=not dd_drawn,
|
1679
|
-
draw_arrow=
|
1668
|
+
draw_arrow=True,
|
1680
1669
|
open_=dd_coords == r,
|
1681
1670
|
)
|
1682
1671
|
else:
|
@@ -1785,7 +1774,7 @@ class RowIndex(tk.Canvas):
|
|
1785
1774
|
txt = txt[:-1]
|
1786
1775
|
self.itemconfig(iid, text=txt)
|
1787
1776
|
wd = self.bbox(iid)
|
1788
|
-
elif align == "e" and
|
1777
|
+
elif align == "e" and checkbox_kwargs:
|
1789
1778
|
txt = txt[len(txt) - int(len(txt) * (mw / wd)) :]
|
1790
1779
|
self.itemconfig(iid, text=txt)
|
1791
1780
|
wd = self.bbox(iid)
|
tksheet/sheet.py
CHANGED
@@ -126,10 +126,11 @@ class Sheet(tk.Frame):
|
|
126
126
|
default_header_height: str | int = "1",
|
127
127
|
default_row_index_width: int = 70,
|
128
128
|
default_row_height: str | int = "1",
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
min_column_width: int = 1,
|
130
|
+
max_column_width: float = float("inf"),
|
131
|
+
max_row_height: float = float("inf"),
|
132
|
+
max_header_height: float = float("inf"),
|
133
|
+
max_index_width: float = float("inf"),
|
133
134
|
after_redraw_time_ms: int = 20,
|
134
135
|
set_all_heights_and_widths: bool = False,
|
135
136
|
zoom: int = 100,
|
@@ -363,10 +364,6 @@ class Sheet(tk.Frame):
|
|
363
364
|
)
|
364
365
|
self.MT = MainTable(
|
365
366
|
parent=self,
|
366
|
-
max_column_width=max_column_width,
|
367
|
-
max_header_height=max_header_height,
|
368
|
-
max_row_height=max_row_height,
|
369
|
-
max_index_width=max_index_width,
|
370
367
|
show_index=show_row_index,
|
371
368
|
show_header=show_header,
|
372
369
|
column_headers_canvas=self.CH,
|
@@ -3797,25 +3794,25 @@ class Sheet(tk.Frame):
|
|
3797
3794
|
if column_widths[0] != 0:
|
3798
3795
|
return False
|
3799
3796
|
return not any(
|
3800
|
-
x - z < self.
|
3797
|
+
x - z < self.ops.min_column_width or not isinstance(x, int) or isinstance(x, bool)
|
3801
3798
|
for z, x in zip(column_widths, islice(column_widths, 1, None))
|
3802
3799
|
)
|
3803
3800
|
return not any(
|
3804
|
-
z < self.
|
3801
|
+
z < self.ops.min_column_width or not isinstance(z, int) or isinstance(z, bool) for z in column_widths
|
3805
3802
|
)
|
3806
3803
|
|
3807
3804
|
def valid_row_height(self, height: int) -> int:
|
3808
3805
|
if height < self.MT.min_row_height:
|
3809
3806
|
return self.MT.min_row_height
|
3810
|
-
elif height > self.
|
3811
|
-
return self.
|
3807
|
+
elif height > self.ops.max_row_height:
|
3808
|
+
return self.ops.max_row_height
|
3812
3809
|
return height
|
3813
3810
|
|
3814
3811
|
def valid_column_width(self, width: int) -> int:
|
3815
|
-
if width < self.
|
3816
|
-
return self.
|
3817
|
-
elif width > self.
|
3818
|
-
return self.
|
3812
|
+
if width < self.ops.min_column_width:
|
3813
|
+
return self.ops.min_column_width
|
3814
|
+
elif width > self.ops.max_column_width:
|
3815
|
+
return self.ops.max_column_width
|
3819
3816
|
return width
|
3820
3817
|
|
3821
3818
|
@property
|
@@ -4440,6 +4437,10 @@ class Sheet(tk.Frame):
|
|
4440
4437
|
self.ops[k] = v
|
4441
4438
|
if k.endswith("bindings"):
|
4442
4439
|
self.MT._enable_binding(k.split("_")[0])
|
4440
|
+
if "name" in kwargs:
|
4441
|
+
self.name = kwargs["name"]
|
4442
|
+
if "min_column_width" in kwargs:
|
4443
|
+
self.MT.set_min_column_width(kwargs["min_column_width"])
|
4443
4444
|
if "from_clipboard_delimiters" in kwargs:
|
4444
4445
|
self.ops.from_clipboard_delimiters = (
|
4445
4446
|
self.ops.from_clipboard_delimiters
|
@@ -4448,14 +4449,6 @@ class Sheet(tk.Frame):
|
|
4448
4449
|
)
|
4449
4450
|
if "default_row_height" in kwargs:
|
4450
4451
|
self.default_row_height(kwargs["default_row_height"])
|
4451
|
-
if "max_column_width" in kwargs:
|
4452
|
-
self.MT.max_column_width = float(kwargs["max_column_width"])
|
4453
|
-
if "max_row_height" in kwargs:
|
4454
|
-
self.MT.max_row_height = float(kwargs["max_row_height"])
|
4455
|
-
if "max_header_height" in kwargs:
|
4456
|
-
self.MT.max_header_height = float(kwargs["max_header_height"])
|
4457
|
-
if "max_index_width" in kwargs:
|
4458
|
-
self.MT.max_index_width = float(kwargs["max_index_width"])
|
4459
4452
|
if "expand_sheet_if_paste_too_big" in kwargs:
|
4460
4453
|
self.ops.paste_can_expand_x = kwargs["expand_sheet_if_paste_too_big"]
|
4461
4454
|
self.ops.paste_can_expand_y = kwargs["expand_sheet_if_paste_too_big"]
|
@@ -4494,7 +4487,6 @@ class Sheet(tk.Frame):
|
|
4494
4487
|
self.set_scrollbar_options()
|
4495
4488
|
self.MT.create_rc_menus()
|
4496
4489
|
if "treeview" in kwargs:
|
4497
|
-
self.set_options(auto_resize_row_index=True, redraw=False)
|
4498
4490
|
self.index_align("w", redraw=False)
|
4499
4491
|
return self.set_refresh_timer(redraw)
|
4500
4492
|
|
tksheet/sheet_options.py
CHANGED
@@ -186,5 +186,10 @@ def new_sheet_options() -> DotDict:
|
|
186
186
|
"treeview_indent": "5",
|
187
187
|
"rounded_boxes": True,
|
188
188
|
"alternate_color": "",
|
189
|
+
"min_column_width": 1,
|
190
|
+
"max_column_width": float("inf"),
|
191
|
+
"max_header_height": float("inf"),
|
192
|
+
"max_row_height": float("inf"),
|
193
|
+
"max_index_width": float("inf"),
|
189
194
|
}
|
190
195
|
)
|
tksheet/top_left_rectangle.py
CHANGED
@@ -160,21 +160,30 @@ class TopLeftRectangle(tk.Canvas):
|
|
160
160
|
self,
|
161
161
|
new_w: None | int = None,
|
162
162
|
new_h: None | int = None,
|
163
|
-
recreate_selection_boxes: bool = True,
|
164
163
|
) -> None:
|
165
164
|
try:
|
166
|
-
if isinstance(new_h, int):
|
165
|
+
if isinstance(new_h, int) and isinstance(new_w, int):
|
167
166
|
h = new_h
|
168
|
-
|
169
|
-
|
167
|
+
w = new_w
|
168
|
+
self.config(width=w, height=h)
|
169
|
+
|
170
|
+
elif isinstance(new_w, int) and new_h is None:
|
170
171
|
h = self.CH.current_height
|
171
|
-
if isinstance(new_w, int):
|
172
172
|
w = new_w
|
173
173
|
self.config(width=w)
|
174
|
+
|
175
|
+
elif isinstance(new_h, int) and new_w is None:
|
176
|
+
h = new_h
|
177
|
+
w = self.RI.current_width
|
178
|
+
self.config(height=h)
|
179
|
+
|
174
180
|
else:
|
181
|
+
h = self.CH.current_height
|
175
182
|
w = self.RI.current_width
|
183
|
+
|
176
184
|
except Exception:
|
177
185
|
return
|
186
|
+
|
178
187
|
self.coords(self.rw_box, 0, h - 5, w, h)
|
179
188
|
self.coords(self.rh_box, w - 5, 0, w, h)
|
180
189
|
self.coords(
|
@@ -187,8 +196,6 @@ class TopLeftRectangle(tk.Canvas):
|
|
187
196
|
h - 7,
|
188
197
|
)
|
189
198
|
self.coords(self.select_all_box, 0, 0, w - 5, h - 5)
|
190
|
-
if recreate_selection_boxes:
|
191
|
-
self.MT.recreate_all_selection_boxes()
|
192
199
|
|
193
200
|
def mouse_motion(self, event: object = None) -> None:
|
194
201
|
self.MT.reset_mouse_motion_creations()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tksheet
|
3
|
-
Version: 7.
|
3
|
+
Version: 7.3.0
|
4
4
|
Summary: Tkinter table / sheet widget
|
5
5
|
Author-email: ragardner <github@ragardner.simplelogin.com>
|
6
6
|
License: Copyright (c) 2019 ragardner and open source contributors
|
@@ -36,12 +36,14 @@ Classifier: Programming Language :: Python :: 3.9
|
|
36
36
|
Classifier: Programming Language :: Python :: 3.10
|
37
37
|
Classifier: Programming Language :: Python :: 3.11
|
38
38
|
Classifier: Programming Language :: Python :: 3.12
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
39
40
|
Requires-Python: >=3.8
|
40
41
|
Description-Content-Type: text/markdown
|
41
42
|
License-File: LICENSE.txt
|
42
43
|
|
43
44
|
<p align="center" width="100%">
|
44
|
-
<img width="
|
45
|
+
<img width="45%" src="https://github.com/user-attachments/assets/4afc1783-6461-4b98-93cb-b2a2a7f35169" alt="tksheet table">
|
46
|
+
<img width="45%"src="https://github.com/user-attachments/assets/08e77e89-00ea-4c52-9222-9bd421284360" alt="tksheet treeview">
|
45
47
|
</p>
|
46
48
|
|
47
49
|
# <div align="center">tksheet - python tkinter table widget</div>
|
@@ -50,14 +52,35 @@ License-File: LICENSE.txt
|
|
50
52
|
|
51
53
|
[](https://github.com/ragardner/tksheet/releases) [](https://pypi.org/project/tksheet/)
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
<table>
|
56
|
+
<thead>
|
57
|
+
<tr>
|
58
|
+
<th style="color: lightgreen" colspan=2><strong>Help</strong></th>
|
59
|
+
</tr>
|
60
|
+
</thead>
|
61
|
+
<tbody>
|
62
|
+
<tr>
|
63
|
+
<td style="color: LightCoral">Versions 6.x.x →</td>
|
64
|
+
<td><a href="https://github.com/ragardner/tksheet/wiki/Version-6">Documentation Wiki</a></td>
|
65
|
+
</tr>
|
66
|
+
<tr>
|
67
|
+
<td style="color: lightgreen">Versions 7.x.x →</td>
|
68
|
+
<td><a href="https://github.com/ragardner/tksheet/wiki/Version-7">Documentation Wiki</a></td>
|
69
|
+
</tr>
|
70
|
+
<tr>
|
71
|
+
<td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/blob/master/docs/CHANGELOG.md">Changelog</a></td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#asking-questions">Questions</a></td>
|
75
|
+
</tr>
|
76
|
+
<tr>
|
77
|
+
<td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#issues">Issues</a></td>
|
78
|
+
</tr>
|
79
|
+
<tr>
|
80
|
+
<td align="right" colspan="2"><a href="https://github.com/ragardner/tksheet/wiki/Version-7#enhancements-or-suggestions">Suggestions</a></td>
|
81
|
+
</tr>
|
82
|
+
</tbody>
|
83
|
+
</table>
|
61
84
|
|
62
85
|
This library is maintained with the help of **[others](https://github.com/ragardner/tksheet/graphs/contributors)**. If you would like to contribute please read this [help section](https://github.com/ragardner/tksheet/wiki/Version-7#contributing).
|
63
86
|
|
@@ -82,8 +105,10 @@ This library is maintained with the help of **[others](https://github.com/ragard
|
|
82
105
|
- Expand row heights and column widths
|
83
106
|
- Change fonts and font size (not for individual cells)
|
84
107
|
- Change any colors in the sheet
|
85
|
-
- Dropdowns, check boxes, progress bars
|
86
108
|
- [Treeview mode](https://github.com/ragardner/tksheet/wiki/Version-7#treeview-mode)
|
109
|
+
- [Dropdown boxes](https://github.com/ragardner/tksheet/wiki/Version-7#dropdown-boxes)
|
110
|
+
- [Check boxes](https://github.com/ragardner/tksheet/wiki/Version-7#check-boxes)
|
111
|
+
- [Progress bars](https://github.com/ragardner/tksheet/wiki/Version-7#progress-bars)
|
87
112
|
- [Hide rows and/or columns](https://github.com/ragardner/tksheet/wiki/Version-7#example-header-dropdown-boxes-and-row-filtering)
|
88
113
|
- Left `"w"`, Center `"center"` or Right `"e"` text alignment for any cell/row/column
|
89
114
|
|
@@ -117,4 +142,3 @@ sheet.delete_columns(columns=[0, 3], undo=True)
|
|
117
142
|

|
118
143
|
|
119
144
|
|
120
|
-
|
@@ -0,0 +1,20 @@
|
|
1
|
+
tksheet/__init__.py,sha256=og5YQbRL0wYfgixmKn9svO5aBxbujfvRhBsWlhmOtVs,2236
|
2
|
+
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
+
tksheet/column_headers.py,sha256=qNDoJoERLKs9hG9rVgclIk-HAZkmJ6Y6qwvdlCa2-l8,102502
|
4
|
+
tksheet/formatters.py,sha256=_exO2KnjtcnE_MVWLG1ngOZ-wmrXZhuh7uEi2iPs1Tk,10546
|
5
|
+
tksheet/functions.py,sha256=v9_YH1-6cQ-tixl-P2ZR0bGNOsOa6FyYMwBsAl1YLrQ,43224
|
6
|
+
tksheet/main_table.py,sha256=6rhc4RtK4s8Mh5bhq_hyVlX56l-1B7a2D1WWd3nfacI,334819
|
7
|
+
tksheet/other_classes.py,sha256=cYcu8TYgGdsJ6ZGG51AQFVrzj7Lu0LwAn62V7iUh_mc,16488
|
8
|
+
tksheet/row_index.py,sha256=oe71E_Y3nj5dhbRTw5DhYDgqxPlL0mGYmaZaMu8AP5w,111295
|
9
|
+
tksheet/sheet.py,sha256=vMsZdciGrNvg0xcDaVAbadlHhCDj_XAy3HgXIz63FPw,288653
|
10
|
+
tksheet/sheet_options.py,sha256=j2e0ij8Pf9ey85GKuMXoCDMkFGJVcDk3t_NNVlBGbuI,6991
|
11
|
+
tksheet/text_editor.py,sha256=zrBdURBFNBbnl8GmZ4vQMFZ3UmvAvfBZ7KSJi_WtrNI,7449
|
12
|
+
tksheet/themes.py,sha256=AoNAxibnQi04MN0Zpbn9-kyDnkiiV8TDNWP9FYjpuf0,18473
|
13
|
+
tksheet/top_left_rectangle.py,sha256=0vzhYK7oGe9M_v7mlxFLh595XuXuXDOjooCDuR5sqnM,8593
|
14
|
+
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
15
|
+
tksheet/vars.py,sha256=-NWaHEEpcQ0YHn4yGDf8SSffjceiEOayGqnEYw6VwPM,3507
|
16
|
+
tksheet-7.3.0.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
17
|
+
tksheet-7.3.0.dist-info/METADATA,sha256=Fheob3WhJC4xXiBM01uelrZdxT0pVu-p_t6JQmziReI,7282
|
18
|
+
tksheet-7.3.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
19
|
+
tksheet-7.3.0.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
20
|
+
tksheet-7.3.0.dist-info/RECORD,,
|
tksheet-7.2.23.dist-info/RECORD
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
tksheet/__init__.py,sha256=xBKEG-m6pGAjxHMQonW2r7Q3WOuMn_TGvOrTslvsME4,2237
|
2
|
-
tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
|
3
|
-
tksheet/column_headers.py,sha256=6PHeHbCu3nSjeQaE46erRx9VdyNCw-L0vdeuukqTCvs,102908
|
4
|
-
tksheet/formatters.py,sha256=_exO2KnjtcnE_MVWLG1ngOZ-wmrXZhuh7uEi2iPs1Tk,10546
|
5
|
-
tksheet/functions.py,sha256=gAksrYFwZi6yC21si0PM4TZyPKdyrIQWqSVB4F-5TF4,43106
|
6
|
-
tksheet/main_table.py,sha256=ilNrXHlebYiwb9dyB13wgMCcjaMCJb35ISAlnMx4Xgg,334993
|
7
|
-
tksheet/other_classes.py,sha256=cYcu8TYgGdsJ6ZGG51AQFVrzj7Lu0LwAn62V7iUh_mc,16488
|
8
|
-
tksheet/row_index.py,sha256=7xBrkIQy8SSn2YDPCDQlb2gj7SQLPH2KL3pYoKfdC3c,111767
|
9
|
-
tksheet/sheet.py,sha256=BJhMAHh37KdXrdDmHxXv2g2K_x0O9GtbBeLEp5pFfN4,289185
|
10
|
-
tksheet/sheet_options.py,sha256=TXNL07Di9KAsl5yH9QSTfo-5Ykmb9nTmkXZWXnkZlEw,6769
|
11
|
-
tksheet/text_editor.py,sha256=zrBdURBFNBbnl8GmZ4vQMFZ3UmvAvfBZ7KSJi_WtrNI,7449
|
12
|
-
tksheet/themes.py,sha256=AoNAxibnQi04MN0Zpbn9-kyDnkiiV8TDNWP9FYjpuf0,18473
|
13
|
-
tksheet/top_left_rectangle.py,sha256=ri7hb9CC5l37ynmxceprq11UuWWRpWEI_0AI42wzv0A,8444
|
14
|
-
tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
|
15
|
-
tksheet/vars.py,sha256=-NWaHEEpcQ0YHn4yGDf8SSffjceiEOayGqnEYw6VwPM,3507
|
16
|
-
tksheet-7.2.23.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
|
17
|
-
tksheet-7.2.23.dist-info/METADATA,sha256=r0MWVHuXUahO8TZArYcPCYeG5VMwXwMI9qUEMf0eBmw,6481
|
18
|
-
tksheet-7.2.23.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
19
|
-
tksheet-7.2.23.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
|
20
|
-
tksheet-7.2.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|