tksheet 7.2.23__py3-none-any.whl → 7.3.1__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
@@ -83,6 +83,7 @@ from .themes import (
83
83
  )
84
84
  from .top_left_rectangle import TopLeftRectangle
85
85
  from .types import (
86
+ AnyIter,
86
87
  CreateSpanTypes,
87
88
  )
88
89
  from .vars import (
@@ -126,10 +127,11 @@ class Sheet(tk.Frame):
126
127
  default_header_height: str | int = "1",
127
128
  default_row_index_width: int = 70,
128
129
  default_row_height: str | int = "1",
129
- max_column_width: Literal["inf"] | float = "inf",
130
- max_row_height: Literal["inf"] | float = "inf",
131
- max_header_height: Literal["inf"] | float = "inf",
132
- max_index_width: Literal["inf"] | float = "inf",
130
+ min_column_width: int = 1,
131
+ max_column_width: float = float("inf"),
132
+ max_row_height: float = float("inf"),
133
+ max_header_height: float = float("inf"),
134
+ max_index_width: float = float("inf"),
133
135
  after_redraw_time_ms: int = 20,
134
136
  set_all_heights_and_widths: bool = False,
135
137
  zoom: int = 100,
@@ -363,10 +365,6 @@ class Sheet(tk.Frame):
363
365
  )
364
366
  self.MT = MainTable(
365
367
  parent=self,
366
- max_column_width=max_column_width,
367
- max_header_height=max_header_height,
368
- max_row_height=max_row_height,
369
- max_index_width=max_index_width,
370
368
  show_index=show_row_index,
371
369
  show_header=show_header,
372
370
  column_headers_canvas=self.CH,
@@ -547,7 +545,7 @@ class Sheet(tk.Frame):
547
545
  def set_header_data(
548
546
  self,
549
547
  value: object,
550
- c: int | None | Iterator[int] = None,
548
+ c: int | None | AnyIter[int] = None,
551
549
  redraw: bool = True,
552
550
  ) -> Sheet:
553
551
  if c is None:
@@ -583,7 +581,7 @@ class Sheet(tk.Frame):
583
581
  def set_index_data(
584
582
  self,
585
583
  value: object,
586
- r: int | None | Iterator[int] = None,
584
+ r: int | None | AnyIter[int] = None,
587
585
  redraw: bool = True,
588
586
  ) -> Sheet:
589
587
  if r is None:
@@ -2308,7 +2306,7 @@ class Sheet(tk.Frame):
2308
2306
 
2309
2307
  def del_rows(
2310
2308
  self,
2311
- rows: int | Iterator[int],
2309
+ rows: int | AnyIter[int],
2312
2310
  data_indexes: bool = True,
2313
2311
  undo: bool = False,
2314
2312
  emit_event: bool = False,
@@ -2350,7 +2348,7 @@ class Sheet(tk.Frame):
2350
2348
 
2351
2349
  def del_columns(
2352
2350
  self,
2353
- columns: int | Iterator[int],
2351
+ columns: int | AnyIter[int],
2354
2352
  data_indexes: bool = True,
2355
2353
  undo: bool = False,
2356
2354
  emit_event: bool = False,
@@ -3466,8 +3464,8 @@ class Sheet(tk.Frame):
3466
3464
 
3467
3465
  def deselect_any(
3468
3466
  self,
3469
- rows: Iterator[int] | int | None,
3470
- columns: Iterator[int] | int | None,
3467
+ rows: AnyIter[int] | int | None,
3468
+ columns: AnyIter[int] | int | None,
3471
3469
  redraw: bool = True,
3472
3470
  ) -> Sheet:
3473
3471
  self.MT.deselect_any(rows=rows, columns=columns, redraw=False)
@@ -3625,7 +3623,7 @@ class Sheet(tk.Frame):
3625
3623
 
3626
3624
  def set_column_widths(
3627
3625
  self,
3628
- column_widths: Iterator[float] | None = None,
3626
+ column_widths: AnyIter[float] | None = None,
3629
3627
  canvas_positions: bool = False,
3630
3628
  reset: bool = False,
3631
3629
  ) -> Sheet:
@@ -3640,7 +3638,7 @@ class Sheet(tk.Frame):
3640
3638
 
3641
3639
  def set_row_heights(
3642
3640
  self,
3643
- row_heights: Iterator[float] | None = None,
3641
+ row_heights: AnyIter[float] | None = None,
3644
3642
  canvas_positions: bool = False,
3645
3643
  reset: bool = False,
3646
3644
  ) -> Sheet:
@@ -3687,7 +3685,7 @@ class Sheet(tk.Frame):
3687
3685
 
3688
3686
  delete_row_position = del_row_position
3689
3687
 
3690
- def del_row_positions(self, idxs: Iterator[int] | None = None) -> Sheet:
3688
+ def del_row_positions(self, idxs: AnyIter[int] | None = None) -> Sheet:
3691
3689
  self.MT.del_row_positions(idxs=idxs)
3692
3690
  self.set_refresh_timer()
3693
3691
  return self
@@ -3698,7 +3696,7 @@ class Sheet(tk.Frame):
3698
3696
 
3699
3697
  delete_column_position = del_column_position
3700
3698
 
3701
- def del_column_positions(self, idxs: Iterator[int] | None = None) -> Sheet:
3699
+ def del_column_positions(self, idxs: AnyIter[int] | None = None) -> Sheet:
3702
3700
  self.MT.del_col_positions(idxs=idxs)
3703
3701
  self.set_refresh_timer()
3704
3702
  return self
@@ -3797,25 +3795,25 @@ class Sheet(tk.Frame):
3797
3795
  if column_widths[0] != 0:
3798
3796
  return False
3799
3797
  return not any(
3800
- x - z < self.MT.min_column_width or not isinstance(x, int) or isinstance(x, bool)
3798
+ x - z < self.ops.min_column_width or not isinstance(x, int) or isinstance(x, bool)
3801
3799
  for z, x in zip(column_widths, islice(column_widths, 1, None))
3802
3800
  )
3803
3801
  return not any(
3804
- z < self.MT.min_column_width or not isinstance(z, int) or isinstance(z, bool) for z in column_widths
3802
+ z < self.ops.min_column_width or not isinstance(z, int) or isinstance(z, bool) for z in column_widths
3805
3803
  )
3806
3804
 
3807
3805
  def valid_row_height(self, height: int) -> int:
3808
3806
  if height < self.MT.min_row_height:
3809
3807
  return self.MT.min_row_height
3810
- elif height > self.MT.max_row_height:
3811
- return self.MT.max_row_height
3808
+ elif height > self.ops.max_row_height:
3809
+ return self.ops.max_row_height
3812
3810
  return height
3813
3811
 
3814
3812
  def valid_column_width(self, width: int) -> int:
3815
- if width < self.MT.min_column_width:
3816
- return self.MT.min_column_width
3817
- elif width > self.MT.max_column_width:
3818
- return self.MT.max_column_width
3813
+ if width < self.ops.min_column_width:
3814
+ return self.ops.min_column_width
3815
+ elif width > self.ops.max_column_width:
3816
+ return self.ops.max_column_width
3819
3817
  return width
3820
3818
 
3821
3819
  @property
@@ -3971,7 +3969,7 @@ class Sheet(tk.Frame):
3971
3969
 
3972
3970
  def display_columns(
3973
3971
  self,
3974
- columns: None | Literal["all"] | Iterator[int] = None,
3972
+ columns: None | Literal["all"] | AnyIter[int] = None,
3975
3973
  all_columns_displayed: None | bool = None,
3976
3974
  reset_col_positions: bool = True,
3977
3975
  redraw: bool = False,
@@ -3995,7 +3993,7 @@ class Sheet(tk.Frame):
3995
3993
 
3996
3994
  def hide_columns(
3997
3995
  self,
3998
- columns: int | set[int] | Iterator[int],
3996
+ columns: int | set[int] | AnyIter[int],
3999
3997
  redraw: bool = True,
4000
3998
  deselect_all: bool = True,
4001
3999
  data_indexes: bool = False,
@@ -4039,7 +4037,7 @@ class Sheet(tk.Frame):
4039
4037
 
4040
4038
  def show_columns(
4041
4039
  self,
4042
- columns: int | Iterator[int],
4040
+ columns: int | AnyIter[int],
4043
4041
  redraw: bool = True,
4044
4042
  deselect_all: bool = True,
4045
4043
  ) -> Sheet:
@@ -4105,7 +4103,7 @@ class Sheet(tk.Frame):
4105
4103
 
4106
4104
  def display_rows(
4107
4105
  self,
4108
- rows: None | Literal["all"] | Iterator[int] = None,
4106
+ rows: None | Literal["all"] | AnyIter[int] = None,
4109
4107
  all_rows_displayed: None | bool = None,
4110
4108
  reset_row_positions: bool = True,
4111
4109
  redraw: bool = False,
@@ -4127,7 +4125,7 @@ class Sheet(tk.Frame):
4127
4125
 
4128
4126
  def hide_rows(
4129
4127
  self,
4130
- rows: int | set[int] | Iterator[int],
4128
+ rows: int | set[int] | AnyIter[int],
4131
4129
  redraw: bool = True,
4132
4130
  deselect_all: bool = True,
4133
4131
  data_indexes: bool = False,
@@ -4173,7 +4171,7 @@ class Sheet(tk.Frame):
4173
4171
 
4174
4172
  def show_rows(
4175
4173
  self,
4176
- rows: int | Iterator[int],
4174
+ rows: int | AnyIter[int],
4177
4175
  redraw: bool = True,
4178
4176
  deselect_all: bool = True,
4179
4177
  ) -> Sheet:
@@ -4440,6 +4438,10 @@ class Sheet(tk.Frame):
4440
4438
  self.ops[k] = v
4441
4439
  if k.endswith("bindings"):
4442
4440
  self.MT._enable_binding(k.split("_")[0])
4441
+ if "name" in kwargs:
4442
+ self.name = kwargs["name"]
4443
+ if "min_column_width" in kwargs:
4444
+ self.MT.set_min_column_width(kwargs["min_column_width"])
4443
4445
  if "from_clipboard_delimiters" in kwargs:
4444
4446
  self.ops.from_clipboard_delimiters = (
4445
4447
  self.ops.from_clipboard_delimiters
@@ -4448,14 +4450,6 @@ class Sheet(tk.Frame):
4448
4450
  )
4449
4451
  if "default_row_height" in kwargs:
4450
4452
  self.default_row_height(kwargs["default_row_height"])
4451
- if "max_column_width" in kwargs:
4452
- self.MT.max_column_width = float(kwargs["max_column_width"])
4453
- if "max_row_height" in kwargs:
4454
- self.MT.max_row_height = float(kwargs["max_row_height"])
4455
- if "max_header_height" in kwargs:
4456
- self.MT.max_header_height = float(kwargs["max_header_height"])
4457
- if "max_index_width" in kwargs:
4458
- self.MT.max_index_width = float(kwargs["max_index_width"])
4459
4453
  if "expand_sheet_if_paste_too_big" in kwargs:
4460
4454
  self.ops.paste_can_expand_x = kwargs["expand_sheet_if_paste_too_big"]
4461
4455
  self.ops.paste_can_expand_y = kwargs["expand_sheet_if_paste_too_big"]
@@ -4494,7 +4488,6 @@ class Sheet(tk.Frame):
4494
4488
  self.set_scrollbar_options()
4495
4489
  self.MT.create_rc_menus()
4496
4490
  if "treeview" in kwargs:
4497
- self.set_options(auto_resize_row_index=True, redraw=False)
4498
4491
  self.index_align("w", redraw=False)
4499
4492
  return self.set_refresh_timer(redraw)
4500
4493
 
@@ -4798,7 +4791,7 @@ class Sheet(tk.Frame):
4798
4791
  def tag(
4799
4792
  self,
4800
4793
  *key: CreateSpanTypes,
4801
- tags: Iterator[str] | str = "",
4794
+ tags: AnyIter[str] | str = "",
4802
4795
  ) -> Sheet:
4803
4796
  span = self.span_from_key(*key)
4804
4797
  rows, cols = self.ranges_from_span(span)
@@ -4843,7 +4836,7 @@ class Sheet(tk.Frame):
4843
4836
 
4844
4837
  def tag_rows(
4845
4838
  self,
4846
- rows: int | Iterator[int],
4839
+ rows: int | AnyIter[int],
4847
4840
  *tags,
4848
4841
  ) -> Sheet:
4849
4842
  if isinstance(rows, int):
@@ -4856,7 +4849,7 @@ class Sheet(tk.Frame):
4856
4849
 
4857
4850
  def tag_columns(
4858
4851
  self,
4859
- columns: int | Iterator[int],
4852
+ columns: int | AnyIter[int],
4860
4853
  *tags,
4861
4854
  ) -> Sheet:
4862
4855
  if isinstance(columns, int):
@@ -4870,8 +4863,8 @@ class Sheet(tk.Frame):
4870
4863
  def untag(
4871
4864
  self,
4872
4865
  cell: tuple[int, int] | None = None,
4873
- rows: int | Iterator[int] | None = None,
4874
- columns: int | Iterator[int] | None = None,
4866
+ rows: int | AnyIter[int] | None = None,
4867
+ columns: int | AnyIter[int] | None = None,
4875
4868
  ) -> Sheet:
4876
4869
  if isinstance(cell, tuple):
4877
4870
  for tagged in self.MT.tagged_cells.values():
@@ -4931,7 +4924,7 @@ class Sheet(tk.Frame):
4931
4924
  text_column: None | int | list[str] = None,
4932
4925
  push_ops: bool = False,
4933
4926
  row_heights: Sequence[int] | None | False = None,
4934
- open_ids: Iterator[str] | None = None,
4927
+ open_ids: AnyIter[str] | None = None,
4935
4928
  safety: bool = True,
4936
4929
  ncols: int | None = None,
4937
4930
  lower: bool = False,
@@ -4958,7 +4951,7 @@ class Sheet(tk.Frame):
4958
4951
  if not iid:
4959
4952
  continue
4960
4953
  tally_of_ids[iid] += 1
4961
- if tally_of_ids[iid] > 0:
4954
+ if tally_of_ids[iid]:
4962
4955
  x = 1
4963
4956
  while iid in tally_of_ids:
4964
4957
  new = f"{row[iid_column]}_DUPLICATED_{x}"
@@ -5040,7 +5033,7 @@ class Sheet(tk.Frame):
5040
5033
  """
5041
5034
  return self.RI.tree_open_ids
5042
5035
 
5043
- def tree_set_open(self, open_ids: Iterator[str]) -> Sheet:
5036
+ def tree_set_open(self, open_ids: AnyIter[str]) -> Sheet:
5044
5037
  """
5045
5038
  Accepts set[str] of iids that are open in the treeview
5046
5039
  Closes everything else
@@ -5095,7 +5088,7 @@ class Sheet(tk.Frame):
5095
5088
  deselect_all=False,
5096
5089
  )
5097
5090
 
5098
- def _tree_close(self, items: Iterator[str]) -> list[int]:
5091
+ def _tree_close(self, items: AnyIter[str]) -> list[int]:
5099
5092
  """
5100
5093
  Only meant for internal use
5101
5094
  """
@@ -5137,6 +5130,9 @@ class Sheet(tk.Frame):
5137
5130
  ) -> str:
5138
5131
  """
5139
5132
  Insert an item into the treeview
5133
+
5134
+ Returns:
5135
+ str: new item iid
5140
5136
  """
5141
5137
  if not iid:
5142
5138
  i = 0
@@ -5195,7 +5191,12 @@ class Sheet(tk.Frame):
5195
5191
  include_text_column: bool = True,
5196
5192
  ) -> dict[str, int]:
5197
5193
  """
5198
- Insert multiple items into the treeview at once, under the same parent
5194
+ Insert multiple items into the treeview at once, under the same parent.
5195
+
5196
+ Returns:
5197
+ dict:
5198
+ - Keys (str): iid
5199
+ - Values (int): row numbers
5199
5200
  """
5200
5201
  to_insert = []
5201
5202
  pid = parent
@@ -5786,7 +5787,7 @@ class Sheet(tk.Frame):
5786
5787
  get_displayed: bool = False,
5787
5788
  get_index: bool = False,
5788
5789
  get_index_displayed: bool = True,
5789
- only_columns: int | Iterator[int] | None = None,
5790
+ only_columns: int | AnyIter[int] | None = None,
5790
5791
  ) -> list[object]:
5791
5792
  if only_columns is not None:
5792
5793
  if isinstance(only_columns, int):
@@ -5812,7 +5813,7 @@ class Sheet(tk.Frame):
5812
5813
  get_displayed: bool = False,
5813
5814
  get_header: bool = False,
5814
5815
  get_header_displayed: bool = True,
5815
- only_rows: int | Iterator[int] | None = None,
5816
+ only_rows: int | AnyIter[int] | None = None,
5816
5817
  ) -> list[object]:
5817
5818
  if only_rows is not None:
5818
5819
  if isinstance(only_rows, int):
@@ -5831,8 +5832,8 @@ class Sheet(tk.Frame):
5831
5832
  get_index: bool = False,
5832
5833
  get_header_displayed: bool = True,
5833
5834
  get_index_displayed: bool = True,
5834
- only_rows: Iterator[int] | int | None = None,
5835
- only_columns: Iterator[int] | int | None = None,
5835
+ only_rows: AnyIter[int] | int | None = None,
5836
+ only_columns: AnyIter[int] | int | None = None,
5836
5837
  ) -> list[object]:
5837
5838
  if only_rows is not None:
5838
5839
  if isinstance(only_rows, int):
@@ -5880,8 +5881,8 @@ class Sheet(tk.Frame):
5880
5881
  get_index: bool = False,
5881
5882
  get_index_displayed: bool = True,
5882
5883
  get_header_displayed: bool = True,
5883
- only_rows: int | Iterator[int] | None = None,
5884
- only_columns: int | Iterator[int] | None = None,
5884
+ only_rows: int | AnyIter[int] | None = None,
5885
+ only_columns: int | AnyIter[int] | None = None,
5885
5886
  ) -> Iterator[list[object]]:
5886
5887
  if only_rows is not None:
5887
5888
  if isinstance(only_rows, int):
@@ -6150,7 +6151,7 @@ class Sheet(tk.Frame):
6150
6151
 
6151
6152
  def highlight_rows(
6152
6153
  self,
6153
- rows: Iterator[int] | int,
6154
+ rows: AnyIter[int] | int,
6154
6155
  bg: None | str = None,
6155
6156
  fg: None | str = None,
6156
6157
  highlight_index: bool = True,
@@ -6168,7 +6169,7 @@ class Sheet(tk.Frame):
6168
6169
 
6169
6170
  def highlight_columns(
6170
6171
  self,
6171
- columns: Iterator[int] | int,
6172
+ columns: AnyIter[int] | int,
6172
6173
  bg: bool | None | str = False,
6173
6174
  fg: bool | None | str = False,
6174
6175
  highlight_header: bool = True,
@@ -6468,7 +6469,12 @@ class Sheet(tk.Frame):
6468
6469
  ) -> None:
6469
6470
  self.create_checkbox(r=r, c=c, **get_checkbox_kwargs(*args, **kwargs))
6470
6471
 
6471
- def checkbox_row(self, r: Iterator[int] | int | Literal["all"] = 0, *args, **kwargs) -> None:
6472
+ def checkbox_row(
6473
+ self,
6474
+ r: AnyIter[int] | int | Literal["all"] = 0,
6475
+ *args,
6476
+ **kwargs,
6477
+ ) -> None:
6472
6478
  kwargs = get_checkbox_kwargs(*args, **kwargs)
6473
6479
  d = get_checkbox_dict(**kwargs)
6474
6480
  if isinstance(r, str) and r.lower() == "all":
@@ -6490,7 +6496,7 @@ class Sheet(tk.Frame):
6490
6496
 
6491
6497
  def checkbox_column(
6492
6498
  self,
6493
- c: Iterator[int] | int | Literal["all"] = 0,
6499
+ c: AnyIter[int] | int | Literal["all"] = 0,
6494
6500
  *args,
6495
6501
  **kwargs,
6496
6502
  ) -> None:
@@ -6513,7 +6519,12 @@ class Sheet(tk.Frame):
6513
6519
  for r in range(self.MT.total_data_rows()):
6514
6520
  self.MT.set_cell_data(r, c, v)
6515
6521
 
6516
- def create_header_checkbox(self, c: Iterator[int] | int | Literal["all"] = 0, *args, **kwargs) -> None:
6522
+ def create_header_checkbox(
6523
+ self,
6524
+ c: AnyIter[int] | int | Literal["all"] = 0,
6525
+ *args,
6526
+ **kwargs,
6527
+ ) -> None:
6517
6528
  kwargs = get_checkbox_kwargs(*args, **kwargs)
6518
6529
  d = get_checkbox_dict(**kwargs)
6519
6530
  if isinstance(c, str) and c.lower() == "all":
@@ -6531,7 +6542,12 @@ class Sheet(tk.Frame):
6531
6542
  add_to_options(self.CH.cell_options, c, "checkbox", d)
6532
6543
  self.CH.set_cell_data(c, v)
6533
6544
 
6534
- def create_index_checkbox(self, r: Iterator[int] | int | Literal["all"] = 0, *args, **kwargs) -> None:
6545
+ def create_index_checkbox(
6546
+ self,
6547
+ r: AnyIter[int] | int | Literal["all"] = 0,
6548
+ *args,
6549
+ **kwargs,
6550
+ ) -> None:
6535
6551
  kwargs = get_checkbox_kwargs(*args, **kwargs)
6536
6552
  d = get_checkbox_dict(**kwargs)
6537
6553
  if isinstance(r, str) and r.lower() == "all":
@@ -6576,7 +6592,10 @@ class Sheet(tk.Frame):
6576
6592
  ) -> None:
6577
6593
  self.delete_checkbox(r, c)
6578
6594
 
6579
- def delete_row_checkbox(self, r: Iterator[int] | int | Literal["all"] = 0) -> None:
6595
+ def delete_row_checkbox(
6596
+ self,
6597
+ r: AnyIter[int] | int | Literal["all"] = 0,
6598
+ ) -> None:
6580
6599
  if isinstance(r, str) and r.lower() == "all":
6581
6600
  for r_ in self.MT.row_options:
6582
6601
  self.del_table_row_options_checkbox(r_)
@@ -6586,7 +6605,10 @@ class Sheet(tk.Frame):
6586
6605
  for r_ in r:
6587
6606
  self.del_table_row_options_checkbox(r_)
6588
6607
 
6589
- def delete_column_checkbox(self, c: Iterator[int] | int | Literal["all"] = 0) -> None:
6608
+ def delete_column_checkbox(
6609
+ self,
6610
+ c: AnyIter[int] | int | Literal["all"] = 0,
6611
+ ) -> None:
6590
6612
  if isinstance(c, str) and c.lower() == "all":
6591
6613
  for c_ in self.MT.col_options:
6592
6614
  self.del_table_column_options_checkbox(c_)
@@ -6596,7 +6618,10 @@ class Sheet(tk.Frame):
6596
6618
  for c_ in c:
6597
6619
  self.del_table_column_options_checkbox(c_)
6598
6620
 
6599
- def delete_header_checkbox(self, c: Iterator[int] | int | Literal["all"] = 0) -> None:
6621
+ def delete_header_checkbox(
6622
+ self,
6623
+ c: AnyIter[int] | int | Literal["all"] = 0,
6624
+ ) -> None:
6600
6625
  if isinstance(c, str) and c.lower() == "all":
6601
6626
  for c_ in self.CH.cell_options:
6602
6627
  if "checkbox" in self.CH.cell_options[c_]:
@@ -6607,7 +6632,10 @@ class Sheet(tk.Frame):
6607
6632
  for c_ in c:
6608
6633
  self.del_header_cell_options_checkbox(c_)
6609
6634
 
6610
- def delete_index_checkbox(self, r: Iterator[int] | int | Literal["all"] = 0) -> None:
6635
+ def delete_index_checkbox(
6636
+ self,
6637
+ r: AnyIter[int] | int | Literal["all"] = 0,
6638
+ ) -> None:
6611
6639
  if isinstance(r, str) and r.lower() == "all":
6612
6640
  for r_ in self.RI.cell_options:
6613
6641
  if "checkbox" in self.RI.cell_options[r_]:
@@ -6696,7 +6724,7 @@ class Sheet(tk.Frame):
6696
6724
 
6697
6725
  def dropdown_row(
6698
6726
  self,
6699
- r: Iterator[int] | int | Literal["all"] = 0,
6727
+ r: AnyIter[int] | int | Literal["all"] = 0,
6700
6728
  *args,
6701
6729
  **kwargs,
6702
6730
  ) -> Sheet:
@@ -6721,7 +6749,7 @@ class Sheet(tk.Frame):
6721
6749
 
6722
6750
  def dropdown_column(
6723
6751
  self,
6724
- c: Iterator[int] | int | Literal["all"] = 0,
6752
+ c: AnyIter[int] | int | Literal["all"] = 0,
6725
6753
  *args,
6726
6754
  **kwargs,
6727
6755
  ) -> Sheet:
@@ -6746,7 +6774,7 @@ class Sheet(tk.Frame):
6746
6774
 
6747
6775
  def create_header_dropdown(
6748
6776
  self,
6749
- c: Iterator[int] | int | Literal["all"] = 0,
6777
+ c: AnyIter[int] | int | Literal["all"] = 0,
6750
6778
  *args,
6751
6779
  **kwargs,
6752
6780
  ) -> Sheet:
@@ -6770,7 +6798,7 @@ class Sheet(tk.Frame):
6770
6798
 
6771
6799
  def create_index_dropdown(
6772
6800
  self,
6773
- r: Iterator[int] | int | Literal["all"] = 0,
6801
+ r: AnyIter[int] | int | Literal["all"] = 0,
6774
6802
  *args,
6775
6803
  **kwargs,
6776
6804
  ) -> Sheet:
@@ -6821,7 +6849,7 @@ class Sheet(tk.Frame):
6821
6849
 
6822
6850
  def delete_row_dropdown(
6823
6851
  self,
6824
- r: Iterator[int] | int | Literal["all"] = "all",
6852
+ r: AnyIter[int] | int | Literal["all"] = "all",
6825
6853
  ) -> None:
6826
6854
  if isinstance(r, str) and r.lower() == "all":
6827
6855
  for r_ in self.MT.row_options:
@@ -6835,7 +6863,7 @@ class Sheet(tk.Frame):
6835
6863
 
6836
6864
  def delete_column_dropdown(
6837
6865
  self,
6838
- c: Iterator[int] | int | Literal["all"] = "all",
6866
+ c: AnyIter[int] | int | Literal["all"] = "all",
6839
6867
  ) -> None:
6840
6868
  if isinstance(c, str) and c.lower() == "all":
6841
6869
  for c_ in self.MT.col_options:
@@ -6847,7 +6875,7 @@ class Sheet(tk.Frame):
6847
6875
  for c_ in c:
6848
6876
  self.del_column_options_dropdown(datacn=c_)
6849
6877
 
6850
- def delete_header_dropdown(self, c: Iterator[int] | int | Literal["all"]) -> None:
6878
+ def delete_header_dropdown(self, c: AnyIter[int] | int | Literal["all"]) -> None:
6851
6879
  if isinstance(c, str) and c.lower() == "all":
6852
6880
  for c_ in self.CH.cell_options:
6853
6881
  if "dropdown" in self.CH.cell_options[c_]:
@@ -6858,7 +6886,7 @@ class Sheet(tk.Frame):
6858
6886
  for c_ in c:
6859
6887
  self.del_header_cell_options_dropdown(c_)
6860
6888
 
6861
- def delete_index_dropdown(self, r: Iterator[int] | int | Literal["all"]) -> None:
6889
+ def delete_index_dropdown(self, r: AnyIter[int] | int | Literal["all"]) -> None:
6862
6890
  if isinstance(r, str) and r.lower() == "all":
6863
6891
  for r_ in self.RI.cell_options:
6864
6892
  if "dropdown" in self.RI.cell_options[r_]:
@@ -7087,7 +7115,7 @@ class Sheet(tk.Frame):
7087
7115
 
7088
7116
  def format_row(
7089
7117
  self,
7090
- r: Iterator[int] | int | Literal["all"],
7118
+ r: AnyIter[int] | int | Literal["all"],
7091
7119
  formatter_options: dict = {},
7092
7120
  formatter_class: object = None,
7093
7121
  redraw: bool = True,
@@ -7117,7 +7145,7 @@ class Sheet(tk.Frame):
7117
7145
 
7118
7146
  def delete_row_format(
7119
7147
  self,
7120
- r: Iterator[int] | int | Literal["all"] = "all",
7148
+ r: AnyIter[int] | int | Literal["all"] = "all",
7121
7149
  clear_values: bool = False,
7122
7150
  ) -> Sheet:
7123
7151
  if is_iterable(r):
@@ -7129,7 +7157,7 @@ class Sheet(tk.Frame):
7129
7157
 
7130
7158
  def format_column(
7131
7159
  self,
7132
- c: Iterator[int] | int | Literal["all"],
7160
+ c: AnyIter[int] | int | Literal["all"],
7133
7161
  formatter_options: dict = {},
7134
7162
  formatter_class: object = None,
7135
7163
  redraw: bool = True,
@@ -7159,7 +7187,7 @@ class Sheet(tk.Frame):
7159
7187
 
7160
7188
  def delete_column_format(
7161
7189
  self,
7162
- c: Iterator[int] | int | Literal["all"] = "all",
7190
+ c: AnyIter[int] | int | Literal["all"] = "all",
7163
7191
  clear_values: bool = False,
7164
7192
  ) -> Sheet:
7165
7193
  if is_iterable(c):
tksheet/sheet_options.py CHANGED
@@ -103,6 +103,20 @@ def new_sheet_options() -> DotDict:
103
103
  "select_all_bindings": [
104
104
  f"<{ctrl_key}-a>",
105
105
  f"<{ctrl_key}-A>",
106
+ f"<{ctrl_key}-Shift-space>",
107
+ ],
108
+ "select_columns_bindings": [
109
+ "<Control-space>",
110
+ ],
111
+ "select_rows_bindings": [
112
+ "<Shift-space>",
113
+ ],
114
+ "row_start_bindings": [
115
+ "<Command-Left>",
116
+ "<Home>",
117
+ ],
118
+ "table_start_bindings": [
119
+ f"<{ctrl_key}-Home>",
106
120
  ],
107
121
  "tab_bindings": [
108
122
  "<Tab>",
@@ -186,5 +200,10 @@ def new_sheet_options() -> DotDict:
186
200
  "treeview_indent": "5",
187
201
  "rounded_boxes": True,
188
202
  "alternate_color": "",
203
+ "min_column_width": 1,
204
+ "max_column_width": float("inf"),
205
+ "max_header_height": float("inf"),
206
+ "max_row_height": float("inf"),
207
+ "max_index_width": float("inf"),
189
208
  }
190
209
  )
@@ -160,21 +160,30 @@ class TopLeftRectangle(tk.Canvas):
160
160
  self,
161
161
  new_w: None | int = None,
162
162
  new_h: None | int = None,
163
- recreate_selection_boxes: bool = True,
164
163
  ) -> None:
165
164
  try:
166
- if isinstance(new_h, int):
165
+ if isinstance(new_h, int) and isinstance(new_w, int):
167
166
  h = new_h
168
- self.config(height=h)
169
- else:
167
+ w = new_w
168
+ self.config(width=w, height=h)
169
+
170
+ elif isinstance(new_w, int) and new_h is None:
170
171
  h = self.CH.current_height
171
- if isinstance(new_w, int):
172
172
  w = new_w
173
173
  self.config(width=w)
174
+
175
+ elif isinstance(new_h, int) and new_w is None:
176
+ h = new_h
177
+ w = self.RI.current_width
178
+ self.config(height=h)
179
+
174
180
  else:
181
+ h = self.CH.current_height
175
182
  w = self.RI.current_width
183
+
176
184
  except Exception:
177
185
  return
186
+
178
187
  self.coords(self.rw_box, 0, h - 5, w, h)
179
188
  self.coords(self.rh_box, w - 5, 0, w, h)
180
189
  self.coords(
@@ -187,8 +196,6 @@ class TopLeftRectangle(tk.Canvas):
187
196
  h - 7,
188
197
  )
189
198
  self.coords(self.select_all_box, 0, 0, w - 5, h - 5)
190
- if recreate_selection_boxes:
191
- self.MT.recreate_all_selection_boxes()
192
199
 
193
200
  def mouse_motion(self, event: object = None) -> None:
194
201
  self.MT.reset_mouse_motion_creations()
tksheet/types.py CHANGED
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import (
4
+ Iterable,
5
+ Iterator,
6
+ )
1
7
  from typing import Tuple, Union
2
8
 
3
9
  from .other_classes import (
@@ -15,3 +21,5 @@ CreateSpanTypes = Union[
15
21
  Tuple[int, None, int, None, int, None, int, None],
16
22
  Span,
17
23
  ]
24
+
25
+ AnyIter = Iterable | Iterator