tksheet 7.4.5__py3-none-any.whl → 7.4.7__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/main_table.py CHANGED
@@ -11,7 +11,7 @@ from itertools import accumulate, chain, cycle, filterfalse, islice, repeat
11
11
  from math import ceil, floor
12
12
  from operator import itemgetter
13
13
  from tkinter import TclError
14
- from typing import Literal
14
+ from typing import Any, Literal
15
15
 
16
16
  from .colors import color_map
17
17
  from .column_headers import ColumnHeaders
@@ -101,7 +101,7 @@ from .other_classes import (
101
101
  from .row_index import RowIndex
102
102
  from .sorting import sort_selection
103
103
  from .text_editor import TextEditor
104
- from .tksheet_types import AnyIter
104
+ from .tksheet_types import AnyIter, Binding
105
105
 
106
106
 
107
107
  class MainTable(tk.Canvas):
@@ -359,10 +359,10 @@ class MainTable(tk.Canvas):
359
359
  else:
360
360
  super().event_generate(*args, **kwargs)
361
361
 
362
- def refresh(self, event: object = None) -> None:
362
+ def refresh(self, event: Any = None) -> None:
363
363
  self.PAR.set_refresh_timer()
364
364
 
365
- def window_configured(self, event: object) -> None:
365
+ def window_configured(self, event: Any) -> None:
366
366
  w = self.PAR.winfo_width()
367
367
  if w != self.PAR_width:
368
368
  self.PAR_width = w
@@ -555,16 +555,31 @@ class MainTable(tk.Canvas):
555
555
  return coords
556
556
 
557
557
  def find_match(self, find: str, r: int, c: int) -> bool:
558
- return (
559
- not find
560
- and (not self.get_valid_cell_data_as_str(r, c, True).lower() or not f"{self.get_cell_data(r, c)}".lower())
561
- ) or (
562
- find
563
- and (
564
- find in self.get_valid_cell_data_as_str(r, c, True).lower()
565
- or find in f"{self.get_cell_data(r, c)}".lower()
566
- )
567
- )
558
+ try:
559
+ value = self.data[r][c]
560
+ except Exception:
561
+ value = ""
562
+ kwargs = self.get_cell_kwargs(r, c, key=None)
563
+ if kwargs:
564
+ if "dropdown" in kwargs:
565
+ kwargs = kwargs["dropdown"]
566
+ if kwargs["text"] is not None and find in str(kwargs["text"]).lower():
567
+ return True
568
+ elif "checkbox" in kwargs:
569
+ kwargs = kwargs["checkbox"]
570
+ if find in str(kwargs["text"]).lower() or (not find and find in "False"):
571
+ return True
572
+ elif "format" in kwargs:
573
+ if kwargs["formatter"] is None:
574
+ if find in data_to_str(value, **kwargs).lower():
575
+ return True
576
+ # assumed given formatter class has __str__() or value attribute
577
+ elif find in str(value).lower() or find in str(value.value).lower():
578
+ return True
579
+ if value is None:
580
+ return find == ""
581
+ else:
582
+ return find in str(value).lower()
568
583
 
569
584
  def find_within_match(self, find: str, r: int, c: int) -> bool:
570
585
  if not self.all_rows_displayed:
@@ -669,9 +684,9 @@ class MainTable(tk.Canvas):
669
684
  reverse=reverse,
670
685
  )
671
686
  if (
672
- (self.all_rows_displayed or bisect_in(self.displayed_rows, r))
687
+ self.find_match(find, r, c)
688
+ and (self.all_rows_displayed or bisect_in(self.displayed_rows, r))
673
689
  and (self.all_columns_displayed or bisect_in(self.displayed_columns, c))
674
- and self.find_match(find, r, c)
675
690
  )
676
691
  ),
677
692
  None,
@@ -974,7 +989,7 @@ class MainTable(tk.Canvas):
974
989
  self.refresh()
975
990
  return event_data
976
991
 
977
- def ctrl_v(self, event: object = None, validation: bool = True) -> None | EventDataDict:
992
+ def ctrl_v(self, event: Any = None, validation: bool = True) -> None | EventDataDict:
978
993
  if not self.PAR.ops.paste_can_expand_x and len(self.col_positions) == 1:
979
994
  return
980
995
  if not self.PAR.ops.paste_can_expand_y and len(self.row_positions) == 1:
@@ -1217,7 +1232,7 @@ class MainTable(tk.Canvas):
1217
1232
  self.PAR.emit_event("<<Paste>>", event_data)
1218
1233
  return event_data
1219
1234
 
1220
- def delete_key(self, event: object = None, validation: bool = True) -> None | EventDataDict:
1235
+ def delete_key(self, event: Any = None, validation: bool = True) -> None | EventDataDict:
1221
1236
  if not self.selected:
1222
1237
  return
1223
1238
  event_data = self.new_event_dict("edit_table")
@@ -1251,7 +1266,7 @@ class MainTable(tk.Canvas):
1251
1266
  self.PAR.emit_event("<<Delete>>", event_data)
1252
1267
  return event_data
1253
1268
 
1254
- def event_data_set_cell(self, datarn: int, datacn: int, value: object, event_data: dict) -> EventDataDict:
1269
+ def event_data_set_cell(self, datarn: int, datacn: int, value: Any, event_data: dict) -> EventDataDict:
1255
1270
  if self.input_valid_for_cell(datarn, datacn, value):
1256
1271
  event_data["cells"]["table"][(datarn, datacn)] = self.get_cell_data(datarn, datacn)
1257
1272
  self.set_cell_data(datarn, datacn, value)
@@ -1780,7 +1795,7 @@ class MainTable(tk.Canvas):
1780
1795
  )
1781
1796
  )
1782
1797
 
1783
- def undo(self, event: object = None) -> None | EventDataDict:
1798
+ def undo(self, event: Any = None) -> None | EventDataDict:
1784
1799
  if not self.undo_stack:
1785
1800
  return
1786
1801
  modification = self.undo_stack[-1]["data"]
@@ -1794,7 +1809,7 @@ class MainTable(tk.Canvas):
1794
1809
  self.PAR.emit_event("<<Undo>>", event_data)
1795
1810
  return event_data
1796
1811
 
1797
- def redo(self, event: object = None) -> None | EventDataDict:
1812
+ def redo(self, event: Any = None) -> None | EventDataDict:
1798
1813
  if not self.redo_stack:
1799
1814
  return
1800
1815
  modification = self.redo_stack[-1]["data"]
@@ -2039,8 +2054,10 @@ class MainTable(tk.Canvas):
2039
2054
  redraw: bool = True,
2040
2055
  r_pc: float = 0.0,
2041
2056
  c_pc: float = 0.0,
2057
+ index: bool = True,
2042
2058
  ) -> bool:
2043
- need_redraw = False
2059
+ need_y_redraw = False
2060
+ need_x_redraw = False
2044
2061
  vis_info = self.cell_visibility_info(r, c)
2045
2062
  yvis, xvis = vis_info["yvis"], vis_info["xvis"]
2046
2063
  top_left_x, top_left_y, bottom_right_x, bottom_right_y = vis_info["visible_region"]
@@ -2067,7 +2084,7 @@ class MainTable(tk.Canvas):
2067
2084
  y - 1 if y > 1 else y,
2068
2085
  ]
2069
2086
  self.set_yviews(*args, redraw=False)
2070
- need_redraw = True
2087
+ need_y_redraw = True
2071
2088
  else:
2072
2089
  if r is not None and not keep_yscroll:
2073
2090
  y = max(
@@ -2079,7 +2096,7 @@ class MainTable(tk.Canvas):
2079
2096
  y - 1 if y > 1 else y,
2080
2097
  ]
2081
2098
  self.set_yviews(*args, redraw=False)
2082
- need_redraw = True
2099
+ need_y_redraw = True
2083
2100
  # x scroll
2084
2101
  if not check_cell_visibility or (check_cell_visibility and not xvis) and len(self.col_positions) > 1:
2085
2102
  if bottom_right_corner is None:
@@ -2102,7 +2119,7 @@ class MainTable(tk.Canvas):
2102
2119
  x - 1 if x > 1 else x,
2103
2120
  ]
2104
2121
  self.set_xviews(*args, redraw=False)
2105
- need_redraw = True
2122
+ need_x_redraw = True
2106
2123
  else:
2107
2124
  if c is not None and not keep_xscroll:
2108
2125
  x = max(
@@ -2114,8 +2131,22 @@ class MainTable(tk.Canvas):
2114
2131
  x - 1 if x > 1 else x,
2115
2132
  ]
2116
2133
  self.set_xviews(*args, redraw=False)
2117
- need_redraw = True
2118
- if redraw and need_redraw:
2134
+ need_x_redraw = True
2135
+ # the index may have resized after scrolling making x calculation wrong
2136
+ if need_x_redraw and index and self.PAR.ops.auto_resize_row_index and self.show_index:
2137
+ self.main_table_redraw_grid_and_text(redraw_header=False, redraw_row_index=False, redraw_table=False)
2138
+ self.see(
2139
+ r=r,
2140
+ c=c,
2141
+ keep_yscroll=keep_yscroll,
2142
+ keep_xscroll=keep_xscroll,
2143
+ check_cell_visibility=check_cell_visibility,
2144
+ redraw=redraw,
2145
+ r_pc=r_pc,
2146
+ c_pc=c_pc,
2147
+ index=False,
2148
+ )
2149
+ if redraw and (need_y_redraw or need_x_redraw):
2119
2150
  self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
2120
2151
  return True
2121
2152
  return False
@@ -2175,7 +2206,7 @@ class MainTable(tk.Canvas):
2175
2206
  self.PAR.emit_event("<<SheetSelect>>", data=event_data)
2176
2207
  self.PAR.emit_event("<<SelectAll>>", data=event_data)
2177
2208
 
2178
- def select_columns(self, event: object) -> None:
2209
+ def select_columns(self, event: Any) -> None:
2179
2210
  if not self.selected:
2180
2211
  return
2181
2212
  r1, c1, r2, c2 = self.selection_boxes[self.selected.fill_iid].coords
@@ -2186,7 +2217,7 @@ class MainTable(tk.Canvas):
2186
2217
  item=self.CH.select_col(range(c1, c2), redraw=True),
2187
2218
  )
2188
2219
 
2189
- def select_rows(self, event: object) -> None:
2220
+ def select_rows(self, event: Any) -> None:
2190
2221
  if not self.selected:
2191
2222
  return
2192
2223
  r1, c1, r2, c2 = self.selection_boxes[self.selected.fill_iid].coords
@@ -2197,12 +2228,12 @@ class MainTable(tk.Canvas):
2197
2228
  item=self.RI.select_row(range(r1, r2), redraw=True),
2198
2229
  )
2199
2230
 
2200
- def select_row_start(self, event: object) -> None:
2231
+ def select_row_start(self, event: Any) -> None:
2201
2232
  if self.selected:
2202
2233
  self.see(self.selected.row, 0)
2203
2234
  self.select_cell(self.selected.row, 0, redraw=True)
2204
2235
 
2205
- def select_a1(self, event: object) -> None:
2236
+ def select_a1(self, event: Any) -> None:
2206
2237
  if len(self.row_positions) > 1 and len(self.col_positions) > 1:
2207
2238
  self.see(0, 0)
2208
2239
  self.select_cell(0, 0, redraw=True)
@@ -2462,7 +2493,7 @@ class MainTable(tk.Canvas):
2462
2493
  if redraw:
2463
2494
  self.refresh()
2464
2495
 
2465
- def page_UP(self, event: object = None) -> None:
2496
+ def page_UP(self, event: Any = None) -> None:
2466
2497
  height = self.winfo_height()
2467
2498
  top = self.canvasy(0)
2468
2499
  scrollto_y = max(0, top - height)
@@ -2487,7 +2518,7 @@ class MainTable(tk.Canvas):
2487
2518
  self.RI.yview(*args)
2488
2519
  self.main_table_redraw_grid_and_text(redraw_row_index=True)
2489
2520
 
2490
- def page_DOWN(self, event: object = None) -> None:
2521
+ def page_DOWN(self, event: Any = None) -> None:
2491
2522
  height = self.winfo_height()
2492
2523
  top = self.canvasy(0)
2493
2524
  scrollto = top + height
@@ -2517,7 +2548,7 @@ class MainTable(tk.Canvas):
2517
2548
  self.RI.yview(*args)
2518
2549
  self.main_table_redraw_grid_and_text(redraw_row_index=True)
2519
2550
 
2520
- def arrowkey_UP(self, event: object = None) -> None:
2551
+ def arrowkey_UP(self, event: Any = None) -> None:
2521
2552
  if not self.selected:
2522
2553
  return
2523
2554
  r = self.selected.row
@@ -2534,7 +2565,7 @@ class MainTable(tk.Canvas):
2534
2565
  ):
2535
2566
  self.select_cell(r - 1, c, redraw=True)
2536
2567
 
2537
- def arrowkey_LEFT(self, event: object = None) -> None:
2568
+ def arrowkey_LEFT(self, event: Any = None) -> Literal["break"]:
2538
2569
  if not self.selected:
2539
2570
  return
2540
2571
  r = self.selected.row
@@ -2543,13 +2574,16 @@ class MainTable(tk.Canvas):
2543
2574
  self.see(r, c)
2544
2575
  else:
2545
2576
  self.see(r, c - 1, redraw=False)
2546
- if self.selected.type_ == "columns":
2577
+ if self.selected.type_ == "columns" and self.CH.col_selection_enabled:
2547
2578
  self.CH.select_col(c - 1, redraw=True)
2548
2579
 
2549
- elif self.selected.type_ in ("cells", "rows"):
2580
+ elif self.selected.type_ in ("cells", "rows") and (
2581
+ self.single_selection_enabled or self.toggle_selection_enabled
2582
+ ):
2550
2583
  self.select_cell(r, c - 1, redraw=True)
2584
+ return "break"
2551
2585
 
2552
- def arrowkey_DOWN(self, event: object = None) -> None:
2586
+ def arrowkey_DOWN(self, event: Any = None) -> None:
2553
2587
  if not self.selected:
2554
2588
  return
2555
2589
  r = self.selected.row
@@ -2564,13 +2598,15 @@ class MainTable(tk.Canvas):
2564
2598
  bottom_right_corner=brc,
2565
2599
  redraw=False,
2566
2600
  )
2567
- if self.selected.type_ == "rows":
2601
+ if self.selected.type_ == "rows" and self.RI.row_selection_enabled:
2568
2602
  self.RI.select_row(r + 1, redraw=True)
2569
2603
 
2570
- elif self.selected.type_ in ("cells", "columns"):
2604
+ elif self.selected.type_ in ("cells", "columns") and (
2605
+ self.single_selection_enabled or self.toggle_selection_enabled
2606
+ ):
2571
2607
  self.select_cell(r + 1, c, redraw=True)
2572
2608
 
2573
- def arrowkey_RIGHT(self, event: object = None) -> None:
2609
+ def arrowkey_RIGHT(self, event: Any = None) -> None:
2574
2610
  if not self.selected:
2575
2611
  return
2576
2612
  r = self.selected.row
@@ -2585,10 +2621,12 @@ class MainTable(tk.Canvas):
2585
2621
  bottom_right_corner=brc,
2586
2622
  redraw=False,
2587
2623
  )
2588
- if self.selected.type_ == "columns":
2624
+ if self.selected.type_ == "columns" and self.CH.col_selection_enabled:
2589
2625
  self.CH.select_col(c + 1, redraw=True)
2590
2626
 
2591
- elif self.selected.type_ in ("cells", "rows"):
2627
+ elif self.selected.type_ in ("cells", "rows") and (
2628
+ self.single_selection_enabled or self.toggle_selection_enabled
2629
+ ):
2592
2630
  self.select_cell(r, c + 1, redraw=True)
2593
2631
 
2594
2632
  def shift_arrowkey_select_box(
@@ -2623,7 +2661,7 @@ class MainTable(tk.Canvas):
2623
2661
  self.see(see_r, see_c, keep_xscroll=keep_xscroll, keep_yscroll=keep_yscroll, redraw=False)
2624
2662
  self.refresh()
2625
2663
 
2626
- def shift_arrowkey_UP(self, event: object = None) -> None:
2664
+ def shift_arrowkey_UP(self, event: Any = None) -> None:
2627
2665
  if not self.selected:
2628
2666
  return
2629
2667
  r1, c1, r2, c2 = self.selected.box
@@ -2640,7 +2678,7 @@ class MainTable(tk.Canvas):
2640
2678
  see_r = r1
2641
2679
  self.shift_arrowkey_select_box(r1, c1, r2, c2, current_r, current_c, see_r, c1, keep_xscroll=True)
2642
2680
 
2643
- def shift_arrowkey_DOWN(self, event: object = None) -> None:
2681
+ def shift_arrowkey_DOWN(self, event: Any = None) -> None:
2644
2682
  if not self.selected:
2645
2683
  return
2646
2684
  r1, c1, r2, c2 = self.selected.box
@@ -2655,7 +2693,7 @@ class MainTable(tk.Canvas):
2655
2693
  see_r = r1
2656
2694
  self.shift_arrowkey_select_box(r1, c1, r2, c2, current_r, current_c, see_r, c1, keep_xscroll=True)
2657
2695
 
2658
- def shift_arrowkey_LEFT(self, event: object = None) -> None:
2696
+ def shift_arrowkey_LEFT(self, event: Any = None) -> None:
2659
2697
  if not self.selected:
2660
2698
  return
2661
2699
  r1, c1, r2, c2 = self.selected.box
@@ -2672,7 +2710,7 @@ class MainTable(tk.Canvas):
2672
2710
  see_c = c1
2673
2711
  self.shift_arrowkey_select_box(r1, c1, r2, c2, current_r, current_c, r1, see_c, keep_yscroll=True)
2674
2712
 
2675
- def shift_arrowkey_RIGHT(self, event: object = None) -> None:
2713
+ def shift_arrowkey_RIGHT(self, event: Any = None) -> None:
2676
2714
  if not self.selected:
2677
2715
  return
2678
2716
  r1, c1, r2, c2 = self.selected.box
@@ -3011,7 +3049,7 @@ class MainTable(tk.Canvas):
3011
3049
  **mnkwgs,
3012
3050
  )
3013
3051
 
3014
- def enable_bindings(self, bindings: object) -> None:
3052
+ def enable_bindings(self, bindings: Any) -> None:
3015
3053
  if not bindings:
3016
3054
  self._enable_binding("all")
3017
3055
  elif isinstance(bindings, (list, tuple)):
@@ -3025,7 +3063,7 @@ class MainTable(tk.Canvas):
3025
3063
  self._enable_binding(bindings.lower())
3026
3064
  self.create_rc_menus()
3027
3065
 
3028
- def disable_bindings(self, bindings: object) -> None:
3066
+ def disable_bindings(self, bindings: Any) -> None:
3029
3067
  if not bindings:
3030
3068
  self._disable_binding("all")
3031
3069
  elif isinstance(bindings, (list, tuple)):
@@ -3039,7 +3077,7 @@ class MainTable(tk.Canvas):
3039
3077
  self._disable_binding(bindings)
3040
3078
  self.create_rc_menus()
3041
3079
 
3042
- def _enable_binding(self, binding: str) -> None:
3080
+ def _enable_binding(self, binding: Binding) -> None:
3043
3081
  if binding == "enable_all":
3044
3082
  binding = "all"
3045
3083
  if binding in (
@@ -3184,7 +3222,7 @@ class MainTable(tk.Canvas):
3184
3222
  for binding in self.PAR.ops[bindings_key]:
3185
3223
  widget.bind(binding, func)
3186
3224
 
3187
- def _disable_binding(self, binding: str) -> None:
3225
+ def _disable_binding(self, binding: Binding) -> None:
3188
3226
  if binding == "disable_all":
3189
3227
  binding = "all"
3190
3228
  if binding in (
@@ -3323,14 +3361,14 @@ class MainTable(tk.Canvas):
3323
3361
  self.CH.rsz_w = None
3324
3362
  self.CH.rsz_h = None
3325
3363
 
3326
- def mouse_motion(self, event: object):
3364
+ def mouse_motion(self, event: Any) -> None:
3327
3365
  self.reset_mouse_motion_creations()
3328
3366
  try_binding(self.extra_motion_func, event)
3329
3367
 
3330
3368
  def not_currently_resizing(self) -> bool:
3331
3369
  return all(v is None for v in (self.RI.rsz_h, self.RI.rsz_w, self.CH.rsz_h, self.CH.rsz_w))
3332
3370
 
3333
- def rc(self, event=None):
3371
+ def rc(self, event: Any = None) -> None:
3334
3372
  self.mouseclick_outside_editor_or_dropdown_all_canvases()
3335
3373
  self.focus_set()
3336
3374
  popup_menu = None
@@ -3363,7 +3401,7 @@ class MainTable(tk.Canvas):
3363
3401
  if popup_menu:
3364
3402
  popup_menu.tk_popup(event.x_root, event.y_root)
3365
3403
 
3366
- def b1_press(self, event=None):
3404
+ def b1_press(self, event: Any = None) -> None:
3367
3405
  self.closed_dropdown = self.mouseclick_outside_editor_or_dropdown_all_canvases()
3368
3406
  self.focus_set()
3369
3407
  if (
@@ -3385,7 +3423,9 @@ class MainTable(tk.Canvas):
3385
3423
  self.b1_pressed_loc = (r, c)
3386
3424
  try_binding(self.extra_b1_press_func, event)
3387
3425
 
3388
- def create_resize_line(self, x1, y1, x2, y2, width, fill, tag):
3426
+ def create_resize_line(
3427
+ self, x1: int, y1: int, x2: int, y2: int, width: int, fill: str, tag: str | tuple[str]
3428
+ ) -> None:
3389
3429
  if self.hidd_resize_lines:
3390
3430
  t, sh = self.hidd_resize_lines.popitem()
3391
3431
  self.coords(t, x1, y1, x2, y2)
@@ -3398,7 +3438,7 @@ class MainTable(tk.Canvas):
3398
3438
  t = self.create_line(x1, y1, x2, y2, width=width, fill=fill, tags=tag)
3399
3439
  self.disp_resize_lines[t] = True
3400
3440
 
3401
- def delete_resize_lines(self):
3441
+ def delete_resize_lines(self) -> None:
3402
3442
  self.hidd_resize_lines.update(self.disp_resize_lines)
3403
3443
  self.disp_resize_lines = {}
3404
3444
  for t, sh in self.hidd_resize_lines.items():
@@ -3406,7 +3446,7 @@ class MainTable(tk.Canvas):
3406
3446
  self.itemconfig(t, state="hidden")
3407
3447
  self.hidd_resize_lines[t] = False
3408
3448
 
3409
- def ctrl_b1_press(self, event=None):
3449
+ def ctrl_b1_press(self, event: Any = None) -> None:
3410
3450
  self.mouseclick_outside_editor_or_dropdown_all_canvases()
3411
3451
  self.focus_set()
3412
3452
  self.ctrl_b1_pressed = True
@@ -3424,7 +3464,7 @@ class MainTable(tk.Canvas):
3424
3464
  elif not self.ctrl_select_enabled:
3425
3465
  self.b1_press(event)
3426
3466
 
3427
- def ctrl_shift_b1_press(self, event=None):
3467
+ def ctrl_shift_b1_press(self, event: Any = None) -> None:
3428
3468
  self.mouseclick_outside_editor_or_dropdown_all_canvases()
3429
3469
  self.focus_set()
3430
3470
  self.ctrl_b1_pressed = True
@@ -3452,7 +3492,7 @@ class MainTable(tk.Canvas):
3452
3492
  elif not self.ctrl_select_enabled:
3453
3493
  self.shift_b1_press(event)
3454
3494
 
3455
- def shift_b1_press(self, event=None):
3495
+ def shift_b1_press(self, event: Any = None) -> None:
3456
3496
  self.mouseclick_outside_editor_or_dropdown_all_canvases()
3457
3497
  self.focus_set()
3458
3498
  if self.drag_selection_enabled and self.not_currently_resizing():
@@ -3479,7 +3519,7 @@ class MainTable(tk.Canvas):
3479
3519
  try_binding(self.shift_selection_binding_func, sel_event)
3480
3520
  self.PAR.emit_event("<<SheetSelect>>", data=sel_event)
3481
3521
 
3482
- def get_shift_select_box(self, min_r: int, rowsel: int, min_c: int, colsel: int):
3522
+ def get_shift_select_box(self, min_r: int, rowsel: int, min_c: int, colsel: int) -> tuple[int, int, int, int]:
3483
3523
  if rowsel >= min_r and colsel >= min_c:
3484
3524
  return min_r, min_c, rowsel + 1, colsel + 1
3485
3525
  elif rowsel >= min_r and min_c >= colsel:
@@ -3489,7 +3529,13 @@ class MainTable(tk.Canvas):
3489
3529
  elif min_r >= rowsel and min_c >= colsel:
3490
3530
  return rowsel, colsel, min_r + 1, min_c + 1
3491
3531
 
3492
- def get_b1_motion_box(self, start_row: int, start_col: int, end_row: int, end_col: int):
3532
+ def get_b1_motion_box(
3533
+ self,
3534
+ start_row: int,
3535
+ start_col: int,
3536
+ end_row: int,
3537
+ end_col: int,
3538
+ ) -> tuple[int, int, int, int, Literal["cells"]]:
3493
3539
  if end_row >= start_row and end_col >= start_col and (end_row - start_row or end_col - start_col):
3494
3540
  return start_row, start_col, end_row + 1, end_col + 1, "cells"
3495
3541
  elif end_row >= start_row and end_col < start_col and (end_row - start_row or start_col - end_col):
@@ -3501,7 +3547,7 @@ class MainTable(tk.Canvas):
3501
3547
  else:
3502
3548
  return start_row, start_col, start_row + 1, start_col + 1, "cells"
3503
3549
 
3504
- def b1_motion(self, event: object):
3550
+ def b1_motion(self, event: Any) -> None:
3505
3551
  if self.drag_selection_enabled and all(
3506
3552
  v is None
3507
3553
  for v in (
@@ -3549,7 +3595,7 @@ class MainTable(tk.Canvas):
3549
3595
  self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True, redraw_table=True)
3550
3596
  try_binding(self.extra_b1_motion_func, event)
3551
3597
 
3552
- def ctrl_b1_motion(self, event: object):
3598
+ def ctrl_b1_motion(self, event: Any) -> None:
3553
3599
  if self.ctrl_select_enabled and self.drag_selection_enabled and self.not_currently_resizing():
3554
3600
  need_redraw = False
3555
3601
  end_row = self.identify_row(y=event.y)
@@ -3592,7 +3638,7 @@ class MainTable(tk.Canvas):
3592
3638
  elif not self.ctrl_select_enabled:
3593
3639
  self.b1_motion(event)
3594
3640
 
3595
- def b1_release(self, event=None):
3641
+ def b1_release(self, event: Any = None) -> None:
3596
3642
  to_hide = self.being_drawn_item
3597
3643
  if self.being_drawn_item is not None and (to_sel := self.coords_and_type(self.being_drawn_item)):
3598
3644
  r_to_sel, c_to_sel = self.selected.row, self.selected.column
@@ -3642,7 +3688,7 @@ class MainTable(tk.Canvas):
3642
3688
  self.closed_dropdown = None
3643
3689
  try_binding(self.extra_b1_release_func, event)
3644
3690
 
3645
- def double_b1(self, event=None):
3691
+ def double_b1(self, event: Any = None) -> None:
3646
3692
  self.mouseclick_outside_editor_or_dropdown_all_canvases()
3647
3693
  self.focus_set()
3648
3694
  if (
@@ -3666,7 +3712,7 @@ class MainTable(tk.Canvas):
3666
3712
  self.open_cell(event)
3667
3713
  try_binding(self.extra_double_b1_func, event)
3668
3714
 
3669
- def identify_row(self, event=None, y=None, allow_end=True):
3715
+ def identify_row(self, event: Any = None, y: int | None = None, allow_end: bool = True) -> int | None:
3670
3716
  if event is None:
3671
3717
  y2 = self.canvasy(y)
3672
3718
  elif y is None:
@@ -3678,7 +3724,7 @@ class MainTable(tk.Canvas):
3678
3724
  return None
3679
3725
  return r
3680
3726
 
3681
- def identify_col(self, event=None, x=None, allow_end=True):
3727
+ def identify_col(self, event: Any = None, x: int | None = None, allow_end: bool = True) -> int | None:
3682
3728
  if event is None:
3683
3729
  x2 = self.canvasx(x)
3684
3730
  elif x is None:
@@ -3710,7 +3756,7 @@ class MainTable(tk.Canvas):
3710
3756
  if self.show_index:
3711
3757
  self.RI.yview("moveto", 1)
3712
3758
 
3713
- def scroll_if_event_offscreen(self, event: object) -> bool:
3759
+ def scroll_if_event_offscreen(self, event: Any) -> bool:
3714
3760
  need_redraw = False
3715
3761
  if self.data:
3716
3762
  xcheck = self.xview()
@@ -3749,7 +3795,7 @@ class MainTable(tk.Canvas):
3749
3795
  self.y_move_synced_scrolls("moveto", self.yview()[0])
3750
3796
  return need_redraw
3751
3797
 
3752
- def x_move_synced_scrolls(self, *args, redraw: bool = True, use_scrollbar: bool = False):
3798
+ def x_move_synced_scrolls(self, *args: Any, redraw: bool = True, use_scrollbar: bool = False) -> None:
3753
3799
  for widget in self.synced_scrolls:
3754
3800
  # try:
3755
3801
  if hasattr(widget, "MT"):
@@ -3762,7 +3808,7 @@ class MainTable(tk.Canvas):
3762
3808
  # except Exception:
3763
3809
  # continue
3764
3810
 
3765
- def y_move_synced_scrolls(self, *args, redraw: bool = True, use_scrollbar: bool = False):
3811
+ def y_move_synced_scrolls(self, *args: Any, redraw: bool = True, use_scrollbar: bool = False) -> None:
3766
3812
  for widget in self.synced_scrolls:
3767
3813
  # try:
3768
3814
  if hasattr(widget, "MT"):
@@ -3775,7 +3821,7 @@ class MainTable(tk.Canvas):
3775
3821
  # except Exception:
3776
3822
  # continue
3777
3823
 
3778
- def _xscrollbar(self, *args, move_synced: bool = True):
3824
+ def _xscrollbar(self, *args: Any, move_synced: bool = True) -> None:
3779
3825
  self.xview(*args)
3780
3826
  if self.show_header:
3781
3827
  self.CH.xview(*args)
@@ -3783,7 +3829,7 @@ class MainTable(tk.Canvas):
3783
3829
  if move_synced:
3784
3830
  self.x_move_synced_scrolls(*args, use_scrollbar=True)
3785
3831
 
3786
- def _yscrollbar(self, *args, move_synced: bool = True):
3832
+ def _yscrollbar(self, *args: Any, move_synced: bool = True) -> None:
3787
3833
  self.yview(*args)
3788
3834
  if self.show_index:
3789
3835
  self.RI.yview(*args)
@@ -3793,7 +3839,7 @@ class MainTable(tk.Canvas):
3793
3839
 
3794
3840
  def set_xviews(
3795
3841
  self,
3796
- *args,
3842
+ *args: Any,
3797
3843
  move_synced: bool = True,
3798
3844
  redraw: bool = True,
3799
3845
  ) -> None:
@@ -3813,7 +3859,7 @@ class MainTable(tk.Canvas):
3813
3859
 
3814
3860
  def set_yviews(
3815
3861
  self,
3816
- *args,
3862
+ *args: Any,
3817
3863
  move_synced: bool = True,
3818
3864
  redraw: bool = True,
3819
3865
  ) -> None:
@@ -3835,7 +3881,7 @@ class MainTable(tk.Canvas):
3835
3881
  self.set_xviews(*x_args)
3836
3882
  self.set_yviews(*y_args)
3837
3883
 
3838
- def mousewheel(self, event: object) -> None:
3884
+ def mousewheel(self, event: Any) -> None:
3839
3885
  if event.delta < 0 or event.num == 5:
3840
3886
  self.yview_scroll(1, "units")
3841
3887
  self.RI.yview_scroll(1, "units")
@@ -3848,7 +3894,7 @@ class MainTable(tk.Canvas):
3848
3894
  self.y_move_synced_scrolls("moveto", self.yview()[0])
3849
3895
  self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
3850
3896
 
3851
- def shift_mousewheel(self, event: object) -> None:
3897
+ def shift_mousewheel(self, event: Any) -> None:
3852
3898
  if event.delta < 0 or event.num == 5:
3853
3899
  self.xview_scroll(1, "units")
3854
3900
  self.CH.xview_scroll(1, "units")
@@ -3861,13 +3907,13 @@ class MainTable(tk.Canvas):
3861
3907
  self.x_move_synced_scrolls("moveto", self.xview()[0])
3862
3908
  self.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
3863
3909
 
3864
- def ctrl_mousewheel(self, event):
3910
+ def ctrl_mousewheel(self, event: Any) -> None:
3865
3911
  if event.delta < 0 or event.num == 5:
3866
3912
  self.zoom_out()
3867
3913
  elif event.delta >= 0 or event.num == 4:
3868
3914
  self.zoom_in()
3869
3915
 
3870
- def zoom_in(self, event=None):
3916
+ def zoom_in(self, event: Any = None) -> None:
3871
3917
  self.zoom_font(
3872
3918
  (self.PAR.ops.table_font[0], self.PAR.ops.table_font[1] + 1, self.PAR.ops.table_font[2]),
3873
3919
  (self.PAR.ops.index_font[0], self.PAR.ops.index_font[1] + 1, self.PAR.ops.index_font[2]),
@@ -3875,7 +3921,7 @@ class MainTable(tk.Canvas):
3875
3921
  "in",
3876
3922
  )
3877
3923
 
3878
- def zoom_out(self, event=None):
3924
+ def zoom_out(self, event: Any = None) -> None:
3879
3925
  if self.PAR.ops.table_font[1] < 2 or self.PAR.ops.index_font[1] < 2 or self.PAR.ops.header_font[1] < 2:
3880
3926
  return
3881
3927
  self.zoom_font(
@@ -3885,7 +3931,13 @@ class MainTable(tk.Canvas):
3885
3931
  "out",
3886
3932
  )
3887
3933
 
3888
- def zoom_font(self, table_font: tuple, index_font: tuple, header_font: tuple, zoom: Literal["in", "out"]) -> None:
3934
+ def zoom_font(
3935
+ self,
3936
+ table_font: FontTuple,
3937
+ index_font: FontTuple,
3938
+ header_font: FontTuple,
3939
+ zoom: Literal["in", "out"],
3940
+ ) -> None:
3889
3941
  self.saved_column_widths = {}
3890
3942
  self.saved_row_heights = {}
3891
3943
  # should record position prior to change and then see after change
@@ -4040,7 +4092,7 @@ class MainTable(tk.Canvas):
4040
4092
  self.recreate_all_selection_boxes()
4041
4093
  return self.PAR.ops.index_font
4042
4094
 
4043
- def set_index_font_help(self):
4095
+ def set_index_font_help(self) -> None:
4044
4096
  self.RI.index_font = self.PAR.ops.index_font
4045
4097
  if self.PAR.ops.index_font not in self.char_widths:
4046
4098
  self.char_widths[self.PAR.ops.index_font] = {}
@@ -4080,7 +4132,7 @@ class MainTable(tk.Canvas):
4080
4132
  self.recreate_all_selection_boxes()
4081
4133
  return self.PAR.ops.header_font
4082
4134
 
4083
- def set_header_font_help(self):
4135
+ def set_header_font_help(self) -> None:
4084
4136
  self.CH.header_font = self.PAR.ops.header_font
4085
4137
  if self.PAR.ops.header_font not in self.char_widths:
4086
4138
  self.char_widths[self.PAR.ops.header_font] = {}
@@ -4094,11 +4146,11 @@ class MainTable(tk.Canvas):
4094
4146
  self.PAR.ops.default_header_height = int(self.min_header_height)
4095
4147
  self.CH.set_height(self.get_default_header_height(), set_TL=True)
4096
4148
 
4097
- def purge_undo_and_redo_stack(self):
4149
+ def purge_undo_and_redo_stack(self) -> None:
4098
4150
  self.undo_stack = deque(maxlen=self.PAR.ops.max_undos)
4099
4151
  self.redo_stack = deque(maxlen=self.PAR.ops.max_undos)
4100
4152
 
4101
- def purge_redo_stack(self):
4153
+ def purge_redo_stack(self) -> None:
4102
4154
  self.redo_stack = deque(maxlen=self.PAR.ops.max_undos)
4103
4155
 
4104
4156
  def data_reference(
@@ -4109,7 +4161,7 @@ class MainTable(tk.Canvas):
4109
4161
  redraw: bool = False,
4110
4162
  return_id: bool = True,
4111
4163
  keep_formatting: bool = True,
4112
- ) -> object:
4164
+ ) -> Any:
4113
4165
  if isinstance(newdataref, (list, tuple)):
4114
4166
  self.hide_dropdown_editor_all_canvases()
4115
4167
  self.data = newdataref
@@ -4129,7 +4181,7 @@ class MainTable(tk.Canvas):
4129
4181
  else:
4130
4182
  return self.data
4131
4183
 
4132
- def get_cell_dimensions(self, datarn, datacn):
4184
+ def get_cell_dimensions(self, datarn: int, datacn: int) -> tuple[int, int]:
4133
4185
  txt = self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True)
4134
4186
  if txt:
4135
4187
  self.txt_measure_canvas.itemconfig(self.txt_measure_canvas_text, text=txt, font=self.PAR.ops.table_font)
@@ -4143,7 +4195,9 @@ class MainTable(tk.Canvas):
4143
4195
  return w + self.table_txt_height, h
4144
4196
  return w, h
4145
4197
 
4146
- def set_cell_size_to_text(self, r, c, only_if_too_small=False, redraw: bool = True, run_binding=False):
4198
+ def set_cell_size_to_text(
4199
+ self, r: int, c: int, only_if_too_small: bool = False, redraw: bool = True, run_binding: bool = False
4200
+ ) -> bool:
4147
4201
  min_column_width = self.PAR.ops.min_column_width
4148
4202
  min_rh = self.min_row_height
4149
4203
  w = min_column_width
@@ -4214,6 +4268,7 @@ class MainTable(tk.Canvas):
4214
4268
  return True
4215
4269
  else:
4216
4270
  return False
4271
+ return False
4217
4272
 
4218
4273
  def get_cell_max_width(self, datarn: int, dispcn: int) -> int:
4219
4274
  datacn = self.datacn(dispcn)
@@ -4364,7 +4419,7 @@ class MainTable(tk.Canvas):
4364
4419
  else:
4365
4420
  self.set_row_positions(itr=repeat(height, len(self.displayed_rows)))
4366
4421
 
4367
- def del_col_position(self, idx: int, deselect_all: bool = False):
4422
+ def del_col_position(self, idx: int, deselect_all: bool = False) -> None:
4368
4423
  if deselect_all:
4369
4424
  self.deselect("all", redraw=False)
4370
4425
  if idx == "end" or len(self.col_positions) <= idx + 1:
@@ -4375,7 +4430,7 @@ class MainTable(tk.Canvas):
4375
4430
  del self.col_positions[idx]
4376
4431
  self.col_positions[idx:] = [e - w for e in islice(self.col_positions, idx, len(self.col_positions))]
4377
4432
 
4378
- def del_row_position(self, idx: int, deselect_all: bool = False):
4433
+ def del_row_position(self, idx: int, deselect_all: bool = False) -> None:
4379
4434
  if deselect_all:
4380
4435
  self.deselect("all", redraw=False)
4381
4436
  if idx == "end" or len(self.row_positions) <= idx + 1:
@@ -4386,7 +4441,7 @@ class MainTable(tk.Canvas):
4386
4441
  del self.row_positions[idx]
4387
4442
  self.row_positions[idx:] = [e - w for e in islice(self.row_positions, idx, len(self.row_positions))]
4388
4443
 
4389
- def del_col_positions(self, idxs: AnyIter[int] | None = None):
4444
+ def del_col_positions(self, idxs: AnyIter[int] | None = None) -> None:
4390
4445
  if idxs is None:
4391
4446
  del self.col_positions[-1]
4392
4447
  else:
@@ -4394,7 +4449,7 @@ class MainTable(tk.Canvas):
4394
4449
  idxs = set(idxs)
4395
4450
  self.set_col_positions(itr=(w for i, w in enumerate(self.gen_column_widths()) if i not in idxs))
4396
4451
 
4397
- def del_row_positions(self, idxs: AnyIter[int] | None = None):
4452
+ def del_row_positions(self, idxs: AnyIter[int] | None = None) -> None:
4398
4453
  if idxs is None:
4399
4454
  del self.row_positions[-1]
4400
4455
  else:
@@ -4617,9 +4672,9 @@ class MainTable(tk.Canvas):
4617
4672
 
4618
4673
  def adjust_options_post_delete_columns(
4619
4674
  self,
4620
- to_del: None | set = None,
4621
- to_bis: None | list = None,
4622
- named_spans: None | set = None,
4675
+ to_del: None | set[int] = None,
4676
+ to_bis: None | list[int] = None,
4677
+ named_spans: None | set[str] = None,
4623
4678
  ) -> list[int]:
4624
4679
  if to_del is None:
4625
4680
  to_del = set()
@@ -4675,7 +4730,7 @@ class MainTable(tk.Canvas):
4675
4730
 
4676
4731
  def del_columns_from_named_spans(
4677
4732
  self,
4678
- to_del: set,
4733
+ to_del: set[int],
4679
4734
  to_bis: list,
4680
4735
  named_spans: None | set = None,
4681
4736
  ) -> None:
@@ -4691,10 +4746,7 @@ class MainTable(tk.Canvas):
4691
4746
  if isinstance(span["upto_c"], int) and span["upto_c"] > c:
4692
4747
  span["upto_c"] -= 1
4693
4748
 
4694
- def get_spans_to_del_from_cols(
4695
- self,
4696
- cols: set,
4697
- ) -> set:
4749
+ def get_spans_to_del_from_cols(self, cols: set[int]) -> set[str]:
4698
4750
  total = self.total_data_cols()
4699
4751
  return {
4700
4752
  nm
@@ -4705,9 +4757,9 @@ class MainTable(tk.Canvas):
4705
4757
 
4706
4758
  def adjust_options_post_delete_rows(
4707
4759
  self,
4708
- to_del: None | set = None,
4709
- to_bis: None | list = None,
4710
- named_spans: None | set = None,
4760
+ to_del: None | set[int] = None,
4761
+ to_bis: None | list[int] = None,
4762
+ named_spans: None | set[str] = None,
4711
4763
  ) -> list[int]:
4712
4764
  if to_del is None:
4713
4765
  to_del = set()
@@ -4770,7 +4822,7 @@ class MainTable(tk.Canvas):
4770
4822
  self,
4771
4823
  to_del: set,
4772
4824
  to_bis: list,
4773
- named_spans: None | set = None,
4825
+ named_spans: None | set[str] = None,
4774
4826
  ) -> None:
4775
4827
  if named_spans is None:
4776
4828
  named_spans = self.get_spans_to_del_from_rows(rows=to_del)
@@ -4784,10 +4836,7 @@ class MainTable(tk.Canvas):
4784
4836
  if isinstance(span["upto_r"], int) and span["upto_r"] > r:
4785
4837
  span["upto_r"] -= 1
4786
4838
 
4787
- def get_spans_to_del_from_rows(
4788
- self,
4789
- rows: set,
4790
- ) -> set:
4839
+ def get_spans_to_del_from_rows(self, rows: set[int]) -> set[str]:
4791
4840
  total = self.total_data_rows()
4792
4841
  return {
4793
4842
  nm
@@ -4881,7 +4930,7 @@ class MainTable(tk.Canvas):
4881
4930
  try_binding(self.extra_end_insert_cols_rc_func, event_data, "end_add_columns")
4882
4931
  return event_data
4883
4932
 
4884
- def rc_add_columns(self, event: object = None) -> None:
4933
+ def rc_add_columns(self, event: Any = None) -> None:
4885
4934
  rowlen = self.equalize_data_row_lengths()
4886
4935
  selcols = sorted(self.get_selected_cols())
4887
4936
  if (
@@ -4930,8 +4979,8 @@ class MainTable(tk.Canvas):
4930
4979
 
4931
4980
  def add_rows(
4932
4981
  self,
4933
- rows: dict[int, list[object]],
4934
- index: dict[int, object],
4982
+ rows: dict[int, list[Any]],
4983
+ index: dict[int, Any],
4935
4984
  row_heights: dict[int, float | int],
4936
4985
  event_data: EventDataDict,
4937
4986
  create_ops: bool = True,
@@ -5015,7 +5064,7 @@ class MainTable(tk.Canvas):
5015
5064
  try_binding(self.extra_end_insert_rows_rc_func, event_data, "end_add_rows")
5016
5065
  return event_data
5017
5066
 
5018
- def rc_add_rows(self, event: object = None) -> None:
5067
+ def rc_add_rows(self, event: Any = None) -> None:
5019
5068
  total_data_rows = self.total_data_rows()
5020
5069
  selrows = sorted(self.get_selected_rows())
5021
5070
  if (
@@ -5067,7 +5116,7 @@ class MainTable(tk.Canvas):
5067
5116
  data_ins_col: int,
5068
5117
  displayed_ins_col: int,
5069
5118
  numcols: int,
5070
- columns: list[list[object]] | None = None,
5119
+ columns: list[list[Any]] | None = None,
5071
5120
  widths: list[int] | tuple[int] | None = None,
5072
5121
  headers: bool = False,
5073
5122
  ) -> tuple[dict, dict, dict]:
@@ -5111,7 +5160,7 @@ class MainTable(tk.Canvas):
5111
5160
  data_ins_row: int,
5112
5161
  displayed_ins_row: int,
5113
5162
  numrows: int,
5114
- rows: list[list[object]] | None = None,
5163
+ rows: list[list[Any]] | None = None,
5115
5164
  heights: list[int] | tuple[int] | None = None,
5116
5165
  row_index: bool = False,
5117
5166
  total_data_cols: int | None = None,
@@ -5235,7 +5284,7 @@ class MainTable(tk.Canvas):
5235
5284
 
5236
5285
  def delete_columns(
5237
5286
  self,
5238
- event: object = None,
5287
+ event: Any = None,
5239
5288
  columns: list[int] | None = None,
5240
5289
  data_indexes: bool = False,
5241
5290
  undo: bool = True,
@@ -5321,7 +5370,7 @@ class MainTable(tk.Canvas):
5321
5370
 
5322
5371
  def delete_rows(
5323
5372
  self,
5324
- event: object = None,
5373
+ event: Any = None,
5325
5374
  rows: list[int] | None = None,
5326
5375
  data_indexes: bool = False,
5327
5376
  undo: bool = True,
@@ -5459,12 +5508,12 @@ class MainTable(tk.Canvas):
5459
5508
 
5460
5509
  def headers(
5461
5510
  self,
5462
- newheaders: object = None,
5511
+ newheaders: Any = None,
5463
5512
  index: int | None = None,
5464
5513
  reset_col_positions: bool = False,
5465
5514
  show_headers_if_not_sheet: bool = True,
5466
5515
  redraw: bool = False,
5467
- ) -> object:
5516
+ ) -> Any:
5468
5517
  if newheaders is not None:
5469
5518
  if isinstance(newheaders, (list, tuple)):
5470
5519
  self._headers = list(newheaders) if isinstance(newheaders, tuple) else newheaders
@@ -5506,12 +5555,12 @@ class MainTable(tk.Canvas):
5506
5555
 
5507
5556
  def row_index(
5508
5557
  self,
5509
- newindex: object = None,
5558
+ newindex: Any = None,
5510
5559
  index: int | None = None,
5511
5560
  reset_row_positions: bool = False,
5512
5561
  show_index_if_not_sheet: bool = True,
5513
5562
  redraw: bool = False,
5514
- ) -> object:
5563
+ ) -> Any:
5515
5564
  if newindex is not None:
5516
5565
  if not self._row_index and not isinstance(self._row_index, int):
5517
5566
  self.RI.set_width(self.PAR.ops.default_row_index_width, set_TL=True)
@@ -5555,8 +5604,7 @@ class MainTable(tk.Canvas):
5555
5604
 
5556
5605
  def total_data_cols(self, include_header: bool = True) -> int:
5557
5606
  h_total = len(self._headers) if include_header and isinstance(self._headers, (list, tuple)) else 0
5558
- # map() for some reason is 15% faster than max(key=len) using python 3.11 windows 11
5559
- d_total = max(map(len, self.data), default=0)
5607
+ d_total = max(map(len, self.data), default=0) # max(map(len, )) is faster
5560
5608
  return max(h_total, d_total)
5561
5609
 
5562
5610
  def total_data_rows(self, include_index: bool = True) -> int:
@@ -6098,7 +6146,7 @@ class MainTable(tk.Canvas):
6098
6146
 
6099
6147
  # check if auto resizing row index
6100
6148
  changed_w = False
6101
- if self.PAR.ops.auto_resize_row_index and redraw_row_index and self.show_index:
6149
+ if self.PAR.ops.auto_resize_row_index and self.show_index:
6102
6150
  changed_w = self.RI.auto_set_index_width(
6103
6151
  end_row=grid_end_row,
6104
6152
  only_rows=map(self.datarn, range(text_start_row, text_end_row)),
@@ -7080,7 +7128,7 @@ class MainTable(tk.Canvas):
7080
7128
 
7081
7129
  def open_cell(
7082
7130
  self,
7083
- event: object = None,
7131
+ event: Any = None,
7084
7132
  ignore_existing_editor: bool = False,
7085
7133
  ) -> None:
7086
7134
  if not self.anything_selected() or (not ignore_existing_editor and self.text_editor.open):
@@ -7115,7 +7163,7 @@ class MainTable(tk.Canvas):
7115
7163
  # displayed indexes
7116
7164
  def open_text_editor(
7117
7165
  self,
7118
- event: object = None,
7166
+ event: Any = None,
7119
7167
  r: int = 0,
7120
7168
  c: int = 0,
7121
7169
  text: str | None = None,
@@ -7214,7 +7262,7 @@ class MainTable(tk.Canvas):
7214
7262
  # displayed indexes
7215
7263
  def text_editor_newline_binding(
7216
7264
  self,
7217
- event: object = None,
7265
+ event: Any = None,
7218
7266
  check_lines: bool = True,
7219
7267
  ) -> None:
7220
7268
  r, c = self.text_editor.coords
@@ -7413,7 +7461,7 @@ class MainTable(tk.Canvas):
7413
7461
  self.select_cell(r + 1 if r < len(self.row_positions) - 2 else r, c)
7414
7462
  self.see(r + 1 if r < len(self.row_positions) - 2 else r, c)
7415
7463
 
7416
- def tab_key(self, event: object = None) -> str:
7464
+ def tab_key(self, event: Any = None) -> str:
7417
7465
  if not self.selected:
7418
7466
  return
7419
7467
  r, c = self.selected.row, self.selected.column
@@ -7511,7 +7559,7 @@ class MainTable(tk.Canvas):
7511
7559
  self,
7512
7560
  r: int,
7513
7561
  c: int,
7514
- event: object = None,
7562
+ event: Any = None,
7515
7563
  ) -> None:
7516
7564
  self.hide_text_editor()
7517
7565
  datarn = self.datarn(r)
@@ -7592,7 +7640,7 @@ class MainTable(tk.Canvas):
7592
7640
  self,
7593
7641
  r: int | None = None,
7594
7642
  c: int | None = None,
7595
- selection: object = None,
7643
+ selection: Any = None,
7596
7644
  redraw: bool = True,
7597
7645
  ) -> None:
7598
7646
  if r is not None and c is not None and selection is not None:
@@ -7636,12 +7684,12 @@ class MainTable(tk.Canvas):
7636
7684
  self.focus_set()
7637
7685
  return closed_dd_coords
7638
7686
 
7639
- def mouseclick_outside_editor_or_dropdown_all_canvases(self):
7687
+ def mouseclick_outside_editor_or_dropdown_all_canvases(self) -> tuple[int, int] | None:
7640
7688
  self.CH.mouseclick_outside_editor_or_dropdown()
7641
7689
  self.RI.mouseclick_outside_editor_or_dropdown()
7642
7690
  return self.mouseclick_outside_editor_or_dropdown()
7643
7691
 
7644
- def hide_dropdown_editor_all_canvases(self):
7692
+ def hide_dropdown_editor_all_canvases(self) -> None:
7645
7693
  self.hide_text_editor_and_dropdown(redraw=False)
7646
7694
  self.RI.hide_text_editor_and_dropdown(redraw=False)
7647
7695
  self.CH.hide_text_editor_and_dropdown(redraw=False)
@@ -7737,7 +7785,7 @@ class MainTable(tk.Canvas):
7737
7785
  self,
7738
7786
  datarn: int,
7739
7787
  datacn: int,
7740
- value: object,
7788
+ value: Any,
7741
7789
  kwargs: dict | None = None,
7742
7790
  expand_sheet: bool = True,
7743
7791
  ) -> None:
@@ -7763,7 +7811,7 @@ class MainTable(tk.Canvas):
7763
7811
  else:
7764
7812
  self.data[datarn][datacn] = value
7765
7813
 
7766
- def get_value_for_empty_cell(self, datarn: int, datacn: int, r_ops: bool = True, c_ops: bool = True) -> object:
7814
+ def get_value_for_empty_cell(self, datarn: int, datacn: int, r_ops: bool = True, c_ops: bool = True) -> Any:
7767
7815
  kwargs = self.get_cell_kwargs(
7768
7816
  datarn,
7769
7817
  datacn,
@@ -7786,7 +7834,7 @@ class MainTable(tk.Canvas):
7786
7834
  start: int = 0,
7787
7835
  r_ops: bool = True,
7788
7836
  c_ops: bool = True,
7789
- ) -> list[object]:
7837
+ ) -> list[Any]:
7790
7838
  return [self.get_value_for_empty_cell(datarn, datacn, r_ops=r_ops, c_ops=c_ops) for datacn in range(start, end)]
7791
7839
 
7792
7840
  def fix_row_len(self, datarn: int, datacn: int) -> None:
@@ -7908,7 +7956,7 @@ class MainTable(tk.Canvas):
7908
7956
  none_to_empty_str: bool = False,
7909
7957
  fmt_kw: dict | None = None,
7910
7958
  **kwargs,
7911
- ) -> object:
7959
+ ) -> Any:
7912
7960
  if get_displayed:
7913
7961
  return self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True)
7914
7962
  value = (
@@ -7927,7 +7975,7 @@ class MainTable(tk.Canvas):
7927
7975
  self,
7928
7976
  datarn: int,
7929
7977
  datacn: int,
7930
- value: object,
7978
+ value: Any,
7931
7979
  check_readonly: bool = True,
7932
7980
  ignore_empty: bool = False,
7933
7981
  ) -> bool:
@@ -7945,7 +7993,7 @@ class MainTable(tk.Canvas):
7945
7993
  else:
7946
7994
  return True
7947
7995
 
7948
- def cell_equal_to(self, datarn: int, datacn: int, value: object, ignore_empty: bool = False, **kwargs) -> bool:
7996
+ def cell_equal_to(self, datarn: int, datacn: int, value: Any, ignore_empty: bool = False, **kwargs) -> bool:
7949
7997
  v = self.get_cell_data(datarn, datacn)
7950
7998
  kwargs = self.get_cell_kwargs(datarn, datacn, key="format")
7951
7999
  if kwargs and kwargs["formatter"] is None:
@@ -7983,16 +8031,30 @@ class MainTable(tk.Canvas):
7983
8031
  row: bool = True,
7984
8032
  column: bool = True,
7985
8033
  ) -> dict:
7986
- if cell and (datarn, datacn) in self.cell_options:
7987
- return (
7988
- self.cell_options[(datarn, datacn)] if key is None else self.cell_options[(datarn, datacn)].get(key, {})
7989
- )
7990
- elif row and datarn in self.row_options:
7991
- return self.row_options[datarn] if key is None else self.row_options[datarn].get(key, {})
7992
- elif column and datacn in self.col_options:
7993
- return self.col_options[datacn] if key is None else self.col_options[datacn].get(key, {})
8034
+ if key is None:
8035
+ if cell and (datarn, datacn) in self.cell_options:
8036
+ return self.cell_options[(datarn, datacn)]
8037
+
8038
+ elif row and datarn in self.row_options:
8039
+ return self.row_options[datarn]
8040
+
8041
+ elif column and datacn in self.col_options:
8042
+ return self.col_options[datacn]
8043
+
8044
+ else:
8045
+ return {}
7994
8046
  else:
7995
- return {}
8047
+ if cell and (datarn, datacn) in self.cell_options and key in self.cell_options[(datarn, datacn)]:
8048
+ return self.cell_options[(datarn, datacn)][key]
8049
+
8050
+ elif row and datarn in self.row_options and key in self.row_options[datarn]:
8051
+ return self.row_options[datarn][key]
8052
+
8053
+ elif column and datacn in self.col_options and key in self.col_options[datacn]:
8054
+ return self.col_options[datacn][key]
8055
+
8056
+ else:
8057
+ return {}
7996
8058
 
7997
8059
  def datacn(self, c: int) -> int:
7998
8060
  return c if self.all_columns_displayed else self.displayed_columns[c]