tksheet 7.1.20__py3-none-any.whl → 7.1.22__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 +5 -1
- tksheet/column_headers.py +36 -26
- tksheet/functions.py +27 -5
- tksheet/main_table.py +116 -58
- tksheet/row_index.py +149 -94
- tksheet/sheet.py +317 -261
- tksheet/sheet_options.py +4 -1
- tksheet/text_editor.py +1 -5
- tksheet/themes.py +51 -30
- tksheet/vars.py +22 -9
- {tksheet-7.1.20.dist-info → tksheet-7.1.22.dist-info}/METADATA +5 -5
- tksheet-7.1.22.dist-info/RECORD +20 -0
- tksheet-7.1.20.dist-info/RECORD +0 -20
- {tksheet-7.1.20.dist-info → tksheet-7.1.22.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.1.20.dist-info → tksheet-7.1.22.dist-info}/WHEEL +0 -0
- {tksheet-7.1.20.dist-info → tksheet-7.1.22.dist-info}/top_level.txt +0 -0
tksheet/row_index.py
CHANGED
@@ -32,6 +32,7 @@ from .functions import (
|
|
32
32
|
event_dict,
|
33
33
|
get_n2a,
|
34
34
|
is_contiguous,
|
35
|
+
new_tk_event,
|
35
36
|
num2alpha,
|
36
37
|
pickled_event_dict,
|
37
38
|
rounded_box_coords,
|
@@ -48,9 +49,10 @@ from .text_editor import (
|
|
48
49
|
TextEditor,
|
49
50
|
)
|
50
51
|
from .vars import (
|
51
|
-
USER_OS,
|
52
52
|
rc_binding,
|
53
53
|
symbols_set,
|
54
|
+
text_editor_close_bindings,
|
55
|
+
text_editor_newline_bindings,
|
54
56
|
text_editor_to_unbind,
|
55
57
|
)
|
56
58
|
|
@@ -117,6 +119,7 @@ class RowIndex(tk.Canvas):
|
|
117
119
|
self.disp_resize_lines = {}
|
118
120
|
self.disp_dropdown = {}
|
119
121
|
self.disp_checkbox = {}
|
122
|
+
self.disp_tree_arrow = {}
|
120
123
|
self.disp_boxes = set()
|
121
124
|
self.hidd_text = {}
|
122
125
|
self.hidd_high = {}
|
@@ -126,6 +129,7 @@ class RowIndex(tk.Canvas):
|
|
126
129
|
self.hidd_resize_lines = {}
|
127
130
|
self.hidd_dropdown = {}
|
128
131
|
self.hidd_checkbox = {}
|
132
|
+
self.hidd_tree_arrow = {}
|
129
133
|
self.hidd_boxes = set()
|
130
134
|
|
131
135
|
self.align = kwargs["row_index_align"]
|
@@ -134,6 +138,13 @@ class RowIndex(tk.Canvas):
|
|
134
138
|
self.tree_reset()
|
135
139
|
self.basic_bindings()
|
136
140
|
|
141
|
+
def event_generate(self, *args, **kwargs) -> None:
|
142
|
+
for arg in args:
|
143
|
+
if self.MT and arg in self.MT.event_linker:
|
144
|
+
self.MT.event_linker[arg]()
|
145
|
+
else:
|
146
|
+
super().event_generate(*args, **kwargs)
|
147
|
+
|
137
148
|
def basic_bindings(self, enable: bool = True) -> None:
|
138
149
|
if enable:
|
139
150
|
self.bind("<Motion>", self.mouse_motion)
|
@@ -833,6 +844,7 @@ class RowIndex(tk.Canvas):
|
|
833
844
|
event_data = event_dict(
|
834
845
|
name="move_rows",
|
835
846
|
sheet=self.PAR.name,
|
847
|
+
widget=self,
|
836
848
|
boxes=self.MT.get_boxes(),
|
837
849
|
selected=self.MT.selected,
|
838
850
|
value=r,
|
@@ -844,6 +856,7 @@ class RowIndex(tk.Canvas):
|
|
844
856
|
to_move=self.dragged_row.to_move,
|
845
857
|
),
|
846
858
|
move_data=self.PAR.ops.row_drag_and_drop_perform,
|
859
|
+
move_heights=self.PAR.ops.row_drag_and_drop_perform,
|
847
860
|
event_data=event_data,
|
848
861
|
)
|
849
862
|
event_data["moved"]["rows"] = {
|
@@ -1009,7 +1022,7 @@ class RowIndex(tk.Canvas):
|
|
1009
1022
|
w = self.PAR.ops.default_row_index_width
|
1010
1023
|
h = self.MT.min_row_height
|
1011
1024
|
if self.get_cell_kwargs(datarn, key="dropdown") or self.get_cell_kwargs(datarn, key="checkbox"):
|
1012
|
-
w += self.MT.index_txt_height
|
1025
|
+
w += self.MT.index_txt_height + 2
|
1013
1026
|
if self.PAR.ops.treeview:
|
1014
1027
|
if datarn in self.cell_options and "align" in self.cell_options[datarn]:
|
1015
1028
|
align = self.cell_options[datarn]["align"]
|
@@ -1017,7 +1030,7 @@ class RowIndex(tk.Canvas):
|
|
1017
1030
|
align = self.align
|
1018
1031
|
if align == "w":
|
1019
1032
|
w += self.MT.index_txt_height
|
1020
|
-
w += self.get_treeview_indent(self.MT._row_index[datarn].iid)
|
1033
|
+
w += self.get_treeview_indent(self.MT._row_index[datarn].iid) + 4
|
1021
1034
|
return w, h
|
1022
1035
|
|
1023
1036
|
def set_row_height(
|
@@ -1191,9 +1204,9 @@ class RowIndex(tk.Canvas):
|
|
1191
1204
|
new_w = self.set_width_of_index_to_text(only_rows=only_rows, set_width=False)
|
1192
1205
|
else:
|
1193
1206
|
new_w = None
|
1194
|
-
if new_w is not None and (sheet_w_x := floor(self.PAR.winfo_width() * 0.
|
1207
|
+
if new_w is not None and (sheet_w_x := floor(self.PAR.winfo_width() * 0.7)) < new_w:
|
1195
1208
|
new_w = sheet_w_x
|
1196
|
-
if new_w and (self.current_width - new_w > 15 or new_w - self.current_width >
|
1209
|
+
if new_w and (self.current_width - new_w > 15 or new_w - self.current_width > 3):
|
1197
1210
|
self.set_width(new_w, set_TL=True)
|
1198
1211
|
return True
|
1199
1212
|
return False
|
@@ -1205,7 +1218,7 @@ class RowIndex(tk.Canvas):
|
|
1205
1218
|
if kwargs[0] is not None:
|
1206
1219
|
c_1 = kwargs[0] if kwargs[0].startswith("#") else color_map[kwargs[0]]
|
1207
1220
|
if "rows" in selections and r in selections["rows"]:
|
1208
|
-
|
1221
|
+
txtfg = (
|
1209
1222
|
self.PAR.ops.index_selected_rows_fg
|
1210
1223
|
if kwargs[1] is None or self.PAR.ops.display_selected_fg_over_highlights
|
1211
1224
|
else kwargs[1]
|
@@ -1217,7 +1230,7 @@ class RowIndex(tk.Canvas):
|
|
1217
1230
|
+ f"{int((int(c_1[5:], 16) + int(c_3[5:], 16)) / 2):02X}"
|
1218
1231
|
)
|
1219
1232
|
elif "cells" in selections and r in selections["cells"]:
|
1220
|
-
|
1233
|
+
txtfg = (
|
1221
1234
|
self.PAR.ops.index_selected_cells_fg
|
1222
1235
|
if kwargs[1] is None or self.PAR.ops.display_selected_fg_over_highlights
|
1223
1236
|
else kwargs[1]
|
@@ -1229,7 +1242,7 @@ class RowIndex(tk.Canvas):
|
|
1229
1242
|
+ f"{int((int(c_1[5:], 16) + int(c_2[5:], 16)) / 2):02X}"
|
1230
1243
|
)
|
1231
1244
|
else:
|
1232
|
-
|
1245
|
+
txtfg = self.PAR.ops.index_fg if kwargs[1] is None else kwargs[1]
|
1233
1246
|
if kwargs[0] is not None:
|
1234
1247
|
fill = kwargs[0]
|
1235
1248
|
if kwargs[0] is not None:
|
@@ -1246,14 +1259,18 @@ class RowIndex(tk.Canvas):
|
|
1246
1259
|
),
|
1247
1260
|
tag="s",
|
1248
1261
|
)
|
1262
|
+
tree_arrow_fg = txtfg
|
1249
1263
|
elif not kwargs:
|
1250
1264
|
if "rows" in selections and r in selections["rows"]:
|
1251
|
-
|
1265
|
+
txtfg = self.PAR.ops.index_selected_rows_fg
|
1266
|
+
tree_arrow_fg = self.PAR.ops.selected_rows_tree_arrow_fg
|
1252
1267
|
elif "cells" in selections and r in selections["cells"]:
|
1253
|
-
|
1268
|
+
txtfg = self.PAR.ops.index_selected_cells_fg
|
1269
|
+
tree_arrow_fg = self.PAR.ops.selected_cells_tree_arrow_fg
|
1254
1270
|
else:
|
1255
|
-
|
1256
|
-
|
1271
|
+
txtfg = self.PAR.ops.index_fg
|
1272
|
+
tree_arrow_fg = self.PAR.ops.tree_arrow_fg
|
1273
|
+
return txtfg, tree_arrow_fg, redrawn
|
1257
1274
|
|
1258
1275
|
def redraw_highlight(self, x1, y1, x2, y2, fill, outline, tag):
|
1259
1276
|
coords = (x1, y1, x2, y2)
|
@@ -1281,6 +1298,56 @@ class RowIndex(tk.Canvas):
|
|
1281
1298
|
else:
|
1282
1299
|
self.disp_grid[self.create_line(points, fill=fill, width=width, tag=tag)] = True
|
1283
1300
|
|
1301
|
+
def redraw_tree_arrow(
|
1302
|
+
self,
|
1303
|
+
x1,
|
1304
|
+
y1,
|
1305
|
+
r,
|
1306
|
+
fill,
|
1307
|
+
tag,
|
1308
|
+
indent: float,
|
1309
|
+
open_: bool = False,
|
1310
|
+
) -> None:
|
1311
|
+
mod = (self.MT.index_txt_height - 1) if self.MT.index_txt_height % 2 else self.MT.index_txt_height
|
1312
|
+
half_mod = mod / 2
|
1313
|
+
qtr_mod = mod / 4
|
1314
|
+
mid_y = (self.MT.index_first_ln_ins - 1) if self.MT.index_first_ln_ins % 2 else self.MT.index_first_ln_ins
|
1315
|
+
# up arrow
|
1316
|
+
if open_:
|
1317
|
+
points = (
|
1318
|
+
x1 + 2 + indent,
|
1319
|
+
y1 + mid_y + qtr_mod,
|
1320
|
+
x1 + 2 + half_mod + indent,
|
1321
|
+
y1 + mid_y - qtr_mod,
|
1322
|
+
x1 + 2 + mod + indent,
|
1323
|
+
y1 + mid_y + qtr_mod,
|
1324
|
+
)
|
1325
|
+
# right pointing arrow
|
1326
|
+
else:
|
1327
|
+
points = (
|
1328
|
+
x1 + half_mod + indent,
|
1329
|
+
y1 + mid_y - half_mod + 1,
|
1330
|
+
x1 + mod + indent - 1,
|
1331
|
+
y1 + mid_y,
|
1332
|
+
x1 + half_mod + indent,
|
1333
|
+
y1 + mid_y + half_mod - 1,
|
1334
|
+
)
|
1335
|
+
if self.hidd_tree_arrow:
|
1336
|
+
t, sh = self.hidd_tree_arrow.popitem()
|
1337
|
+
self.coords(t, points)
|
1338
|
+
if sh:
|
1339
|
+
self.itemconfig(t, fill=fill)
|
1340
|
+
else:
|
1341
|
+
self.itemconfig(t, fill=fill, tag=tag, state="normal")
|
1342
|
+
self.lift(t)
|
1343
|
+
else:
|
1344
|
+
t = self.create_polygon(
|
1345
|
+
points,
|
1346
|
+
fill=fill,
|
1347
|
+
tag=tag,
|
1348
|
+
)
|
1349
|
+
self.disp_tree_arrow[t] = True
|
1350
|
+
|
1284
1351
|
def redraw_dropdown(
|
1285
1352
|
self,
|
1286
1353
|
x1,
|
@@ -1293,7 +1360,6 @@ class RowIndex(tk.Canvas):
|
|
1293
1360
|
draw_outline: bool = True,
|
1294
1361
|
draw_arrow: bool = True,
|
1295
1362
|
open_: bool = False,
|
1296
|
-
indent: None | float = None,
|
1297
1363
|
) -> None:
|
1298
1364
|
if draw_outline and self.PAR.ops.show_dropdown_borders:
|
1299
1365
|
self.redraw_highlight(x1 + 1, y1 + 1, x2, y2, fill="", outline=self.PAR.ops.index_fg, tag=tag)
|
@@ -1302,47 +1368,24 @@ class RowIndex(tk.Canvas):
|
|
1302
1368
|
half_mod = mod / 2
|
1303
1369
|
qtr_mod = mod / 4
|
1304
1370
|
mid_y = (self.MT.index_first_ln_ins - 1) if self.MT.index_first_ln_ins % 2 else self.MT.index_first_ln_ins
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
x1 + 2 + mod + indent,
|
1315
|
-
y1 + mid_y + qtr_mod,
|
1316
|
-
)
|
1317
|
-
# right pointing arrow
|
1318
|
-
else:
|
1319
|
-
points = (
|
1320
|
-
x1 + half_mod + indent,
|
1321
|
-
y1 + mid_y - half_mod + 1,
|
1322
|
-
x1 + mod + indent - 1,
|
1323
|
-
y1 + mid_y,
|
1324
|
-
x1 + half_mod + indent,
|
1325
|
-
y1 + mid_y + half_mod - 1,
|
1326
|
-
)
|
1371
|
+
if open_:
|
1372
|
+
points = (
|
1373
|
+
x2 - 3 - mod,
|
1374
|
+
y1 + mid_y + qtr_mod,
|
1375
|
+
x2 - 3 - half_mod,
|
1376
|
+
y1 + mid_y - qtr_mod,
|
1377
|
+
x2 - 3,
|
1378
|
+
y1 + mid_y + qtr_mod,
|
1379
|
+
)
|
1327
1380
|
else:
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
)
|
1337
|
-
else:
|
1338
|
-
points = (
|
1339
|
-
x2 - 3 - mod,
|
1340
|
-
y1 + mid_y - qtr_mod,
|
1341
|
-
x2 - 3 - half_mod,
|
1342
|
-
y1 + mid_y + qtr_mod,
|
1343
|
-
x2 - 3,
|
1344
|
-
y1 + mid_y - qtr_mod,
|
1345
|
-
)
|
1381
|
+
points = (
|
1382
|
+
x2 - 3 - mod,
|
1383
|
+
y1 + mid_y - qtr_mod,
|
1384
|
+
x2 - 3 - half_mod,
|
1385
|
+
y1 + mid_y + qtr_mod,
|
1386
|
+
x2 - 3,
|
1387
|
+
y1 + mid_y - qtr_mod,
|
1388
|
+
)
|
1346
1389
|
if self.hidd_dropdown:
|
1347
1390
|
t, sh = self.hidd_dropdown.popitem()
|
1348
1391
|
self.coords(t, points)
|
@@ -1352,12 +1395,9 @@ class RowIndex(tk.Canvas):
|
|
1352
1395
|
self.itemconfig(t, fill=fill, tag=tag, state="normal")
|
1353
1396
|
self.lift(t)
|
1354
1397
|
else:
|
1355
|
-
t = self.
|
1398
|
+
t = self.create_polygon(
|
1356
1399
|
points,
|
1357
1400
|
fill=fill,
|
1358
|
-
width=2,
|
1359
|
-
capstyle=tk.ROUND,
|
1360
|
-
joinstyle=tk.ROUND,
|
1361
1401
|
tag=tag,
|
1362
1402
|
)
|
1363
1403
|
self.disp_dropdown[t] = True
|
@@ -1428,6 +1468,8 @@ class RowIndex(tk.Canvas):
|
|
1428
1468
|
self.disp_dropdown = {}
|
1429
1469
|
self.hidd_checkbox.update(self.disp_checkbox)
|
1430
1470
|
self.disp_checkbox = {}
|
1471
|
+
self.hidd_tree_arrow.update(self.disp_tree_arrow)
|
1472
|
+
self.disp_tree_arrow = {}
|
1431
1473
|
self.visible_row_dividers = {}
|
1432
1474
|
draw_y = self.MT.row_positions[start_row]
|
1433
1475
|
xend = self.current_width - 6
|
@@ -1484,7 +1526,15 @@ class RowIndex(tk.Canvas):
|
|
1484
1526
|
if rbotgridln - rtopgridln < self.MT.index_txt_height:
|
1485
1527
|
continue
|
1486
1528
|
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1487
|
-
fill, dd_drawn = self.redraw_highlight_get_text_fg(
|
1529
|
+
fill, tree_arrow_fg, dd_drawn = self.redraw_highlight_get_text_fg(
|
1530
|
+
rtopgridln,
|
1531
|
+
rbotgridln,
|
1532
|
+
r,
|
1533
|
+
c_2,
|
1534
|
+
c_3,
|
1535
|
+
selections,
|
1536
|
+
datarn,
|
1537
|
+
)
|
1488
1538
|
|
1489
1539
|
if datarn in self.cell_options and "align" in self.cell_options[datarn]:
|
1490
1540
|
align = self.cell_options[datarn]["align"]
|
@@ -1584,20 +1634,16 @@ class RowIndex(tk.Canvas):
|
|
1584
1634
|
if align == "w":
|
1585
1635
|
draw_x += self.MT.index_txt_height + 1
|
1586
1636
|
indent = self.get_treeview_indent(iid)
|
1587
|
-
draw_x += indent
|
1637
|
+
draw_x += indent + 4
|
1588
1638
|
if self.tree[iid].children:
|
1589
|
-
self.
|
1639
|
+
self.redraw_tree_arrow(
|
1590
1640
|
0,
|
1591
1641
|
rtopgridln,
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
outline=fill,
|
1596
|
-
tag="dd",
|
1597
|
-
draw_outline=False,
|
1598
|
-
draw_arrow=True,
|
1599
|
-
open_=self.MT._row_index[datarn].iid in self.tree_open_ids,
|
1642
|
+
r=r,
|
1643
|
+
fill=tree_arrow_fg,
|
1644
|
+
tag="ta",
|
1600
1645
|
indent=indent,
|
1646
|
+
open_=self.MT._row_index[datarn].iid in self.tree_open_ids,
|
1601
1647
|
)
|
1602
1648
|
lns = self.get_valid_cell_data_as_str(datarn, fix=False)
|
1603
1649
|
if not lns:
|
@@ -1677,7 +1723,14 @@ class RowIndex(tk.Canvas):
|
|
1677
1723
|
draw_y += self.MT.index_xtra_lines_increment
|
1678
1724
|
if draw_y + self.MT.index_half_txt_height - 1 > rbotgridln:
|
1679
1725
|
break
|
1680
|
-
for dct in (
|
1726
|
+
for dct in (
|
1727
|
+
self.hidd_text,
|
1728
|
+
self.hidd_high,
|
1729
|
+
self.hidd_grid,
|
1730
|
+
self.hidd_dropdown,
|
1731
|
+
self.hidd_checkbox,
|
1732
|
+
self.hidd_tree_arrow,
|
1733
|
+
):
|
1681
1734
|
for iid, showing in dct.items():
|
1682
1735
|
if showing:
|
1683
1736
|
self.itemconfig(iid, state="hidden")
|
@@ -1819,24 +1872,19 @@ class RowIndex(tk.Canvas):
|
|
1819
1872
|
self.itemconfig(self.text_editor.canvas_id, state="normal")
|
1820
1873
|
self.text_editor.open = True
|
1821
1874
|
self.coords(self.text_editor.canvas_id, x, y)
|
1875
|
+
for b in text_editor_newline_bindings:
|
1876
|
+
self.text_editor.tktext.bind(b, self.text_editor_newline_binding)
|
1877
|
+
for b in text_editor_close_bindings:
|
1878
|
+
self.text_editor.tktext.bind(b, self.close_text_editor)
|
1822
1879
|
if not dropdown:
|
1823
1880
|
self.text_editor.tktext.focus_set()
|
1824
1881
|
self.text_editor.window.scroll_to_bottom()
|
1825
|
-
|
1826
|
-
self.text_editor.tktext.bind("<Alt-KP_Enter>", lambda _x: self.text_editor_newline_binding(r=r))
|
1827
|
-
if USER_OS == "darwin":
|
1828
|
-
self.text_editor.tktext.bind("<Option-Return>", lambda _x: self.text_editor_newline_binding(r=r))
|
1882
|
+
self.text_editor.tktext.bind("<FocusOut>", self.close_text_editor)
|
1829
1883
|
for key, func in self.MT.text_editor_user_bound_keys.items():
|
1830
1884
|
self.text_editor.tktext.bind(key, func)
|
1831
|
-
self.text_editor.tktext.bind("<Tab>", lambda _x: self.close_text_editor((r, "Tab")))
|
1832
|
-
self.text_editor.tktext.bind("<Return>", lambda _x: self.close_text_editor((r, "Return")))
|
1833
|
-
self.text_editor.tktext.bind("<KP_Enter>", lambda _x: self.close_text_editor((r, "Return")))
|
1834
|
-
if not dropdown:
|
1835
|
-
self.text_editor.tktext.bind("<FocusOut>", lambda _x: self.close_text_editor((r, "FocusOut")))
|
1836
|
-
self.text_editor.tktext.bind("<Escape>", lambda _x: self.close_text_editor((r, "Escape")))
|
1837
1885
|
return True
|
1838
1886
|
|
1839
|
-
def text_editor_newline_binding(self,
|
1887
|
+
def text_editor_newline_binding(self, event: object = None, check_lines=True):
|
1840
1888
|
if not self.height_resizing_enabled:
|
1841
1889
|
return
|
1842
1890
|
curr_height = self.text_editor.window.winfo_height()
|
@@ -1850,6 +1898,7 @@ class RowIndex(tk.Canvas):
|
|
1850
1898
|
)
|
1851
1899
|
> curr_height
|
1852
1900
|
):
|
1901
|
+
r = self.text_editor.row
|
1853
1902
|
new_height = curr_height + self.MT.index_xtra_lines_increment
|
1854
1903
|
space_bot = self.MT.get_space_bot(r)
|
1855
1904
|
if new_height > space_bot:
|
@@ -1865,14 +1914,14 @@ class RowIndex(tk.Canvas):
|
|
1865
1914
|
if anchor == "nw":
|
1866
1915
|
self.coords(
|
1867
1916
|
self.dropdown.canvas_id,
|
1868
|
-
|
1917
|
+
0,
|
1869
1918
|
self.MT.row_positions[r] + text_editor_h - 1,
|
1870
1919
|
)
|
1871
1920
|
self.itemconfig(self.dropdown.canvas_id, anchor=anchor, height=win_h)
|
1872
1921
|
elif anchor == "sw":
|
1873
1922
|
self.coords(
|
1874
1923
|
self.dropdown.canvas_id,
|
1875
|
-
|
1924
|
+
0,
|
1876
1925
|
self.MT.row_positions[r],
|
1877
1926
|
)
|
1878
1927
|
self.itemconfig(self.dropdown.canvas_id, anchor=anchor, height=win_h)
|
@@ -1926,29 +1975,32 @@ class RowIndex(tk.Canvas):
|
|
1926
1975
|
self.focus_set()
|
1927
1976
|
|
1928
1977
|
# r is displayed row
|
1929
|
-
def close_text_editor(
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1978
|
+
def close_text_editor(self, event: tk.Event) -> Literal["break"] | None:
|
1979
|
+
# checking if text editor should be closed or not
|
1980
|
+
# errors if __tk_filedialog is open
|
1981
|
+
try:
|
1982
|
+
focused = self.focus_get()
|
1983
|
+
except Exception:
|
1984
|
+
focused = None
|
1934
1985
|
try:
|
1935
1986
|
if focused == self.text_editor.tktext.rc_popup_menu:
|
1936
1987
|
return "break"
|
1937
1988
|
except Exception:
|
1938
1989
|
pass
|
1939
|
-
if focused is None
|
1990
|
+
if focused is None:
|
1940
1991
|
return "break"
|
1941
|
-
if
|
1992
|
+
if event.keysym == "Escape":
|
1942
1993
|
self.hide_text_editor_and_dropdown()
|
1943
1994
|
return
|
1944
1995
|
text_editor_value = self.text_editor.get()
|
1945
|
-
r =
|
1996
|
+
r = self.text_editor.row
|
1946
1997
|
datarn = r if self.MT.all_rows_displayed else self.MT.displayed_rows[r]
|
1947
1998
|
event_data = event_dict(
|
1948
1999
|
name="end_edit_index",
|
1949
2000
|
sheet=self.PAR.name,
|
2001
|
+
widget=self,
|
1950
2002
|
cells_index={datarn: self.get_cell_data(datarn)},
|
1951
|
-
key=
|
2003
|
+
key=event.keysym,
|
1952
2004
|
value=text_editor_value,
|
1953
2005
|
loc=r,
|
1954
2006
|
row=r,
|
@@ -1972,7 +2024,7 @@ class RowIndex(tk.Canvas):
|
|
1972
2024
|
try_binding(self.extra_end_edit_cell_func, event_data)
|
1973
2025
|
self.MT.recreate_all_selection_boxes()
|
1974
2026
|
self.hide_text_editor_and_dropdown()
|
1975
|
-
if
|
2027
|
+
if event.keysym != "FocusOut":
|
1976
2028
|
self.focus_set()
|
1977
2029
|
return "break"
|
1978
2030
|
|
@@ -2109,6 +2161,7 @@ class RowIndex(tk.Canvas):
|
|
2109
2161
|
event_data = event_dict(
|
2110
2162
|
name="end_edit_index",
|
2111
2163
|
sheet=self.PAR.name,
|
2164
|
+
widget=self,
|
2112
2165
|
cells_header={datarn: pre_edit_value},
|
2113
2166
|
key="??",
|
2114
2167
|
value=selection,
|
@@ -2140,7 +2193,7 @@ class RowIndex(tk.Canvas):
|
|
2140
2193
|
def mouseclick_outside_editor_or_dropdown(self, inside: bool = False):
|
2141
2194
|
closed_dd_coords = self.dropdown.get_coords()
|
2142
2195
|
if self.text_editor.open:
|
2143
|
-
self.close_text_editor((
|
2196
|
+
self.close_text_editor(new_tk_event("ButtonPress-1"))
|
2144
2197
|
if closed_dd_coords is not None:
|
2145
2198
|
self.hide_dropdown_window()
|
2146
2199
|
if inside:
|
@@ -2178,6 +2231,7 @@ class RowIndex(tk.Canvas):
|
|
2178
2231
|
event_data = event_dict(
|
2179
2232
|
name="edit_index",
|
2180
2233
|
sheet=self.PAR.name,
|
2234
|
+
widget=self,
|
2181
2235
|
cells_index={datarn: self.get_cell_data(datarn)},
|
2182
2236
|
boxes=self.MT.get_boxes(),
|
2183
2237
|
selected=self.MT.selected,
|
@@ -2332,6 +2386,7 @@ class RowIndex(tk.Canvas):
|
|
2332
2386
|
event_data = event_dict(
|
2333
2387
|
name="end_edit_index",
|
2334
2388
|
sheet=self.PAR.name,
|
2389
|
+
widget=self,
|
2335
2390
|
cells_index={datarn: pre_edit_value},
|
2336
2391
|
key="??",
|
2337
2392
|
value=value,
|
@@ -2385,7 +2440,7 @@ class RowIndex(tk.Canvas):
|
|
2385
2440
|
|
2386
2441
|
def get_treeview_indent(self, iid: str) -> int:
|
2387
2442
|
if isinstance(self.PAR.ops.treeview_indent, str):
|
2388
|
-
indent = self.MT.
|
2443
|
+
indent = self.MT.index_txt_width * int(self.PAR.ops.treeview_indent)
|
2389
2444
|
else:
|
2390
2445
|
indent = self.PAR.ops.treeview_indent
|
2391
2446
|
return indent * max(self.get_node_level(self.tree[iid]))
|