tksheet 7.4.4__py3-none-any.whl → 7.4.6__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/sheet.py CHANGED
@@ -4,11 +4,12 @@ import tkinter as tk
4
4
  from bisect import bisect_left
5
5
  from collections import deque
6
6
  from collections.abc import Callable, Generator, Hashable, Iterator, Sequence
7
+ from contextlib import suppress
7
8
  from itertools import accumulate, chain, filterfalse, islice, product, repeat
8
9
  from operator import attrgetter
9
10
  from timeit import default_timer
10
11
  from tkinter import ttk
11
- from typing import Literal
12
+ from typing import Any, Literal
12
13
 
13
14
  from .column_headers import ColumnHeaders
14
15
  from .constants import (
@@ -76,7 +77,7 @@ from .themes import (
76
77
  theme_light_blue,
77
78
  theme_light_green,
78
79
  )
79
- from .tksheet_types import AnyIter, CellPropertyKey, CreateSpanTypes
80
+ from .tksheet_types import AnyIter, Binding, CellPropertyKey, CreateSpanTypes, ExtraBinding
80
81
  from .top_left_rectangle import TopLeftRectangle
81
82
 
82
83
 
@@ -93,14 +94,14 @@ class Sheet(tk.Frame):
93
94
  show_y_scrollbar: bool = True,
94
95
  width: int | None = None,
95
96
  height: int | None = None,
96
- headers: None | list[object] = None,
97
- header: None | list[object] = None,
98
- row_index: None | list[object] = None,
99
- index: None | list[object] = None,
97
+ headers: None | list[Any] = None,
98
+ header: None | list[Any] = None,
99
+ row_index: None | list[Any] = None,
100
+ index: None | list[Any] = None,
100
101
  default_header: Literal["letters", "numbers", "both"] | None = "letters",
101
102
  default_row_index: Literal["letters", "numbers", "both"] | None = "numbers",
102
- data_reference: None | Sequence[Sequence[object]] = None,
103
- data: None | Sequence[Sequence[object]] = None,
103
+ data_reference: None | Sequence[Sequence[Any]] = None,
104
+ data: None | Sequence[Sequence[Any]] = None,
104
105
  # either (start row, end row, "rows"), (start column, end column, "rows") or
105
106
  # (cells start row, cells start column, cells end row, cells end column, "cells") # noqa: E501
106
107
  startup_select: tuple[int, int, str] | tuple[int, int, int, int, str] = None,
@@ -123,14 +124,14 @@ class Sheet(tk.Frame):
123
124
  header_align: str = "n",
124
125
  row_index_align: str | None = None,
125
126
  index_align: str = "n",
126
- displayed_columns: list[int] = [],
127
+ displayed_columns: list[int] | None = None,
127
128
  all_columns_displayed: bool = True,
128
- displayed_rows: list[int] = [],
129
+ displayed_rows: list[int] | None = None,
129
130
  all_rows_displayed: bool = True,
130
131
  to_clipboard_delimiter: str = "\t",
131
132
  to_clipboard_quotechar: str = '"',
132
133
  to_clipboard_lineterminator: str = "\n",
133
- from_clipboard_delimiters: list[str] | str = ["\t"],
134
+ from_clipboard_delimiters: list[str] | str = "\t",
134
135
  show_default_header_for_empty: bool = True,
135
136
  show_default_index_for_empty: bool = True,
136
137
  page_up_down_select_row: bool = True,
@@ -530,7 +531,7 @@ class Sheet(tk.Frame):
530
531
 
531
532
  def set_header_data(
532
533
  self,
533
- value: object,
534
+ value: Any,
534
535
  c: int | None | AnyIter[int] = None,
535
536
  redraw: bool = True,
536
537
  ) -> Sheet:
@@ -549,12 +550,12 @@ class Sheet(tk.Frame):
549
550
 
550
551
  def headers(
551
552
  self,
552
- newheaders: object = None,
553
+ newheaders: Any = None,
553
554
  index: None | int = None,
554
555
  reset_col_positions: bool = False,
555
556
  show_headers_if_not_sheet: bool = True,
556
557
  redraw: bool = True,
557
- ) -> object:
558
+ ) -> Any:
558
559
  self.set_refresh_timer(redraw)
559
560
  return self.MT.headers(
560
561
  newheaders,
@@ -566,7 +567,7 @@ class Sheet(tk.Frame):
566
567
 
567
568
  def set_index_data(
568
569
  self,
569
- value: object,
570
+ value: Any,
570
571
  r: int | None | AnyIter[int] = None,
571
572
  redraw: bool = True,
572
573
  ) -> Sheet:
@@ -585,12 +586,12 @@ class Sheet(tk.Frame):
585
586
 
586
587
  def row_index(
587
588
  self,
588
- newindex: object = None,
589
+ newindex: Any = None,
589
590
  index: None | int = None,
590
591
  reset_row_positions: bool = False,
591
592
  show_index_if_not_sheet: bool = True,
592
593
  redraw: bool = True,
593
- ) -> object:
594
+ ) -> Any:
594
595
  self.set_refresh_timer(redraw)
595
596
  return self.MT.row_index(
596
597
  newindex,
@@ -602,7 +603,7 @@ class Sheet(tk.Frame):
602
603
 
603
604
  # Bindings and Functionality
604
605
 
605
- def enable_bindings(self, *bindings: str) -> Sheet:
606
+ def enable_bindings(self, *bindings: Binding) -> Sheet:
606
607
  """
607
608
  List of available bindings:
608
609
  - "all"
@@ -652,7 +653,7 @@ class Sheet(tk.Frame):
652
653
  self.MT.enable_bindings(bindings)
653
654
  return self
654
655
 
655
- def disable_bindings(self, *bindings: str) -> Sheet:
656
+ def disable_bindings(self, *bindings: Binding) -> Sheet:
656
657
  """
657
658
  List of available bindings:
658
659
  - "all"
@@ -699,7 +700,7 @@ class Sheet(tk.Frame):
699
700
 
700
701
  def extra_bindings(
701
702
  self,
702
- bindings: str | list | tuple | None = None,
703
+ bindings: ExtraBinding | Sequence[ExtraBinding] | None = None,
703
704
  func: Callable | None = None,
704
705
  ) -> Sheet:
705
706
  """
@@ -734,10 +735,14 @@ class Sheet(tk.Frame):
734
735
  - "rc_delete_row", "end_rc_delete_row", "end_delete_rows", "delete_rows"
735
736
  - "begin_rc_delete_column", "begin_delete_columns"
736
737
  - "rc_delete_column", "end_rc_delete_column","end_delete_columns", "delete_columns"
737
- - "begin_rc_insert_column", "begin_insert_column", "begin_insert_columns", "begin_add_column","begin_rc_add_column", "begin_add_columns"
738
- - "rc_insert_column", "end_rc_insert_column", "end_insert_column", "end_insert_columns", "rc_add_column", "end_rc_add_column", "end_add_column", "end_add_columns", "add_columns"
739
- - "begin_rc_insert_row", "begin_insert_row", "begin_insert_rows", "begin_rc_add_row", "begin_add_row", "begin_add_rows"
740
- - "rc_insert_row", "end_rc_insert_row", "end_insert_row", "end_insert_rows", "rc_add_row", "end_rc_add_row", "end_add_row", "end_add_rows", "add_rows"
738
+ - "begin_rc_insert_column", "begin_insert_column", "begin_insert_columns", "begin_add_column",
739
+ "begin_rc_add_column", "begin_add_columns"
740
+ - "rc_insert_column", "end_rc_insert_column", "end_insert_column", "end_insert_columns", "rc_add_column",
741
+ "end_rc_add_column", "end_add_column", "end_add_columns", "add_columns"
742
+ - "begin_rc_insert_row", "begin_insert_row", "begin_insert_rows", "begin_rc_add_row", "begin_add_row",
743
+ "begin_add_rows"
744
+ - "rc_insert_row", "end_rc_insert_row", "end_insert_row", "end_insert_rows", "rc_add_row", "end_rc_add_row",
745
+ "end_add_row", "end_add_rows", "add_rows"
741
746
  - "row_height_resize"
742
747
  - "column_width_resize"
743
748
  - "cell_select"
@@ -1255,27 +1260,25 @@ class Sheet(tk.Frame):
1255
1260
  canvas.basic_bindings(enable)
1256
1261
  return self
1257
1262
 
1258
- def cut(self, event: object = None, validation: bool = True) -> None | EventDataDict:
1263
+ def cut(self, event: Any = None, validation: bool = True) -> None | EventDataDict:
1259
1264
  return self.MT.ctrl_x(event, validation)
1260
1265
 
1261
- def copy(self, event: object = None) -> None | EventDataDict:
1266
+ def copy(self, event: Any = None) -> None | EventDataDict:
1262
1267
  return self.MT.ctrl_c(event)
1263
1268
 
1264
- def paste(self, event: object = None, validation: bool = True) -> None | EventDataDict:
1269
+ def paste(self, event: Any = None, validation: bool = True) -> None | EventDataDict:
1265
1270
  return self.MT.ctrl_v(event, validation)
1266
1271
 
1267
- def delete(self, event: object = None, validation: bool = True) -> None | EventDataDict:
1272
+ def delete(self, event: Any = None, validation: bool = True) -> None | EventDataDict:
1268
1273
  return self.MT.delete_key(event, validation)
1269
1274
 
1270
- def undo(self, event: object = None) -> None | EventDataDict:
1275
+ def undo(self, event: Any = None) -> None | EventDataDict:
1271
1276
  return self.MT.undo(event)
1272
1277
 
1273
- def redo(self, event: object = None) -> None | EventDataDict:
1278
+ def redo(self, event: Any = None) -> None | EventDataDict:
1274
1279
  return self.MT.redo(event)
1275
1280
 
1276
- def has_focus(
1277
- self,
1278
- ) -> bool:
1281
+ def has_focus(self) -> bool:
1279
1282
  """
1280
1283
  Check if any Sheet widgets have focus
1281
1284
  Includes child widgets such as scroll bars
@@ -1335,10 +1338,10 @@ class Sheet(tk.Frame):
1335
1338
  hdisp: bool = True,
1336
1339
  transposed: bool = False,
1337
1340
  ndim: int = 0,
1338
- convert: object = None,
1341
+ convert: Any = None,
1339
1342
  undo: bool = True,
1340
1343
  emit_event: bool = False,
1341
- widget: object = None,
1344
+ widget: Any = None,
1342
1345
  expand: None | str = None,
1343
1346
  formatter_options: dict | None = None,
1344
1347
  **kwargs,
@@ -1381,10 +1384,7 @@ class Sheet(tk.Frame):
1381
1384
 
1382
1385
  # Named Spans
1383
1386
 
1384
- def named_span(
1385
- self,
1386
- span: Span,
1387
- ) -> Span:
1387
+ def named_span(self, span: Span) -> Span:
1388
1388
  if span.name in self.MT.named_spans:
1389
1389
  raise ValueError(f"Span '{span.name}' already exists.")
1390
1390
  if not span.name:
@@ -1448,7 +1448,7 @@ class Sheet(tk.Frame):
1448
1448
  del self.MT.named_spans[name]
1449
1449
  return self
1450
1450
 
1451
- def set_named_spans(self, named_spans: None | dict = None) -> Sheet:
1451
+ def set_named_spans(self, named_spans: None | dict[str, Span] = None) -> Sheet:
1452
1452
  if named_spans is None:
1453
1453
  for name in self.MT.named_spans:
1454
1454
  self.del_named_span(name)
@@ -1456,10 +1456,10 @@ class Sheet(tk.Frame):
1456
1456
  self.MT.named_spans = named_spans
1457
1457
  return self
1458
1458
 
1459
- def get_named_span(self, name: str) -> dict:
1459
+ def get_named_span(self, name: str) -> dict[str, Span]:
1460
1460
  return self.MT.named_spans[name]
1461
1461
 
1462
- def get_named_spans(self) -> dict:
1462
+ def get_named_spans(self) -> dict[str, Span]:
1463
1463
  return self.MT.named_spans
1464
1464
 
1465
1465
  # Getting Sheet Data
@@ -1470,10 +1470,7 @@ class Sheet(tk.Frame):
1470
1470
  ) -> Span:
1471
1471
  return self.span_from_key(*key)
1472
1472
 
1473
- def span_from_key(
1474
- self,
1475
- *key: CreateSpanTypes,
1476
- ) -> None | Span:
1473
+ def span_from_key(self, *key: CreateSpanTypes) -> None | Span:
1477
1474
  if not key:
1478
1475
  key = (None, None, None, None)
1479
1476
  span = key_to_span(key if len(key) != 1 else key[0], self.MT.named_spans, self)
@@ -1488,10 +1485,7 @@ class Sheet(tk.Frame):
1488
1485
  totalcols=self.MT.total_data_cols,
1489
1486
  )
1490
1487
 
1491
- def get_data(
1492
- self,
1493
- *key: CreateSpanTypes,
1494
- ) -> object:
1488
+ def get_data(self, *key: CreateSpanTypes) -> Any:
1495
1489
  """
1496
1490
  e.g. retrieves entire table as pandas dataframe
1497
1491
  sheet["A1"].expand().options(pandas.DataFrame).data
@@ -1613,10 +1607,7 @@ class Sheet(tk.Frame):
1613
1607
  res = list(chain.from_iterable(res))
1614
1608
  elif span.ndim == 1:
1615
1609
  # flatten sublists
1616
- if len(res) == 1 and len(res[0]) == 1:
1617
- res = res[0]
1618
- else:
1619
- res = list(chain.from_iterable(res))
1610
+ res = res[0] if len(res) == 1 and len(res[0]) == 1 else list(chain.from_iterable(res))
1620
1611
  # if span.ndim == 2 res keeps its current
1621
1612
  # dimensions as a list of lists
1622
1613
  if span.convert is not None:
@@ -1635,20 +1626,20 @@ class Sheet(tk.Frame):
1635
1626
  c: int,
1636
1627
  r_ops: bool = True,
1637
1628
  c_ops: bool = True,
1638
- ) -> object:
1629
+ ) -> Any:
1639
1630
  return self.MT.get_value_for_empty_cell(r, c, r_ops, c_ops)
1640
1631
 
1641
1632
  @property
1642
- def data(self):
1633
+ def data(self) -> Sequence[Sequence[Any]]:
1643
1634
  return self.MT.data
1644
1635
 
1645
- def __iter__(self) -> Iterator[list[object] | tuple[object]]:
1636
+ def __iter__(self) -> Iterator[list[Any] | tuple[Any]]:
1646
1637
  return self.MT.data.__iter__()
1647
1638
 
1648
- def __reversed__(self) -> Iterator[list[object] | tuple[object]]:
1639
+ def __reversed__(self) -> Iterator[list[Any] | tuple[Any]]:
1649
1640
  return reversed(self.MT.data)
1650
1641
 
1651
- def __contains__(self, key: object) -> bool:
1642
+ def __contains__(self, key: Any) -> bool:
1652
1643
  if isinstance(key, (list, tuple)):
1653
1644
  return key in self.MT.data
1654
1645
  return any(key in row for row in self.MT.data)
@@ -1720,7 +1711,7 @@ class Sheet(tk.Frame):
1720
1711
  reset_highlights: bool = False,
1721
1712
  keep_formatting: bool = True,
1722
1713
  delete_options: bool = False,
1723
- ) -> object:
1714
+ ) -> Any:
1724
1715
  if data is None:
1725
1716
  data = []
1726
1717
  if verify and (not isinstance(data, list) or not all(isinstance(row, list) for row in data)):
@@ -1739,7 +1730,7 @@ class Sheet(tk.Frame):
1739
1730
  )
1740
1731
 
1741
1732
  @data.setter
1742
- def data(self, value: list[list[object]]) -> None:
1733
+ def data(self, value: list[list[Any]]) -> None:
1743
1734
  self.data_reference(value)
1744
1735
 
1745
1736
  def new_tksheet_event(self) -> EventDataDict:
@@ -1753,7 +1744,7 @@ class Sheet(tk.Frame):
1753
1744
  def set_data(
1754
1745
  self,
1755
1746
  *key: CreateSpanTypes,
1756
- data: object = None,
1747
+ data: Any = None,
1757
1748
  undo: bool | None = None,
1758
1749
  emit_event: bool | None = None,
1759
1750
  redraw: bool = True,
@@ -2072,8 +2063,8 @@ class Sheet(tk.Frame):
2072
2063
  self,
2073
2064
  datarn: int,
2074
2065
  datacn: int,
2075
- value: object,
2076
- event_data: dict,
2066
+ value: Any,
2067
+ event_data: EventDataDict,
2077
2068
  fmt_kw: dict | None = None,
2078
2069
  check_readonly: bool = False,
2079
2070
  ) -> EventDataDict:
@@ -2085,8 +2076,8 @@ class Sheet(tk.Frame):
2085
2076
  def event_data_set_index_cell(
2086
2077
  self,
2087
2078
  datarn: int,
2088
- value: object,
2089
- event_data: dict,
2079
+ value: Any,
2080
+ event_data: EventDataDict,
2090
2081
  check_readonly: bool = False,
2091
2082
  ) -> EventDataDict:
2092
2083
  if self.RI.input_valid_for_cell(datarn, value, check_readonly=check_readonly):
@@ -2097,8 +2088,8 @@ class Sheet(tk.Frame):
2097
2088
  def event_data_set_header_cell(
2098
2089
  self,
2099
2090
  datacn: int,
2100
- value: object,
2101
- event_data: dict,
2091
+ value: Any,
2092
+ event_data: EventDataDict,
2102
2093
  check_readonly: bool = False,
2103
2094
  ) -> EventDataDict:
2104
2095
  if self.CH.input_valid_for_cell(datacn, value, check_readonly=check_readonly):
@@ -2108,7 +2099,7 @@ class Sheet(tk.Frame):
2108
2099
 
2109
2100
  def insert_row(
2110
2101
  self,
2111
- row: list[object] | tuple[object] | None = None,
2102
+ row: list[Any] | tuple[Any] | None = None,
2112
2103
  idx: str | int | None = None,
2113
2104
  height: int | None = None,
2114
2105
  row_index: bool = False,
@@ -2130,7 +2121,7 @@ class Sheet(tk.Frame):
2130
2121
 
2131
2122
  def insert_column(
2132
2123
  self,
2133
- column: list[object] | tuple[object] | None = None,
2124
+ column: list[Any] | tuple[Any] | None = None,
2134
2125
  idx: str | int | None = None,
2135
2126
  width: int | None = None,
2136
2127
  header: bool = False,
@@ -2152,7 +2143,7 @@ class Sheet(tk.Frame):
2152
2143
 
2153
2144
  def insert_rows(
2154
2145
  self,
2155
- rows: list[tuple[object] | list[object]] | tuple[tuple[object] | list[object]] | int = 1,
2146
+ rows: list[tuple[Any] | list[Any]] | tuple[tuple[Any] | list[Any]] | int = 1,
2156
2147
  idx: str | int | None = None,
2157
2148
  heights: list[int] | tuple[int] | None = None,
2158
2149
  row_index: bool = False,
@@ -2208,10 +2199,7 @@ class Sheet(tk.Frame):
2208
2199
  c_ops=False,
2209
2200
  )
2210
2201
  numrows = len(data)
2211
- if self.MT.all_rows_displayed:
2212
- displayed_ins_idx = idx
2213
- else:
2214
- displayed_ins_idx = bisect_left(self.MT.displayed_rows, idx)
2202
+ displayed_ins_idx = idx if self.MT.all_rows_displayed else bisect_left(self.MT.displayed_rows, idx)
2215
2203
  event_data = self.MT.add_rows(
2216
2204
  *self.MT.get_args_for_add_rows(
2217
2205
  data_ins_row=idx,
@@ -2236,7 +2224,7 @@ class Sheet(tk.Frame):
2236
2224
 
2237
2225
  def insert_columns(
2238
2226
  self,
2239
- columns: list[tuple[object] | list[object]] | tuple[tuple[object] | list[object]] | int = 1,
2227
+ columns: list[tuple[Any] | list[Any]] | tuple[tuple[Any] | list[Any]] | int = 1,
2240
2228
  idx: str | int | None = None,
2241
2229
  widths: list[int] | tuple[int] | None = None,
2242
2230
  headers: bool = False,
@@ -2599,7 +2587,8 @@ class Sheet(tk.Frame):
2599
2587
  """
2600
2588
  Sort the data within specified box regions in the table.
2601
2589
 
2602
- This method sorts the data within one or multiple box regions defined by their coordinates. Each box's columns are sorted independently.
2590
+ This method sorts the data within one or multiple box regions defined by their coordinates.
2591
+ Each box's columns are sorted independently.
2603
2592
 
2604
2593
  Args:
2605
2594
  boxes (CreateSpanTypes): A type that can create a Span.
@@ -2617,7 +2606,8 @@ class Sheet(tk.Frame):
2617
2606
  Note: Performance might be slow with the natural sort for very large datasets.
2618
2607
 
2619
2608
  Returns:
2620
- EventDataDict: A dictionary containing information about the sorting event, including changes made to the table.
2609
+ EventDataDict: A dictionary containing information about the sorting event,
2610
+ including changes made to the table.
2621
2611
 
2622
2612
  Raises:
2623
2613
  ValueError: If the input boxes are not in the expected format or if the data cannot be sorted.
@@ -2758,10 +2748,10 @@ class Sheet(tk.Frame):
2758
2748
  def dropdown(
2759
2749
  self,
2760
2750
  *key: CreateSpanTypes,
2761
- values: list = [],
2751
+ values: list[Any] | None = None,
2762
2752
  edit_data: bool = True,
2763
- set_values: dict[tuple[int, int], object] = {},
2764
- set_value: object = None,
2753
+ set_values: dict[tuple[int, int], Any] | None = None,
2754
+ set_value: Any = None,
2765
2755
  state: Literal["normal", "readonly", "disabled"] = "normal",
2766
2756
  redraw: bool = True,
2767
2757
  selection_function: Callable | None = None,
@@ -2770,6 +2760,10 @@ class Sheet(tk.Frame):
2770
2760
  validate_input: bool = True,
2771
2761
  text: None | str = None,
2772
2762
  ) -> Span:
2763
+ if values is None:
2764
+ values = []
2765
+ if set_values is None:
2766
+ set_values = {}
2773
2767
  if not search_function:
2774
2768
  search_function = dropdown_search_function
2775
2769
  v = set_value if set_value is not None else values[0] if values else ""
@@ -2794,13 +2788,13 @@ class Sheet(tk.Frame):
2794
2788
  self.del_index_cell_options_dropdown_and_checkbox(r)
2795
2789
  add_to_options(self.RI.cell_options, r, "dropdown", d)
2796
2790
  if edit_data:
2797
- set_idata(r, value=set_values[r] if r in set_values else v)
2791
+ set_idata(r, value=set_values.get(r, v))
2798
2792
  if header:
2799
2793
  for c in cols:
2800
2794
  self.del_header_cell_options_dropdown_and_checkbox(c)
2801
2795
  add_to_options(self.CH.cell_options, c, "dropdown", d)
2802
2796
  if edit_data:
2803
- set_hdata(c, value=set_values[c] if c in set_values else v)
2797
+ set_hdata(c, value=set_values.get(c, v))
2804
2798
  if table:
2805
2799
  if span.kind == "cell":
2806
2800
  for r in rows:
@@ -2808,21 +2802,21 @@ class Sheet(tk.Frame):
2808
2802
  self.del_cell_options_dropdown_and_checkbox(r, c)
2809
2803
  add_to_options(self.MT.cell_options, (r, c), "dropdown", d)
2810
2804
  if edit_data:
2811
- set_tdata(r, c, value=set_values[(r, c)] if (r, c) in set_values else v)
2805
+ set_tdata(r, c, value=set_values.get((r, c), v))
2812
2806
  elif span.kind == "row":
2813
2807
  for r in rows:
2814
2808
  self.del_row_options_dropdown_and_checkbox(r)
2815
2809
  add_to_options(self.MT.row_options, r, "dropdown", d)
2816
2810
  if edit_data:
2817
2811
  for c in cols:
2818
- set_tdata(r, c, value=set_values[(r, c)] if (r, c) in set_values else v)
2812
+ set_tdata(r, c, value=set_values.get((r, c), v))
2819
2813
  elif span.kind == "column":
2820
2814
  for c in cols:
2821
2815
  self.del_column_options_dropdown_and_checkbox(c)
2822
2816
  add_to_options(self.MT.col_options, c, "dropdown", d)
2823
2817
  if edit_data:
2824
2818
  for r in rows:
2825
- set_tdata(r, c, value=set_values[(r, c)] if (r, c) in set_values else v)
2819
+ set_tdata(r, c, value=set_values.get((r, c), v))
2826
2820
  self.set_refresh_timer(redraw)
2827
2821
  return span
2828
2822
 
@@ -3002,11 +2996,13 @@ class Sheet(tk.Frame):
3002
2996
  def format(
3003
2997
  self,
3004
2998
  *key: CreateSpanTypes,
3005
- formatter_options: dict = {},
3006
- formatter_class: object = None,
2999
+ formatter_options: dict | None = None,
3000
+ formatter_class: Any = None,
3007
3001
  redraw: bool = True,
3008
3002
  **kwargs,
3009
3003
  ) -> Span:
3004
+ if formatter_options is None:
3005
+ formatter_options = {}
3010
3006
  span = self.span_from_key(*key)
3011
3007
  rows, cols = self.ranges_from_span(span)
3012
3008
  kwargs = fix_format_kwargs({"formatter": formatter_class, **formatter_options, **kwargs})
@@ -3962,7 +3958,7 @@ class Sheet(tk.Frame):
3962
3958
 
3963
3959
  # Identifying Bound Event Mouse Position
3964
3960
 
3965
- def identify_region(self, event: object) -> Literal["table", "index", "header", "top left"]:
3961
+ def identify_region(self, event: Any) -> Literal["table", "index", "header", "top left"]:
3966
3962
  if event.widget == self.MT:
3967
3963
  return "table"
3968
3964
  elif event.widget == self.RI:
@@ -3974,7 +3970,7 @@ class Sheet(tk.Frame):
3974
3970
 
3975
3971
  def identify_row(
3976
3972
  self,
3977
- event: object,
3973
+ event: Any,
3978
3974
  exclude_index: bool = False,
3979
3975
  allow_end: bool = True,
3980
3976
  ) -> int | None:
@@ -3991,7 +3987,7 @@ class Sheet(tk.Frame):
3991
3987
 
3992
3988
  def identify_column(
3993
3989
  self,
3994
- event: object,
3990
+ event: Any,
3995
3991
  exclude_header: bool = False,
3996
3992
  allow_end: bool = True,
3997
3993
  ) -> int | None:
@@ -4008,7 +4004,7 @@ class Sheet(tk.Frame):
4008
4004
 
4009
4005
  # Scroll Positions and Cell Visibility
4010
4006
 
4011
- def sync_scroll(self, widget: object) -> Sheet:
4007
+ def sync_scroll(self, widget: Any) -> Sheet:
4012
4008
  if widget is self:
4013
4009
  return self
4014
4010
  self.MT.synced_scrolls.add(widget)
@@ -4016,7 +4012,7 @@ class Sheet(tk.Frame):
4016
4012
  widget.MT.synced_scrolls.add(self)
4017
4013
  return self
4018
4014
 
4019
- def unsync_scroll(self, widget: object = None) -> Sheet:
4015
+ def unsync_scroll(self, widget: Any = None) -> Sheet:
4020
4016
  if widget is None:
4021
4017
  for widget in self.MT.synced_scrolls:
4022
4018
  if isinstance(widget, Sheet):
@@ -4034,7 +4030,7 @@ class Sheet(tk.Frame):
4034
4030
  column: int = 0,
4035
4031
  keep_yscroll: bool = False,
4036
4032
  keep_xscroll: bool = False,
4037
- bottom_right_corner: bool = False,
4033
+ bottom_right_corner: bool | None = None,
4038
4034
  check_cell_visibility: bool = True,
4039
4035
  redraw: bool = True,
4040
4036
  ) -> Sheet:
@@ -4053,7 +4049,11 @@ class Sheet(tk.Frame):
4053
4049
  return self.MT.cell_visible(r, c)
4054
4050
 
4055
4051
  def cell_completely_visible(self, r: int, c: int, seperate_axes: bool = False) -> bool:
4056
- return self.MT.cell_completely_visible(r, c, seperate_axes)
4052
+ if seperate_axes:
4053
+ d = self.MT.cell_visibility_info(r, c)
4054
+ return d["yvis"], d["xvis"]
4055
+ else:
4056
+ return self.MT.cell_completely_visible(r, c)
4057
4057
 
4058
4058
  def set_xview(self, position: None | float = None, option: str = "moveto") -> Sheet | tuple[float, float]:
4059
4059
  if position is not None:
@@ -4488,13 +4488,13 @@ class Sheet(tk.Frame):
4488
4488
  self.CH.text_editor.window.set_text(text)
4489
4489
  return self
4490
4490
 
4491
- def destroy_text_editor(self, event: object = None) -> Sheet:
4491
+ def destroy_text_editor(self, event: Any = None) -> Sheet:
4492
4492
  self.MT.hide_text_editor(reason=event)
4493
4493
  self.RI.hide_text_editor(reason=event)
4494
4494
  self.CH.hide_text_editor(reason=event)
4495
4495
  return self
4496
4496
 
4497
- def get_text_editor_widget(self, event: object = None) -> tk.Text | None:
4497
+ def get_text_editor_widget(self, event: Any = None) -> tk.Text | None:
4498
4498
  try:
4499
4499
  return self.MT.text_editor.tktext
4500
4500
  except Exception:
@@ -4507,18 +4507,14 @@ class Sheet(tk.Frame):
4507
4507
  def unbind_key_text_editor(self, key: str) -> Sheet:
4508
4508
  if key == "all":
4509
4509
  for key in self.MT.text_editor_user_bound_keys:
4510
- try:
4510
+ with suppress(Exception):
4511
4511
  self.MT.text_editor.tktext.unbind(key)
4512
- except Exception:
4513
- pass
4514
4512
  self.MT.text_editor_user_bound_keys = {}
4515
4513
  else:
4516
4514
  if key in self.MT.text_editor_user_bound_keys:
4517
4515
  del self.MT.text_editor_user_bound_keys[key]
4518
- try:
4516
+ with suppress(Exception):
4519
4517
  self.MT.text_editor.tktext.unbind(key)
4520
- except Exception:
4521
- pass
4522
4518
  return self
4523
4519
 
4524
4520
  def get_text_editor_value(self) -> str | None:
@@ -4632,7 +4628,7 @@ class Sheet(tk.Frame):
4632
4628
 
4633
4629
  def event_widget_is_sheet(
4634
4630
  self,
4635
- event: object,
4631
+ event: Any,
4636
4632
  table: bool = True,
4637
4633
  index: bool = True,
4638
4634
  header: bool = True,
@@ -4977,16 +4973,16 @@ class Sheet(tk.Frame):
4977
4973
  columns=set(),
4978
4974
  )
4979
4975
  for tag in unpack(tags):
4980
- res.cells.update(self.MT.tagged_cells[tag] if tag in self.MT.tagged_cells else set())
4981
- res.rows.update(self.MT.tagged_rows[tag] if tag in self.MT.tagged_rows else set())
4982
- res.columns.update(self.MT.tagged_columns[tag] if tag in self.MT.tagged_columns else set())
4976
+ res.cells.update(self.MT.tagged_cells.get(tag, set()))
4977
+ res.rows.update(self.MT.tagged_rows.get(tag, set()))
4978
+ res.columns.update(self.MT.tagged_columns.get(tag, set()))
4983
4979
  return res
4984
4980
 
4985
4981
  # Treeview Mode
4986
4982
 
4987
4983
  def tree_build(
4988
4984
  self,
4989
- data: list[list[object]],
4985
+ data: list[list[Any]],
4990
4986
  iid_column: int,
4991
4987
  parent_column: int,
4992
4988
  text_column: None | int | list[str] = None,
@@ -5073,10 +5069,7 @@ class Sheet(tk.Frame):
5073
5069
  """
5074
5070
  If used without args all items are opened
5075
5071
  """
5076
- if items := set(unpack(items)):
5077
- to_open = self._tree_open(items)
5078
- else:
5079
- to_open = self._tree_open(set(self.get_children()))
5072
+ to_open = self._tree_open(items) if (items := set(unpack(items))) else self._tree_open(set(self.get_children()))
5080
5073
  return self.show_rows(
5081
5074
  rows=to_open,
5082
5075
  redraw=redraw,
@@ -5103,10 +5096,7 @@ class Sheet(tk.Frame):
5103
5096
  """
5104
5097
  If used without args all items are closed
5105
5098
  """
5106
- if items:
5107
- to_close = self._tree_close(unpack(items))
5108
- else:
5109
- to_close = self._tree_close(self.get_children())
5099
+ to_close = self._tree_close(unpack(items)) if items else self._tree_close(self.get_children())
5110
5100
  return self.hide_rows(
5111
5101
  rows=to_close,
5112
5102
  redraw=redraw,
@@ -5120,7 +5110,7 @@ class Sheet(tk.Frame):
5120
5110
  index: None | int | Literal["end"] = None,
5121
5111
  iid: None | str = None,
5122
5112
  text: None | str = None,
5123
- values: None | list[object] = None,
5113
+ values: None | list[Any] = None,
5124
5114
  create_selections: bool = False,
5125
5115
  undo: bool = True,
5126
5116
  ) -> str:
@@ -5164,13 +5154,10 @@ class Sheet(tk.Frame):
5164
5154
  self.RI.tree_rns[parent]
5165
5155
  + index
5166
5156
  + 1
5167
- + sum(
5168
- sum(1 for _ in self.RI.get_iid_descendants(cid))
5169
- for cid in islice(self.get_children(parent), index)
5170
- )
5157
+ + sum(self.RI.num_descendants(cid) for cid in islice(self.get_children(parent), index))
5171
5158
  )
5172
5159
  else:
5173
- datarn = self.RI.tree_rns[parent] + sum(1 for _ in self.RI.get_iid_descendants(parent)) + 1
5160
+ datarn = self.RI.tree_rns[parent] + self.RI.num_descendants(parent) + 1
5174
5161
  else:
5175
5162
  if isinstance(index, int):
5176
5163
  datarn = index
@@ -5182,7 +5169,7 @@ class Sheet(tk.Frame):
5182
5169
 
5183
5170
  def bulk_insert(
5184
5171
  self,
5185
- data: list[list[object]],
5172
+ data: list[list[Any]],
5186
5173
  parent: str = "",
5187
5174
  index: None | int | Literal["end"] = None,
5188
5175
  iid_column: int | None = None,
@@ -5206,10 +5193,7 @@ class Sheet(tk.Frame):
5206
5193
  datarn = self._get_id_insert_row(index=index, parent=parent)
5207
5194
  rns_to_add = {}
5208
5195
  for rn, r in enumerate(data, start=datarn):
5209
- if iid_column is None:
5210
- iid = self.RI.new_iid()
5211
- else:
5212
- iid = r[iid_column]
5196
+ iid = self.RI.new_iid() if iid_column is None else r[iid_column]
5213
5197
  new_node = Node(
5214
5198
  r[text_column] if isinstance(text_column, int) else text_column if isinstance(text_column, str) else "",
5215
5199
  iid,
@@ -5302,8 +5286,8 @@ class Sheet(tk.Frame):
5302
5286
  def itemrow(self, item: str) -> int:
5303
5287
  try:
5304
5288
  return self.RI.tree_rns[item]
5305
- except Exception:
5306
- raise ValueError(f"item '{item}' does not exist.")
5289
+ except ValueError as error:
5290
+ raise ValueError(f"item '{item}' does not exist.") from error
5307
5291
 
5308
5292
  def rowitem(self, row: int, data_index: bool = False) -> str | None:
5309
5293
  try:
@@ -5524,7 +5508,7 @@ class Sheet(tk.Frame):
5524
5508
  return self.set_refresh_timer(redraw)
5525
5509
 
5526
5510
  def selection_toggle(self, *items, redraw: bool = True) -> Sheet:
5527
- selected = set(self.MT._row_index[self.displayed_row_to_data(rn)].iid for rn in self.get_selected_rows())
5511
+ selected = {self.MT._row_index[self.displayed_row_to_data(rn)].iid for rn in self.get_selected_rows()}
5528
5512
  add = []
5529
5513
  remove = []
5530
5514
  for item in unpack(items):
@@ -5664,7 +5648,7 @@ class Sheet(tk.Frame):
5664
5648
 
5665
5649
  # ########## OLD FUNCTIONS ##########
5666
5650
 
5667
- def get_cell_data(self, r: int, c: int, get_displayed: bool = False) -> object:
5651
+ def get_cell_data(self, r: int, c: int, get_displayed: bool = False) -> Any:
5668
5652
  return self.MT.get_cell_data(r, c, get_displayed)
5669
5653
 
5670
5654
  def get_row_data(
@@ -5674,7 +5658,7 @@ class Sheet(tk.Frame):
5674
5658
  get_index: bool = False,
5675
5659
  get_index_displayed: bool = True,
5676
5660
  only_columns: int | AnyIter[int] | None = None,
5677
- ) -> list[object]:
5661
+ ) -> list[Any]:
5678
5662
  if only_columns is not None:
5679
5663
  if isinstance(only_columns, int):
5680
5664
  only_columns = (only_columns,)
@@ -5700,7 +5684,7 @@ class Sheet(tk.Frame):
5700
5684
  get_header: bool = False,
5701
5685
  get_header_displayed: bool = True,
5702
5686
  only_rows: int | AnyIter[int] | None = None,
5703
- ) -> list[object]:
5687
+ ) -> list[Any]:
5704
5688
  if only_rows is not None:
5705
5689
  if isinstance(only_rows, int):
5706
5690
  only_rows = (only_rows,)
@@ -5720,7 +5704,7 @@ class Sheet(tk.Frame):
5720
5704
  get_index_displayed: bool = True,
5721
5705
  only_rows: AnyIter[int] | int | None = None,
5722
5706
  only_columns: AnyIter[int] | int | None = None,
5723
- ) -> list[object]:
5707
+ ) -> list[Any]:
5724
5708
  if only_rows is not None:
5725
5709
  if isinstance(only_rows, int):
5726
5710
  only_rows = (only_rows,)
@@ -5769,7 +5753,7 @@ class Sheet(tk.Frame):
5769
5753
  get_header_displayed: bool = True,
5770
5754
  only_rows: int | AnyIter[int] | None = None,
5771
5755
  only_columns: int | AnyIter[int] | None = None,
5772
- ) -> Iterator[list[object]]:
5756
+ ) -> Iterator[list[Any]]:
5773
5757
  if only_rows is not None:
5774
5758
  if isinstance(only_rows, int):
5775
5759
  only_rows = (only_rows,)
@@ -5809,7 +5793,7 @@ class Sheet(tk.Frame):
5809
5793
  reset_col_positions: bool = True,
5810
5794
  reset_row_positions: bool = True,
5811
5795
  redraw: bool = True,
5812
- ) -> object:
5796
+ ) -> Any:
5813
5797
  self.set_refresh_timer(redraw)
5814
5798
  return self.MT.data_reference(newdataref, reset_col_positions, reset_row_positions)
5815
5799
 
@@ -5817,7 +5801,7 @@ class Sheet(tk.Frame):
5817
5801
  self,
5818
5802
  r: int,
5819
5803
  c: int,
5820
- value: object = "",
5804
+ value: Any = "",
5821
5805
  redraw: bool = True,
5822
5806
  keep_formatting: bool = True,
5823
5807
  ) -> Sheet:
@@ -5829,7 +5813,7 @@ class Sheet(tk.Frame):
5829
5813
  def set_row_data(
5830
5814
  self,
5831
5815
  r: int,
5832
- values: Sequence[object] = [],
5816
+ values: Sequence[Any] = [],
5833
5817
  add_columns: bool = True,
5834
5818
  redraw: bool = True,
5835
5819
  keep_formatting: bool = True,
@@ -5861,7 +5845,7 @@ class Sheet(tk.Frame):
5861
5845
  def set_column_data(
5862
5846
  self,
5863
5847
  c: int,
5864
- values: Sequence[object] = [],
5848
+ values: Sequence[Any] = [],
5865
5849
  add_rows: bool = True,
5866
5850
  redraw: bool = True,
5867
5851
  keep_formatting: bool = True,
@@ -5892,14 +5876,12 @@ class Sheet(tk.Frame):
5892
5876
 
5893
5877
  def readonly_rows(
5894
5878
  self,
5895
- rows: list | int = [],
5879
+ rows: list[int] | int,
5896
5880
  readonly: bool = True,
5897
5881
  redraw: bool = False,
5898
5882
  ) -> Sheet:
5899
5883
  if isinstance(rows, int):
5900
5884
  rows = [rows]
5901
- else:
5902
- rows = rows
5903
5885
  if not readonly:
5904
5886
  for r in rows:
5905
5887
  if r in self.MT.row_options and "readonly" in self.MT.row_options[r]:
@@ -5913,14 +5895,12 @@ class Sheet(tk.Frame):
5913
5895
 
5914
5896
  def readonly_columns(
5915
5897
  self,
5916
- columns: list | int = [],
5898
+ columns: list[int] | int,
5917
5899
  readonly: bool = True,
5918
5900
  redraw: bool = False,
5919
5901
  ) -> Sheet:
5920
5902
  if isinstance(columns, int):
5921
5903
  columns = [columns]
5922
- else:
5923
- columns = columns
5924
5904
  if not readonly:
5925
5905
  for c in columns:
5926
5906
  if c in self.MT.col_options and "readonly" in self.MT.col_options[c]:
@@ -5936,7 +5916,7 @@ class Sheet(tk.Frame):
5936
5916
  self,
5937
5917
  row: int = 0,
5938
5918
  column: int = 0,
5939
- cells: list = [],
5919
+ cells: list[tuple[int, int]] | None = None,
5940
5920
  readonly: bool = True,
5941
5921
  redraw: bool = False,
5942
5922
  ) -> Sheet:
@@ -5965,7 +5945,7 @@ class Sheet(tk.Frame):
5965
5945
 
5966
5946
  def readonly_header(
5967
5947
  self,
5968
- columns: list = [],
5948
+ columns: list[int],
5969
5949
  readonly: bool = True,
5970
5950
  redraw: bool = False,
5971
5951
  ) -> Sheet:
@@ -5974,7 +5954,7 @@ class Sheet(tk.Frame):
5974
5954
 
5975
5955
  def readonly_index(
5976
5956
  self,
5977
- rows: list = [],
5957
+ rows: list[int],
5978
5958
  readonly: bool = True,
5979
5959
  redraw: bool = False,
5980
5960
  ) -> Sheet:
@@ -5983,7 +5963,7 @@ class Sheet(tk.Frame):
5983
5963
 
5984
5964
  def dehighlight_rows(
5985
5965
  self,
5986
- rows: list[int] | Literal["all"] = [],
5966
+ rows: list[int] | Literal["all"],
5987
5967
  redraw: bool = True,
5988
5968
  ) -> Sheet:
5989
5969
  if isinstance(rows, int):
@@ -5998,19 +5978,15 @@ class Sheet(tk.Frame):
5998
5978
  del self.RI.cell_options[r]["highlight"]
5999
5979
  else:
6000
5980
  for r in rows:
6001
- try:
5981
+ with suppress(Exception):
6002
5982
  del self.MT.row_options[r]["highlight"]
6003
- except Exception:
6004
- pass
6005
- try:
5983
+ with suppress(Exception):
6006
5984
  del self.RI.cell_options[r]["highlight"]
6007
- except Exception:
6008
- pass
6009
5985
  return self.set_refresh_timer(redraw)
6010
5986
 
6011
5987
  def dehighlight_columns(
6012
5988
  self,
6013
- columns: list[int] | Literal["all"] = [],
5989
+ columns: list[int] | Literal["all"],
6014
5990
  redraw: bool = True,
6015
5991
  ) -> Sheet:
6016
5992
  if isinstance(columns, int):
@@ -6025,14 +6001,10 @@ class Sheet(tk.Frame):
6025
6001
  del self.CH.cell_options[c]["highlight"]
6026
6002
  else:
6027
6003
  for c in columns:
6028
- try:
6004
+ with suppress(Exception):
6029
6005
  del self.MT.col_options[c]["highlight"]
6030
- except Exception:
6031
- pass
6032
- try:
6006
+ with suppress(Exception):
6033
6007
  del self.CH.cell_options[c]["highlight"]
6034
- except Exception:
6035
- pass
6036
6008
  return self.set_refresh_timer(redraw)
6037
6009
 
6038
6010
  def highlight_rows(
@@ -6074,7 +6046,7 @@ class Sheet(tk.Frame):
6074
6046
  self,
6075
6047
  row: int | Literal["all"] = 0,
6076
6048
  column: int | Literal["all"] = 0,
6077
- cells: list[tuple[int, int]] = [],
6049
+ cells: list[tuple[int, int]] | None = None,
6078
6050
  canvas: Literal["table", "index", "header"] = "table",
6079
6051
  bg: bool | None | str = False,
6080
6052
  fg: bool | None | str = False,
@@ -6128,7 +6100,7 @@ class Sheet(tk.Frame):
6128
6100
  self,
6129
6101
  row: int | Literal["all"] = 0,
6130
6102
  column: int = 0,
6131
- cells: list[tuple[int, int]] = [],
6103
+ cells: list[tuple[int, int]] | None = None,
6132
6104
  canvas: Literal["table", "row_index", "index", "header"] = "table",
6133
6105
  all_: bool = False,
6134
6106
  redraw: bool = True,
@@ -6207,7 +6179,7 @@ class Sheet(tk.Frame):
6207
6179
  self,
6208
6180
  row: int = 0,
6209
6181
  column: int = 0,
6210
- cells: list = [],
6182
+ cells: list[tuple[int, int]] | dict[tuple[int, int], str] | None = None,
6211
6183
  align: str | None = "global",
6212
6184
  redraw: bool = True,
6213
6185
  ) -> Sheet:
@@ -6224,7 +6196,7 @@ class Sheet(tk.Frame):
6224
6196
 
6225
6197
  def align_rows(
6226
6198
  self,
6227
- rows: list | dict | int = [],
6199
+ rows: list[int] | dict[int, str] | int,
6228
6200
  align: str | None = "global",
6229
6201
  align_index: bool = False,
6230
6202
  redraw: bool = True,
@@ -6249,7 +6221,7 @@ class Sheet(tk.Frame):
6249
6221
 
6250
6222
  def align_columns(
6251
6223
  self,
6252
- columns: list | dict | int = [],
6224
+ columns: list[int] | dict[int, str] | int,
6253
6225
  align: str | None = "global",
6254
6226
  align_header: bool = False,
6255
6227
  redraw: bool = True,
@@ -6274,7 +6246,7 @@ class Sheet(tk.Frame):
6274
6246
 
6275
6247
  def align_header(
6276
6248
  self,
6277
- columns: list | dict | int = [],
6249
+ columns: list[int] | dict[int, str] | int,
6278
6250
  align: str | None = "global",
6279
6251
  redraw: bool = True,
6280
6252
  ) -> Sheet:
@@ -6291,7 +6263,7 @@ class Sheet(tk.Frame):
6291
6263
 
6292
6264
  def align_index(
6293
6265
  self,
6294
- rows: list | dict | int = [],
6266
+ rows: list[int] | dict[int, str] | int,
6295
6267
  align: str | None = "global",
6296
6268
  redraw: bool = True,
6297
6269
  ) -> Sheet:
@@ -6457,11 +6429,11 @@ class Sheet(tk.Frame):
6457
6429
  c: int | Literal["all"] = 0,
6458
6430
  ) -> None:
6459
6431
  if isinstance(r, str) and r.lower() == "all" and isinstance(c, int):
6460
- for r_, c_ in self.MT.cell_options:
6432
+ for r_, _ in self.MT.cell_options:
6461
6433
  if "checkbox" in self.MT.cell_options[(r_, c)]:
6462
6434
  self.del_cell_options_checkbox(r_, c)
6463
6435
  elif isinstance(c, str) and c.lower() == "all" and isinstance(r, int):
6464
- for r_, c_ in self.MT.cell_options:
6436
+ for _, c_ in self.MT.cell_options:
6465
6437
  if "checkbox" in self.MT.cell_options[(r, c_)]:
6466
6438
  self.del_cell_options_checkbox(r, c_)
6467
6439
  elif isinstance(r, str) and r.lower() == "all" and isinstance(c, str) and c.lower() == "all":
@@ -6594,7 +6566,7 @@ class Sheet(tk.Frame):
6594
6566
  self._create_dropdown(r, c, v, d)
6595
6567
  return self.set_refresh_timer(kwargs["redraw"])
6596
6568
 
6597
- def _create_dropdown(self, r: int, c: int, v: object, d: dict) -> None:
6569
+ def _create_dropdown(self, r: int, c: int, v: Any, d: dict) -> None:
6598
6570
  self.del_cell_options_dropdown_and_checkbox(r, c)
6599
6571
  add_to_options(self.MT.cell_options, (r, c), "dropdown", d)
6600
6572
  self.MT.set_cell_data(r, c, v)
@@ -6627,7 +6599,7 @@ class Sheet(tk.Frame):
6627
6599
  self._dropdown_row(r_, v, d)
6628
6600
  return self.set_refresh_timer(kwargs["redraw"])
6629
6601
 
6630
- def _dropdown_row(self, r: int, v: object, d: dict) -> None:
6602
+ def _dropdown_row(self, r: int, v: Any, d: dict) -> None:
6631
6603
  self.del_row_options_dropdown_and_checkbox(r)
6632
6604
  add_to_options(self.MT.row_options, r, "dropdown", d)
6633
6605
  for c in range(self.MT.total_data_cols()):
@@ -6652,7 +6624,7 @@ class Sheet(tk.Frame):
6652
6624
  self._dropdown_column(c_, v, d)
6653
6625
  return self.set_refresh_timer(kwargs["redraw"])
6654
6626
 
6655
- def _dropdown_column(self, c: int, v: object, d: dict) -> None:
6627
+ def _dropdown_column(self, c: int, v: Any, d: dict) -> None:
6656
6628
  self.del_column_options_dropdown_and_checkbox(c)
6657
6629
  add_to_options(self.MT.col_options, c, "dropdown", d)
6658
6630
  for r in range(self.MT.total_data_rows()):
@@ -6677,7 +6649,7 @@ class Sheet(tk.Frame):
6677
6649
  self._create_header_dropdown(c_, v, d)
6678
6650
  return self.set_refresh_timer(kwargs["redraw"])
6679
6651
 
6680
- def _create_header_dropdown(self, c: int, v: object, d: dict) -> None:
6652
+ def _create_header_dropdown(self, c: int, v: Any, d: dict) -> None:
6681
6653
  self.del_header_cell_options_dropdown_and_checkbox(c)
6682
6654
  add_to_options(self.CH.cell_options, c, "dropdown", d)
6683
6655
  self.CH.set_cell_data(c, v)
@@ -6701,7 +6673,7 @@ class Sheet(tk.Frame):
6701
6673
  self._create_index_dropdown(r_, v, d)
6702
6674
  return self.set_refresh_timer(kwargs["redraw"])
6703
6675
 
6704
- def _create_index_dropdown(self, r: int, v: object, d: dict) -> None:
6676
+ def _create_index_dropdown(self, r: int, v: Any, d: dict) -> None:
6705
6677
  self.del_index_cell_options_dropdown_and_checkbox(r)
6706
6678
  add_to_options(self.RI.cell_options, r, "dropdown", d)
6707
6679
  self.RI.set_cell_data(r, v)
@@ -6712,11 +6684,11 @@ class Sheet(tk.Frame):
6712
6684
  c: int | Literal["all"] = 0,
6713
6685
  ) -> None:
6714
6686
  if isinstance(r, str) and r.lower() == "all" and isinstance(c, int):
6715
- for r_, c_ in self.MT.cell_options:
6687
+ for r_, _ in self.MT.cell_options:
6716
6688
  if "dropdown" in self.MT.cell_options[(r_, c)]:
6717
6689
  self.del_cell_options_dropdown(r_, c)
6718
6690
  elif isinstance(c, str) and c.lower() == "all" and isinstance(r, int):
6719
- for r_, c_ in self.MT.cell_options:
6691
+ for _, c_ in self.MT.cell_options:
6720
6692
  if "dropdown" in self.MT.cell_options[(r, c_)]:
6721
6693
  self.del_cell_options_dropdown(r, c_)
6722
6694
  elif isinstance(r, str) and r.lower() == "all" and isinstance(c, str) and c.lower() == "all":
@@ -6810,9 +6782,11 @@ class Sheet(tk.Frame):
6810
6782
  r: int = 0,
6811
6783
  c: int = 0,
6812
6784
  set_existing_dropdown: bool = False,
6813
- values: list[object] = [],
6814
- set_value: object = None,
6785
+ values: list[Any] | None = None,
6786
+ set_value: Any = None,
6815
6787
  ) -> Sheet:
6788
+ if values is None:
6789
+ values = []
6816
6790
  if set_existing_dropdown:
6817
6791
  if self.MT.dropdown.open:
6818
6792
  r_, c_ = self.MT.dropdown.get_coords()
@@ -6835,9 +6809,11 @@ class Sheet(tk.Frame):
6835
6809
  self,
6836
6810
  c: int = 0,
6837
6811
  set_existing_dropdown: bool = False,
6838
- values: list[object] = [],
6839
- set_value: object = None,
6812
+ values: list[Any] | None = None,
6813
+ set_value: Any = None,
6840
6814
  ) -> Sheet:
6815
+ if values is None:
6816
+ values = []
6841
6817
  if set_existing_dropdown:
6842
6818
  if self.CH.dropdown.open:
6843
6819
  c_ = self.CH.dropdown.get_coords()
@@ -6859,9 +6835,11 @@ class Sheet(tk.Frame):
6859
6835
  self,
6860
6836
  r: int = 0,
6861
6837
  set_existing_dropdown: bool = False,
6862
- values: list[object] = [],
6863
- set_value: object = None,
6838
+ values: list[Any] | None = None,
6839
+ set_value: Any = None,
6864
6840
  ) -> Sheet:
6841
+ if values is None:
6842
+ values = []
6865
6843
  if set_existing_dropdown:
6866
6844
  if self.RI.current_dropdown_window is not None:
6867
6845
  r_ = self.RI.current_dropdown_window.r
@@ -6934,15 +6912,15 @@ class Sheet(tk.Frame):
6934
6912
  kwargs["modified_function"] = modified_function
6935
6913
  return kwargs
6936
6914
 
6937
- def get_dropdown_value(self, r: int = 0, c: int = 0) -> object:
6915
+ def get_dropdown_value(self, r: int = 0, c: int = 0) -> Any:
6938
6916
  if self.MT.get_cell_kwargs(r, c, key="dropdown"):
6939
6917
  return self.get_cell_data(r, c)
6940
6918
 
6941
- def get_header_dropdown_value(self, c: int = 0) -> object:
6919
+ def get_header_dropdown_value(self, c: int = 0) -> Any:
6942
6920
  if self.CH.get_cell_kwargs(c, key="dropdown"):
6943
6921
  return self.MT._headers[c]
6944
6922
 
6945
- def get_index_dropdown_value(self, r: int = 0) -> object:
6923
+ def get_index_dropdown_value(self, r: int = 0) -> Any:
6946
6924
  if self.RI.get_cell_kwargs(r, key="dropdown"):
6947
6925
  return self.MT._row_index[r]
6948
6926
 
@@ -6950,11 +6928,13 @@ class Sheet(tk.Frame):
6950
6928
  self,
6951
6929
  r: int | Literal["all"],
6952
6930
  c: int | Literal["all"],
6953
- formatter_options: dict = {},
6954
- formatter_class: object = None,
6931
+ formatter_options: dict | None = None,
6932
+ formatter_class: Any = None,
6955
6933
  redraw: bool = True,
6956
6934
  **kwargs,
6957
6935
  ) -> Sheet:
6936
+ if formatter_options is None:
6937
+ formatter_options = {}
6958
6938
  kwargs = fix_format_kwargs({"formatter": formatter_class, **formatter_options, **kwargs})
6959
6939
  if isinstance(r, str) and r.lower() == "all" and isinstance(c, int):
6960
6940
  for r_ in range(self.MT.total_data_rows()):
@@ -6983,11 +6963,11 @@ class Sheet(tk.Frame):
6983
6963
  clear_values: bool = False,
6984
6964
  ) -> Sheet:
6985
6965
  if isinstance(r, str) and r.lower() == "all" and isinstance(c, int):
6986
- for r_, c_ in self.MT.cell_options:
6966
+ for r_, _ in self.MT.cell_options:
6987
6967
  if "format" in self.MT.cell_options[(r_, c)]:
6988
6968
  self.MT.delete_cell_format(r_, c, clear_values=clear_values)
6989
6969
  elif isinstance(c, str) and c.lower() == "all" and isinstance(r, int):
6990
- for r_, c_ in self.MT.cell_options:
6970
+ for _, c_ in self.MT.cell_options:
6991
6971
  if "format" in self.MT.cell_options[(r, c_)]:
6992
6972
  self.MT.delete_cell_format(r, c_, clear_values=clear_values)
6993
6973
  elif isinstance(r, str) and r.lower() == "all" and isinstance(c, str) and c.lower() == "all":
@@ -7001,11 +6981,13 @@ class Sheet(tk.Frame):
7001
6981
  def format_row(
7002
6982
  self,
7003
6983
  r: AnyIter[int] | int | Literal["all"],
7004
- formatter_options: dict = {},
7005
- formatter_class: object = None,
6984
+ formatter_options: dict | None = None,
6985
+ formatter_class: Any = None,
7006
6986
  redraw: bool = True,
7007
6987
  **kwargs,
7008
6988
  ) -> Sheet:
6989
+ if formatter_options is None:
6990
+ formatter_options = {}
7009
6991
  kwargs = fix_format_kwargs({"formatter": formatter_class, **formatter_options, **kwargs})
7010
6992
  if isinstance(r, str) and r.lower() == "all":
7011
6993
  for r_ in range(len(self.MT.data)):
@@ -7043,11 +7025,13 @@ class Sheet(tk.Frame):
7043
7025
  def format_column(
7044
7026
  self,
7045
7027
  c: AnyIter[int] | int | Literal["all"],
7046
- formatter_options: dict = {},
7047
- formatter_class: object = None,
7028
+ formatter_options: dict | None = None,
7029
+ formatter_class: Any = None,
7048
7030
  redraw: bool = True,
7049
7031
  **kwargs,
7050
7032
  ) -> Sheet:
7033
+ if formatter_options is None:
7034
+ formatter_options = {}
7051
7035
  kwargs = fix_format_kwargs({"formatter": formatter_class, **formatter_options, **kwargs})
7052
7036
  if isinstance(c, str) and c.lower() == "all":
7053
7037
  for c_ in range(self.MT.total_data_cols()):
@@ -7099,7 +7083,7 @@ class Dropdown(Sheet):
7099
7083
  height: int | None = None,
7100
7084
  font: None | tuple[str, int, str] = None,
7101
7085
  outline_thickness: int = 2,
7102
- values: list[object] = [],
7086
+ values: list[Any] | None = None,
7103
7087
  close_dropdown_window: Callable | None = None,
7104
7088
  search_function: Callable = dropdown_search_function,
7105
7089
  modified_function: None | Callable = None,
@@ -7157,7 +7141,7 @@ class Dropdown(Sheet):
7157
7141
  ops=ops,
7158
7142
  outline_color=outline_color,
7159
7143
  align=align,
7160
- values=values,
7144
+ values=[] if values is None else values,
7161
7145
  search_function=search_function,
7162
7146
  modified_function=modified_function,
7163
7147
  )
@@ -7176,7 +7160,7 @@ class Dropdown(Sheet):
7176
7160
  ops: DotDict,
7177
7161
  outline_color: str,
7178
7162
  align: str,
7179
- values: list[object] | None = None,
7163
+ values: list[Any] | None = None,
7180
7164
  search_function: Callable = dropdown_search_function,
7181
7165
  modified_function: None | Callable = None,
7182
7166
  ) -> None:
@@ -7206,7 +7190,7 @@ class Dropdown(Sheet):
7206
7190
  )
7207
7191
  self.values(values, width=width - self.yscroll.winfo_width() - 4)
7208
7192
 
7209
- def arrowkey_UP(self, event: object = None) -> None:
7193
+ def arrowkey_UP(self, event: Any = None) -> None:
7210
7194
  if self.row > 0:
7211
7195
  self.row -= 1
7212
7196
  else:
@@ -7214,13 +7198,13 @@ class Dropdown(Sheet):
7214
7198
  self.see(self.row, 0, redraw=False)
7215
7199
  self.select_row(self.row)
7216
7200
 
7217
- def arrowkey_DOWN(self, event: object = None) -> None:
7201
+ def arrowkey_DOWN(self, event: Any = None) -> None:
7218
7202
  if len(self.MT.data) - 1 > self.row:
7219
7203
  self.row += 1
7220
7204
  self.see(self.row, 0, redraw=False)
7221
7205
  self.select_row(self.row)
7222
7206
 
7223
- def search_and_see(self, event: object = None) -> str:
7207
+ def search_and_see(self, event: Any = None) -> str:
7224
7208
  if self.search_function is not None:
7225
7209
  rn = self.search_function(search_for=rf"{event['value']}", data=(r[0] for r in self.MT.data))
7226
7210
  if isinstance(rn, int):
@@ -7229,7 +7213,7 @@ class Dropdown(Sheet):
7229
7213
  self.select_row(self.row)
7230
7214
  return self.MT.data[rn][0]
7231
7215
 
7232
- def mouse_motion(self, event: object) -> None:
7216
+ def mouse_motion(self, event: Any) -> None:
7233
7217
  row = self.identify_row(event, exclude_index=True, allow_end=False)
7234
7218
  if row is not None and row != self.row:
7235
7219
  self.row = row
@@ -7240,15 +7224,12 @@ class Dropdown(Sheet):
7240
7224
  if rows:
7241
7225
  self.select_row(next(iter(rows)))
7242
7226
 
7243
- def b1(self, event: object = None) -> None:
7227
+ def b1(self, event: Any = None) -> None:
7244
7228
  if event is None:
7245
7229
  row = None
7246
7230
  elif event.keysym == "Return":
7247
7231
  row = self.get_selected_rows()
7248
- if not row:
7249
- row = None
7250
- else:
7251
- row = next(iter(row))
7232
+ row = None if not row else next(iter(row))
7252
7233
  else:
7253
7234
  row = self.identify_row(event, exclude_index=True, allow_end=False)
7254
7235
  if self.single_index:
@@ -7274,10 +7255,12 @@ class Dropdown(Sheet):
7274
7255
 
7275
7256
  def values(
7276
7257
  self,
7277
- values: list = [],
7258
+ values: list[Any] | None = None,
7278
7259
  redraw: bool = True,
7279
7260
  width: int | None = None,
7280
7261
  ) -> None:
7262
+ if values is None:
7263
+ values = []
7281
7264
  self.set_sheet_data(
7282
7265
  [[v] for v in values],
7283
7266
  reset_col_positions=False,