tksheet 7.1.7__py3-none-any.whl → 7.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tksheet/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
  tksheet - A Python tkinter table widget
5
5
  """
6
6
 
7
- __version__ = "7.1.7"
7
+ __version__ = "7.1.8"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
@@ -35,13 +35,13 @@ from .functions import (
35
35
  alpha2idx,
36
36
  alpha2num,
37
37
  consecutive_chunks,
38
+ consecutive_ranges,
38
39
  data_to_displayed_idxs,
39
40
  displayed_to_data_idxs,
40
41
  dropdown_search_function,
41
42
  event_dict,
42
43
  get_checkbox_dict,
43
44
  get_checkbox_kwargs,
44
- rounded_box_coords,
45
45
  get_dropdown_dict,
46
46
  get_dropdown_kwargs,
47
47
  get_index_of_gap_in_sorted_integer_seq_forward,
@@ -53,12 +53,10 @@ from .functions import (
53
53
  move_elements_by_mapping,
54
54
  move_elements_to,
55
55
  num2alpha,
56
+ rounded_box_coords,
56
57
  span_dict,
57
58
  tksheet_type_error,
58
59
  )
59
- from .listbox import (
60
- ListBox,
61
- )
62
60
  from .main_table import MainTable
63
61
  from .other_classes import (
64
62
  DotDict,
tksheet/column_headers.py CHANGED
@@ -23,9 +23,9 @@ from .functions import (
23
23
  consecutive_ranges,
24
24
  ev_stack_dict,
25
25
  event_dict,
26
- rounded_box_coords,
27
26
  get_n2a,
28
27
  is_contiguous,
28
+ rounded_box_coords,
29
29
  try_binding,
30
30
  )
31
31
  from .other_classes import (
@@ -41,6 +41,7 @@ from .vars import (
41
41
  USER_OS,
42
42
  rc_binding,
43
43
  symbols_set,
44
+ text_editor_to_unbind,
44
45
  )
45
46
 
46
47
 
@@ -942,7 +943,7 @@ class ColumnHeaders(tk.Canvas):
942
943
  y1,
943
944
  x2,
944
945
  y2,
945
- radius=9 if self.PAR.ops.rounded_boxes else 0,
946
+ radius=8 if self.PAR.ops.rounded_boxes else 0,
946
947
  )
947
948
  if isinstance(iid, int):
948
949
  self.coords(iid, coords)
@@ -1663,6 +1664,7 @@ class ColumnHeaders(tk.Canvas):
1663
1664
  key=extra_func_key,
1664
1665
  value=text,
1665
1666
  loc=c,
1667
+ column=c,
1666
1668
  boxes=self.MT.get_boxes(),
1667
1669
  selected=self.MT.selected,
1668
1670
  )
@@ -1726,12 +1728,14 @@ class ColumnHeaders(tk.Canvas):
1726
1728
  self.text_editor.tktext.focus_set()
1727
1729
  self.text_editor.window.scroll_to_bottom()
1728
1730
  self.text_editor.tktext.bind("<Alt-Return>", lambda _x: self.text_editor_newline_binding(c=c))
1731
+ self.text_editor.tktext.bind("<Alt-KP_Enter>", lambda _x: self.text_editor_newline_binding(c=c))
1729
1732
  if USER_OS == "darwin":
1730
1733
  self.text_editor.tktext.bind("<Option-Return>", lambda _x: self.text_editor_newline_binding(c=c))
1731
1734
  for key, func in self.MT.text_editor_user_bound_keys.items():
1732
1735
  self.text_editor.tktext.bind(key, func)
1733
1736
  self.text_editor.tktext.bind("<Tab>", lambda _x: self.close_text_editor((c, "Tab")))
1734
1737
  self.text_editor.tktext.bind("<Return>", lambda _x: self.close_text_editor((c, "Return")))
1738
+ self.text_editor.tktext.bind("<KP_Enter>", lambda _x: self.close_text_editor((c, "Return")))
1735
1739
  if not dropdown:
1736
1740
  self.text_editor.tktext.bind("<FocusOut>", lambda _x: self.close_text_editor((c, "FocusOut")))
1737
1741
  self.text_editor.tktext.bind("<Escape>", lambda _x: self.close_text_editor((c, "Escape")))
@@ -1827,8 +1831,8 @@ class ColumnHeaders(tk.Canvas):
1827
1831
 
1828
1832
  def hide_text_editor(self, reason: None | str = None) -> None:
1829
1833
  if self.text_editor.open:
1830
- for b in ("<Alt-Return>", "<Option-Return>", "<Tab>", "<Return>", "<FocusOut>", "<Escape>"):
1831
- self.text_editor.tktext.unbind(b)
1834
+ for binding in text_editor_to_unbind:
1835
+ self.text_editor.tktext.unbind(binding)
1832
1836
  self.itemconfig(self.text_editor.canvas_id, state="hidden")
1833
1837
  self.text_editor.open = False
1834
1838
  if reason == "Escape":
@@ -1862,6 +1866,7 @@ class ColumnHeaders(tk.Canvas):
1862
1866
  key=editor_info[1] if len(editor_info) >= 2 else "FocusOut",
1863
1867
  value=text_editor_value,
1864
1868
  loc=c,
1869
+ column=c,
1865
1870
  boxes=self.MT.get_boxes(),
1866
1871
  selected=self.MT.selected,
1867
1872
  )
@@ -1970,6 +1975,7 @@ class ColumnHeaders(tk.Canvas):
1970
1975
  sheet=self.PAR.name,
1971
1976
  value=self.text_editor.get(),
1972
1977
  loc=c,
1978
+ column=c,
1973
1979
  boxes=self.MT.get_boxes(),
1974
1980
  selected=self.MT.selected,
1975
1981
  ),
@@ -2005,6 +2011,7 @@ class ColumnHeaders(tk.Canvas):
2005
2011
  key="??",
2006
2012
  value=selection,
2007
2013
  loc=c,
2014
+ column=c,
2008
2015
  boxes=self.MT.get_boxes(),
2009
2016
  selected=self.MT.selected,
2010
2017
  )
@@ -2230,6 +2237,7 @@ class ColumnHeaders(tk.Canvas):
2230
2237
  key="??",
2231
2238
  value=value,
2232
2239
  loc=c,
2240
+ column=c,
2233
2241
  boxes=self.MT.get_boxes(),
2234
2242
  selected=self.MT.selected,
2235
2243
  )
tksheet/functions.py CHANGED
@@ -102,6 +102,8 @@ def event_dict(
102
102
  key: None | str = None,
103
103
  value: object = None,
104
104
  loc: None | int | tuple[int] = None,
105
+ row: None | int = None,
106
+ column: None | int = None,
105
107
  resized_rows: None | dict = None,
106
108
  resized_columns: None | dict = None,
107
109
  # resized_index: None, dict] = None,
@@ -147,6 +149,8 @@ def event_dict(
147
149
  key="" if key is None else key,
148
150
  value=None if value is None else value,
149
151
  loc=tuple() if loc is None else loc,
152
+ row=row,
153
+ column=column,
150
154
  resized=DotDict(
151
155
  rows=DotDict() if resized_rows is None else resized_rows,
152
156
  columns=DotDict() if resized_columns is None else resized_columns,
@@ -403,8 +407,8 @@ def index_exists(seq: Sequence[object], index: int) -> bool:
403
407
 
404
408
  def move_elements_by_mapping(
405
409
  seq: list[object],
406
- new_idxs: dict,
407
- old_idxs: dict,
410
+ new_idxs: dict[int, int],
411
+ old_idxs: dict[int, int],
408
412
  ) -> list[object]:
409
413
  # move elements of a list around, displacing
410
414
  # other elements based on mapping
@@ -472,8 +476,7 @@ def get_new_indexes(
472
476
 
473
477
 
474
478
  def insert_items(seq: list | tuple, to_insert: dict, seq_len_func: Callable | None = None) -> list:
475
- # faster method of inserting many items into a list
476
- # using a dict of reverse sorted order of
479
+ # inserts many items into a list using a dict of reverse sorted order of
477
480
  # {index: value, index: value, ...}
478
481
  res = []
479
482
  extended = 0
tksheet/main_table.py CHANGED
@@ -26,7 +26,6 @@ from itertools import (
26
26
  chain,
27
27
  cycle,
28
28
  islice,
29
- product,
30
29
  repeat,
31
30
  )
32
31
  from math import (
@@ -56,7 +55,6 @@ from .functions import (
56
55
  ev_stack_dict,
57
56
  event_dict,
58
57
  gen_formatted,
59
- rounded_box_coords,
60
58
  get_new_indexes,
61
59
  get_seq_without_gaps_at_index,
62
60
  index_exists,
@@ -67,10 +65,11 @@ from .functions import (
67
65
  len_to_idx,
68
66
  mod_event_val,
69
67
  mod_span,
68
+ mod_span_widget,
70
69
  move_elements_by_mapping,
71
70
  pickle_obj,
71
+ rounded_box_coords,
72
72
  span_idxs_post_move,
73
- mod_span_widget,
74
73
  try_binding,
75
74
  unpickle_obj,
76
75
  )
@@ -82,6 +81,7 @@ from .other_classes import (
82
81
  DropdownStorage,
83
82
  EventDataDict,
84
83
  FontTuple,
84
+ Loc,
85
85
  Selected,
86
86
  SelectionBox,
87
87
  TextEditorStorage,
@@ -94,6 +94,7 @@ from .vars import (
94
94
  ctrl_key,
95
95
  rc_binding,
96
96
  symbols_set,
97
+ text_editor_to_unbind,
97
98
  val_modifying_options,
98
99
  )
99
100
 
@@ -675,7 +676,7 @@ class MainTable(tk.Canvas):
675
676
  if lastbox_numrows > new_data_numrows and not lastbox_numrows % new_data_numrows:
676
677
  nd = []
677
678
  for _ in range(int(lastbox_numrows / new_data_numrows)):
678
- nd.extend([r.copy() for r in data])
679
+ nd.extend(r.copy() for r in data)
679
680
  data.extend(nd)
680
681
  new_data_numrows *= int(lastbox_numrows / new_data_numrows)
681
682
 
@@ -971,14 +972,14 @@ class MainTable(tk.Canvas):
971
972
  run_binding=True,
972
973
  )
973
974
  if move_data:
974
- self.data[:] = [
975
- move_elements_by_mapping(
976
- r,
977
- data_new_idxs,
978
- data_old_idxs,
979
- )
980
- for r in self.data
981
- ]
975
+ self.data = list(
976
+ map(
977
+ move_elements_by_mapping,
978
+ self.data,
979
+ repeat(data_new_idxs),
980
+ repeat(data_old_idxs),
981
+ ),
982
+ )
982
983
  maxidx = len_to_idx(totalcols)
983
984
  self.CH.fix_header(maxidx)
984
985
  if isinstance(self._headers, list) and self._headers:
@@ -1195,7 +1196,7 @@ class MainTable(tk.Canvas):
1195
1196
  run_binding=True,
1196
1197
  )
1197
1198
  if move_data:
1198
- self.data[:] = move_elements_by_mapping(
1199
+ self.data = move_elements_by_mapping(
1199
1200
  self.data,
1200
1201
  data_new_idxs,
1201
1202
  data_old_idxs,
@@ -3213,39 +3214,30 @@ class MainTable(tk.Canvas):
3213
3214
  # continue
3214
3215
 
3215
3216
  def set_xviews(self, *args, move_synced: bool = True, redraw: bool = True) -> None:
3217
+ self.main_table_redraw_grid_and_text(setting_views=True)
3218
+ self.update_idletasks()
3216
3219
  self.xview(*args)
3217
3220
  if self.show_header:
3218
3221
  self.CH.xview(*args)
3219
3222
  if move_synced:
3220
3223
  self.x_move_synced_scrolls(*args)
3221
3224
  self.fix_views()
3222
- if redraw:
3223
- self.main_table_redraw_grid_and_text(redraw_header=True if self.show_header else False)
3225
+ self.PAR.set_refresh_timer(redraw)
3224
3226
 
3225
3227
  def set_yviews(self, *args, move_synced: bool = True, redraw: bool = True) -> None:
3228
+ self.main_table_redraw_grid_and_text(setting_views=True)
3229
+ self.update_idletasks()
3226
3230
  self.yview(*args)
3227
3231
  if self.show_index:
3228
3232
  self.RI.yview(*args)
3229
3233
  if move_synced:
3230
3234
  self.y_move_synced_scrolls(*args)
3231
3235
  self.fix_views()
3232
- if redraw:
3233
- self.main_table_redraw_grid_and_text(redraw_row_index=True if self.show_index else False)
3236
+ self.PAR.set_refresh_timer(redraw)
3234
3237
 
3235
3238
  def set_view(self, x_args: list[str, float], y_args: list[str, float]) -> None:
3236
- self.xview(*x_args)
3237
- if self.show_header:
3238
- self.CH.xview(*x_args)
3239
- self.yview(*y_args)
3240
- if self.show_index:
3241
- self.RI.yview(*y_args)
3242
- self.x_move_synced_scrolls(*x_args)
3243
- self.y_move_synced_scrolls(*y_args)
3244
- self.fix_views()
3245
- self.main_table_redraw_grid_and_text(
3246
- redraw_row_index=True if self.show_index else False,
3247
- redraw_header=True if self.show_header else False,
3248
- )
3239
+ self.set_xviews(*x_args)
3240
+ self.set_yviews(*y_args)
3249
3241
 
3250
3242
  def mousewheel(self, event: object) -> None:
3251
3243
  if event.delta < 0 or event.num == 5:
@@ -4893,7 +4885,7 @@ class MainTable(tk.Canvas):
4893
4885
  if total_rows is not None:
4894
4886
  if len(self.data) < total_rows:
4895
4887
  ncols = self.total_data_cols() if total_columns is None else total_columns
4896
- self.data.extend([self.get_empty_row_seq(r, ncols) for r in range(total_rows - len(self.data))])
4888
+ self.data.extend(self.get_empty_row_seq(r, ncols) for r in range(total_rows - len(self.data)))
4897
4889
  else:
4898
4890
  self.data[total_rows:] = []
4899
4891
  if total_columns is not None:
@@ -5193,6 +5185,7 @@ class MainTable(tk.Canvas):
5193
5185
  redraw_header: bool = False,
5194
5186
  redraw_row_index: bool = False,
5195
5187
  redraw_table: bool = True,
5188
+ setting_views: bool = False,
5196
5189
  ) -> bool:
5197
5190
  try:
5198
5191
  can_width = self.winfo_width()
@@ -5286,6 +5279,8 @@ class MainTable(tk.Canvas):
5286
5279
  if scrollregion != self.scrollregion:
5287
5280
  self.configure(scrollregion=scrollregion)
5288
5281
  self.scrollregion = scrollregion
5282
+ if setting_views:
5283
+ return False
5289
5284
  scrollpos_bot = self.canvasy(can_height)
5290
5285
  end_row = bisect_right(self.row_positions, scrollpos_bot)
5291
5286
  if not scrollpos_bot >= self.row_positions[-1]:
@@ -5765,8 +5760,8 @@ class MainTable(tk.Canvas):
5765
5760
  fill, outline = self.get_selected_box_bg_fg(type_=type_)
5766
5761
  x1 = self.col_positions[c] + 1
5767
5762
  y1 = self.row_positions[r] + 1
5768
- x2 = self.col_positions[c + 1] if index_exists(self.col_positions, c + 1) else self.col_positions[c]
5769
- y2 = self.row_positions[r + 1] if index_exists(self.row_positions, r + 1) else self.row_positions[r]
5763
+ x2 = self.col_positions[c + 1] if index_exists(self.col_positions, c + 1) else self.col_positions[c] + 1
5764
+ y2 = self.row_positions[r + 1] if index_exists(self.row_positions, r + 1) else self.row_positions[r] + 1
5770
5765
  self.hide_selected()
5771
5766
  if self.PAR.ops.show_selected_cells_border:
5772
5767
  fill = ""
@@ -5809,12 +5804,16 @@ class MainTable(tk.Canvas):
5809
5804
  width: int,
5810
5805
  iid: None | int = None,
5811
5806
  ) -> int:
5807
+ if not self.PAR.ops.rounded_boxes or not x2 - x1 or not y2 - y1:
5808
+ radius = 0
5809
+ else:
5810
+ radius = 8
5812
5811
  coords = rounded_box_coords(
5813
5812
  x1,
5814
5813
  y1,
5815
5814
  x2,
5816
5815
  y2,
5817
- radius=9 if self.PAR.ops.rounded_boxes else 0,
5816
+ radius=radius,
5818
5817
  )
5819
5818
  if isinstance(iid, int):
5820
5819
  self.itemconfig(iid, fill=fill, outline=outline, state=state, tags=tags, width=width)
@@ -5844,7 +5843,7 @@ class MainTable(tk.Canvas):
5844
5843
  self.itemconfig(item, state="hidden")
5845
5844
 
5846
5845
  def hide_selection_box(self, item: int | None, set_current: bool = True) -> bool:
5847
- if item is None:
5846
+ if item is None or item is True:
5848
5847
  return
5849
5848
  box = self.selection_boxes.pop(item)
5850
5849
  self.hide_box(box.fill_iid)
@@ -6048,7 +6047,7 @@ class MainTable(tk.Canvas):
6048
6047
  tags="cells" if type_ == "rows" else type_,
6049
6048
  iid=self.selection_boxes[fill_iid].header,
6050
6049
  )
6051
- if (bd_iid := self.selection_boxes[fill_iid].bd_iid):
6050
+ if bd_iid := self.selection_boxes[fill_iid].bd_iid:
6052
6051
  if self.PAR.ops.show_selected_cells_border:
6053
6052
  self.display_box(
6054
6053
  x1,
@@ -6147,168 +6146,62 @@ class MainTable(tk.Canvas):
6147
6146
  def get_selected_rows(
6148
6147
  self,
6149
6148
  get_cells: bool = False,
6150
- within_range: tuple | None = None,
6151
6149
  get_cells_as_rows: bool = False,
6152
6150
  ) -> set[int] | set[tuple[int, int]]:
6153
- s = set()
6154
- if within_range is not None:
6155
- within_r1 = within_range[0]
6156
- within_r2 = within_range[1]
6157
6151
  if get_cells:
6158
- if within_range is None:
6159
- for item, box in self.get_selection_items(cells=False, columns=False):
6160
- r1, c1, r2, c2 = box.coords
6161
- s.update(set(product(range(r1, r2), range(0, len(self.col_positions) - 1))))
6162
- if get_cells_as_rows:
6163
- s.update(self.get_selected_cells())
6164
- else:
6165
- for item, box in self.get_selection_items(cells=False, columns=False):
6166
- r1, c1, r2, c2 = box.coords
6167
- if r1 >= within_r1 or r2 <= within_r2:
6168
- s.update(
6169
- set(
6170
- product(
6171
- range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2),
6172
- range(0, len(self.col_positions) - 1),
6173
- )
6174
- )
6175
- )
6176
- if get_cells_as_rows:
6177
- s.update(
6178
- self.get_selected_cells(
6179
- within_range=(
6180
- within_r1,
6181
- 0,
6182
- within_r2,
6183
- len(self.col_positions) - 1,
6184
- )
6185
- )
6186
- )
6152
+ s = {
6153
+ (r, c)
6154
+ for item, box in self.get_selection_items(cells=False, columns=False)
6155
+ for r in range(box.coords.from_r, box.coords.upto_r)
6156
+ for c in range(0, len(self.col_positions) - 1)
6157
+ }
6158
+ if get_cells_as_rows:
6159
+ return s | self.get_selected_cells()
6187
6160
  else:
6188
- if within_range is None:
6189
- for item, box in self.get_selection_items(cells=False, columns=False):
6190
- r1, c1, r2, c2 = box.coords
6191
- s.update(set(range(r1, r2)))
6192
- if get_cells_as_rows:
6193
- s.update(set(tup[0] for tup in self.get_selected_cells()))
6194
- else:
6195
- for item, box in self.get_selection_items(cells=False, columns=False):
6196
- r1, c1, r2, c2 = box.coords
6197
- if r1 >= within_r1 or r2 <= within_r2:
6198
- s.update(set(range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2)))
6199
- if get_cells_as_rows:
6200
- s.update(
6201
- set(
6202
- tup[0]
6203
- for tup in self.get_selected_cells(
6204
- within_range=(
6205
- within_r1,
6206
- 0,
6207
- within_r2,
6208
- len(self.col_positions) - 1,
6209
- )
6210
- )
6211
- )
6212
- )
6161
+ s = {
6162
+ r
6163
+ for item, box in self.get_selection_items(cells=False, columns=False)
6164
+ for r in range(box.coords.from_r, box.coords.upto_r)
6165
+ }
6166
+ if get_cells_as_rows:
6167
+ return s | set(tup[0] for tup in self.get_selected_cells())
6213
6168
  return s
6214
6169
 
6215
6170
  def get_selected_cols(
6216
6171
  self,
6217
6172
  get_cells: bool = False,
6218
- within_range: tuple | None = None,
6219
6173
  get_cells_as_cols: bool = False,
6220
6174
  ) -> set[int] | set[tuple[int, int]]:
6221
- s = set()
6222
- if within_range is not None:
6223
- within_c1 = within_range[0]
6224
- within_c2 = within_range[1]
6225
6175
  if get_cells:
6226
- if within_range is None:
6227
- for item, box in self.get_selection_items(cells=False, rows=False):
6228
- r1, c1, r2, c2 = box.coords
6229
- s.update(set(product(range(c1, c2), range(0, len(self.row_positions) - 1))))
6230
- if get_cells_as_cols:
6231
- s.update(self.get_selected_cells())
6232
- else:
6233
- for item, box in self.get_selection_items(cells=False, rows=False):
6234
- r1, c1, r2, c2 = box.coords
6235
- if c1 >= within_c1 or c2 <= within_c2:
6236
- s.update(
6237
- set(
6238
- product(
6239
- range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2),
6240
- range(0, len(self.row_positions) - 1),
6241
- )
6242
- )
6243
- )
6244
- if get_cells_as_cols:
6245
- s.update(
6246
- self.get_selected_cells(
6247
- within_range=(
6248
- 0,
6249
- within_c1,
6250
- len(self.row_positions) - 1,
6251
- within_c2,
6252
- )
6253
- )
6254
- )
6176
+ s = {
6177
+ (r, c)
6178
+ for item, box in self.get_selection_items(cells=False, rows=False)
6179
+ for r in range(0, len(self.row_positions) - 1)
6180
+ for c in range(box.coords.from_c, box.coords.upto_c)
6181
+ }
6182
+ if get_cells_as_cols:
6183
+ return s | self.get_selected_cells()
6255
6184
  else:
6256
- if within_range is None:
6257
- for item, box in self.get_selection_items(cells=False, rows=False):
6258
- r1, c1, r2, c2 = box.coords
6259
- s.update(set(range(c1, c2)))
6260
- if get_cells_as_cols:
6261
- s.update(set(tup[1] for tup in self.get_selected_cells()))
6262
- else:
6263
- for item in self.get_selection_items(cells=False, rows=False):
6264
- r1, c1, r2, c2 = box.coords
6265
- if c1 >= within_c1 or c2 <= within_c2:
6266
- s.update(set(range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2)))
6267
- if get_cells_as_cols:
6268
- s.update(
6269
- set(
6270
- tup[0]
6271
- for tup in self.get_selected_cells(
6272
- within_range=(
6273
- 0,
6274
- within_c1,
6275
- len(self.row_positions) - 1,
6276
- within_c2,
6277
- )
6278
- )
6279
- )
6280
- )
6185
+ s = {
6186
+ c
6187
+ for item, box in self.get_selection_items(cells=False, rows=False)
6188
+ for c in range(box.coords.from_c, box.coords.upto_c)
6189
+ }
6190
+ if get_cells_as_cols:
6191
+ return s | set(tup[1] for tup in self.get_selected_cells())
6281
6192
  return s
6282
6193
 
6283
6194
  def get_selected_cells(
6284
6195
  self,
6285
6196
  get_rows: bool = False,
6286
6197
  get_cols: bool = False,
6287
- within_range: bool = None,
6288
6198
  ) -> set[tuple[int, int]]:
6289
- s = set()
6290
- if within_range is not None:
6291
- within_r1 = within_range[0]
6292
- within_c1 = within_range[1]
6293
- within_r2 = within_range[2]
6294
- within_c2 = within_range[3]
6295
- if within_range is None:
6296
- for item, box in self.get_selection_items(rows=get_rows, columns=get_cols):
6297
- r1, c1, r2, c2 = box.coords
6298
- s.update(set(product(range(r1, r2), range(c1, c2))))
6299
- else:
6300
- for item in self.get_selection_items(rows=get_rows, columns=get_cols):
6301
- r1, c1, r2, c2 = box.coords
6302
- if r1 >= within_r1 or c1 >= within_c1 or r2 <= within_r2 or c2 <= within_c2:
6303
- s.update(
6304
- set(
6305
- product(
6306
- range(r1 if r1 > within_r1 else within_r1, r2 if r2 < within_r2 else within_r2),
6307
- range(c1 if c1 > within_c1 else within_c1, c2 if c2 < within_c2 else within_c2),
6308
- )
6309
- )
6310
- )
6311
- return s
6199
+ return {
6200
+ (r, c)
6201
+ for item, box in self.get_selection_items(rows=get_rows, columns=get_cols)
6202
+ for r in range(box.coords.from_r, box.coords.upto_r)
6203
+ for c in range(box.coords.from_c, box.coords.upto_c)
6204
+ }
6312
6205
 
6313
6206
  def get_all_selection_boxes(self) -> tuple[tuple[int, int, int, int]]:
6314
6207
  return tuple(box.coords for item, box in self.get_selection_items())
@@ -6469,7 +6362,9 @@ class MainTable(tk.Canvas):
6469
6362
  sheet=self.PAR.name,
6470
6363
  key=extra_func_key,
6471
6364
  value=text,
6472
- loc=(r, c),
6365
+ loc=Loc(r, c),
6366
+ row=r,
6367
+ column=c,
6473
6368
  boxes=self.get_boxes(),
6474
6369
  selected=self.selected,
6475
6370
  )
@@ -6532,12 +6427,14 @@ class MainTable(tk.Canvas):
6532
6427
  self.text_editor.tktext.focus_set()
6533
6428
  self.text_editor.window.scroll_to_bottom()
6534
6429
  self.text_editor.tktext.bind("<Alt-Return>", lambda _x: self.text_editor_newline_binding(r, c))
6430
+ self.text_editor.tktext.bind("<Alt-KP_Enter>", lambda _x: self.text_editor_newline_binding(r, c))
6535
6431
  if USER_OS == "darwin":
6536
6432
  self.text_editor.tktext.bind("<Option-Return>", lambda _x: self.text_editor_newline_binding(r, c))
6537
6433
  for key, func in self.text_editor_user_bound_keys.items():
6538
6434
  self.text_editor.tktext.bind(key, func)
6539
6435
  self.text_editor.tktext.bind("<Tab>", lambda _x: self.close_text_editor((r, c, "Tab")))
6540
6436
  self.text_editor.tktext.bind("<Return>", lambda _x: self.close_text_editor((r, c, "Return")))
6437
+ self.text_editor.tktext.bind("<KP_Enter>", lambda _x: self.close_text_editor((r, c, "Return")))
6541
6438
  if not dropdown:
6542
6439
  self.text_editor.tktext.bind("<FocusOut>", lambda _x: self.close_text_editor((r, c, "FocusOut")))
6543
6440
  self.text_editor.tktext.bind("<Escape>", lambda _x: self.close_text_editor((r, c, "Escape")))
@@ -6627,8 +6524,8 @@ class MainTable(tk.Canvas):
6627
6524
 
6628
6525
  def hide_text_editor(self, reason: None | str = None) -> None:
6629
6526
  if self.text_editor.open:
6630
- for b in ("<Alt-Return>", "<Option-Return>", "<Tab>", "<Return>", "<FocusOut>", "<Escape>"):
6631
- self.text_editor.tktext.unbind(b)
6527
+ for binding in text_editor_to_unbind:
6528
+ self.text_editor.tktext.unbind(binding)
6632
6529
  self.itemconfig(self.text_editor.canvas_id, state="hidden")
6633
6530
  self.text_editor.open = False
6634
6531
  if reason == "Escape":
@@ -6660,7 +6557,9 @@ class MainTable(tk.Canvas):
6660
6557
  cells_table={(datarn, datacn): text_editor_value},
6661
6558
  key=editor_info[2],
6662
6559
  value=text_editor_value,
6663
- loc=(r, c),
6560
+ loc=Loc(r, c),
6561
+ row=r,
6562
+ column=c,
6664
6563
  boxes=self.get_boxes(),
6665
6564
  selected=self.selected,
6666
6565
  )
@@ -6911,7 +6810,9 @@ class MainTable(tk.Canvas):
6911
6810
  name="table_dropdown_modified",
6912
6811
  sheet=self.PAR.name,
6913
6812
  value=self.text_editor.get(),
6914
- loc=(r, c),
6813
+ loc=Loc(r, c),
6814
+ row=r,
6815
+ column=c,
6915
6816
  boxes=self.get_boxes(),
6916
6817
  selected=self.selected,
6917
6818
  )
@@ -6954,7 +6855,9 @@ class MainTable(tk.Canvas):
6954
6855
  cells_table={(datarn, datacn): pre_edit_value},
6955
6856
  key="??",
6956
6857
  value=selection,
6957
- loc=(r, c),
6858
+ loc=Loc(r, c),
6859
+ row=r,
6860
+ column=c,
6958
6861
  boxes=self.get_boxes(),
6959
6862
  selected=self.selected,
6960
6863
  )
@@ -7042,7 +6945,9 @@ class MainTable(tk.Canvas):
7042
6945
  cells_table={(datarn, datacn): pre_edit_value},
7043
6946
  key="??",
7044
6947
  value=value,
7045
- loc=(r, c),
6948
+ loc=Loc(r, c),
6949
+ row=r,
6950
+ column=c,
7046
6951
  boxes=self.get_boxes(),
7047
6952
  selected=self.selected,
7048
6953
  )
@@ -7161,7 +7066,7 @@ class MainTable(tk.Canvas):
7161
7066
 
7162
7067
  def fix_data_len(self, datarn: int, datacn: int | None = None) -> int:
7163
7068
  ncols = self.total_data_cols() if datacn is None else datacn + 1
7164
- self.data.extend([self.get_empty_row_seq(rn, end=ncols, start=0) for rn in range(len(self.data), datarn + 1)])
7069
+ self.data.extend(self.get_empty_row_seq(rn, end=ncols, start=0) for rn in range(len(self.data), datarn + 1))
7165
7070
  return len(self.data)
7166
7071
 
7167
7072
  def reapply_formatting(self) -> None:
tksheet/other_classes.py CHANGED
@@ -17,10 +17,8 @@ Box_t = namedtuple(
17
17
  "Box_t",
18
18
  "from_r from_c upto_r upto_c type_",
19
19
  )
20
- Box_st = namedtuple(
21
- "Box_st",
22
- "coords type_"
23
- )
20
+ Box_st = namedtuple("Box_st", "coords type_")
21
+ Loc = namedtuple("Loc", "row column")
24
22
 
25
23
  Highlight = namedtuple(
26
24
  "Highlight",
@@ -472,4 +470,3 @@ Selected = namedtuple(
472
470
  None,
473
471
  ),
474
472
  )
475
-
tksheet/row_index.py CHANGED
@@ -31,10 +31,10 @@ from .functions import (
31
31
  consecutive_chunks,
32
32
  ev_stack_dict,
33
33
  event_dict,
34
- rounded_box_coords,
35
34
  get_n2a,
36
35
  is_contiguous,
37
36
  num2alpha,
37
+ rounded_box_coords,
38
38
  try_binding,
39
39
  )
40
40
  from .other_classes import (
@@ -51,6 +51,7 @@ from .vars import (
51
51
  USER_OS,
52
52
  rc_binding,
53
53
  symbols_set,
54
+ text_editor_to_unbind,
54
55
  )
55
56
 
56
57
 
@@ -965,7 +966,7 @@ class RowIndex(tk.Canvas):
965
966
  y1,
966
967
  x2,
967
968
  y2,
968
- radius=9 if self.PAR.ops.rounded_boxes else 0,
969
+ radius=8 if self.PAR.ops.rounded_boxes else 0,
969
970
  )
970
971
  if isinstance(iid, int):
971
972
  self.coords(iid, coords)
@@ -1755,6 +1756,7 @@ class RowIndex(tk.Canvas):
1755
1756
  key=extra_func_key,
1756
1757
  value=text,
1757
1758
  loc=r,
1759
+ row=r,
1758
1760
  boxes=self.MT.get_boxes(),
1759
1761
  selected=self.MT.selected,
1760
1762
  )
@@ -1816,12 +1818,14 @@ class RowIndex(tk.Canvas):
1816
1818
  self.text_editor.tktext.focus_set()
1817
1819
  self.text_editor.window.scroll_to_bottom()
1818
1820
  self.text_editor.tktext.bind("<Alt-Return>", lambda _x: self.text_editor_newline_binding(r=r))
1821
+ self.text_editor.tktext.bind("<Alt-KP_Enter>", lambda _x: self.text_editor_newline_binding(r=r))
1819
1822
  if USER_OS == "darwin":
1820
1823
  self.text_editor.tktext.bind("<Option-Return>", lambda _x: self.text_editor_newline_binding(r=r))
1821
1824
  for key, func in self.MT.text_editor_user_bound_keys.items():
1822
1825
  self.text_editor.tktext.bind(key, func)
1823
1826
  self.text_editor.tktext.bind("<Tab>", lambda _x: self.close_text_editor((r, "Tab")))
1824
1827
  self.text_editor.tktext.bind("<Return>", lambda _x: self.close_text_editor((r, "Return")))
1828
+ self.text_editor.tktext.bind("<KP_Enter>", lambda _x: self.close_text_editor((r, "Return")))
1825
1829
  if not dropdown:
1826
1830
  self.text_editor.tktext.bind("<FocusOut>", lambda _x: self.close_text_editor((r, "FocusOut")))
1827
1831
  self.text_editor.tktext.bind("<Escape>", lambda _x: self.close_text_editor((r, "Escape")))
@@ -1909,8 +1913,8 @@ class RowIndex(tk.Canvas):
1909
1913
 
1910
1914
  def hide_text_editor(self, reason: None | str = None) -> None:
1911
1915
  if self.text_editor.open:
1912
- for b in ("<Alt-Return>", "<Option-Return>", "<Tab>", "<Return>", "<FocusOut>", "<Escape>"):
1913
- self.text_editor.tktext.unbind(b)
1916
+ for binding in text_editor_to_unbind:
1917
+ self.text_editor.tktext.unbind(binding)
1914
1918
  self.itemconfig(self.text_editor.canvas_id, state="hidden")
1915
1919
  self.text_editor.open = False
1916
1920
  if reason == "Escape":
@@ -1942,6 +1946,7 @@ class RowIndex(tk.Canvas):
1942
1946
  key=editor_info[1] if len(editor_info) >= 2 else "FocusOut",
1943
1947
  value=text_editor_value,
1944
1948
  loc=r,
1949
+ row=r,
1945
1950
  boxes=self.MT.get_boxes(),
1946
1951
  selected=self.MT.selected,
1947
1952
  )
@@ -2064,6 +2069,7 @@ class RowIndex(tk.Canvas):
2064
2069
  sheet=self.PAR.name,
2065
2070
  value=self.text_editor.get(),
2066
2071
  loc=r,
2072
+ row=r,
2067
2073
  boxes=self.MT.get_boxes(),
2068
2074
  selected=self.MT.selected,
2069
2075
  ),
@@ -2100,6 +2106,7 @@ class RowIndex(tk.Canvas):
2100
2106
  key="??",
2101
2107
  value=selection,
2102
2108
  loc=r,
2109
+ row=r,
2103
2110
  boxes=self.MT.get_boxes(),
2104
2111
  selected=self.MT.selected,
2105
2112
  )
@@ -2322,6 +2329,7 @@ class RowIndex(tk.Canvas):
2322
2329
  key="??",
2323
2330
  value=value,
2324
2331
  loc=r,
2332
+ row=r,
2325
2333
  boxes=self.MT.get_boxes(),
2326
2334
  selected=self.MT.selected,
2327
2335
  )
tksheet/sheet.py CHANGED
@@ -8,7 +8,6 @@ from itertools import accumulate, chain, islice, product
8
8
  from timeit import default_timer
9
9
  from tkinter import ttk
10
10
  from typing import Literal
11
- from warnings import warn as WARNING
12
11
 
13
12
  from .column_headers import ColumnHeaders
14
13
  from .functions import (
@@ -46,8 +45,8 @@ from .other_classes import (
46
45
  FontTuple,
47
46
  GeneratedMouseEvent,
48
47
  Node,
49
- Span,
50
48
  Selected,
49
+ Span,
51
50
  )
52
51
  from .row_index import RowIndex
53
52
  from .sheet_options import (
@@ -272,9 +271,6 @@ class Sheet(tk.Frame):
272
271
  highlightbackground=outline_color,
273
272
  highlightcolor=outline_color,
274
273
  )
275
- WARNING(
276
- "There have been many changes from tksheet version 6.x.x to version 7.x.x. Please see the changelog for more information."
277
- )
278
274
  self.ops = new_sheet_options()
279
275
  if column_width is not None:
280
276
  default_column_width = column_width
@@ -614,7 +610,7 @@ class Sheet(tk.Frame):
614
610
  for b, f in iterable:
615
611
  b = b.lower()
616
612
 
617
- if func is not None and b in emitted_events:
613
+ if f is not None and b in emitted_events:
618
614
  self.bind(b, f)
619
615
 
620
616
  if b in (
@@ -1357,16 +1353,14 @@ class Sheet(tk.Frame):
1357
1353
  if header:
1358
1354
  if table:
1359
1355
  res.extend(
1360
- [
1361
- [quick_hdata(c, get_displayed=hdisp)]
1362
- + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows]
1363
- for c in cols
1364
- ]
1356
+ [quick_hdata(c, get_displayed=hdisp)]
1357
+ + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows]
1358
+ for c in cols
1365
1359
  )
1366
1360
  else:
1367
- res.extend([[quick_hdata(c, get_displayed=hdisp)] for c in cols])
1361
+ res.extend([quick_hdata(c, get_displayed=hdisp)] for c in cols)
1368
1362
  elif table:
1369
- res.extend([[quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows] for c in cols])
1363
+ res.extend([quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows] for c in cols)
1370
1364
  elif not span.transposed:
1371
1365
  if header:
1372
1366
  if header and index:
@@ -1379,16 +1373,14 @@ class Sheet(tk.Frame):
1379
1373
  if index:
1380
1374
  if table:
1381
1375
  res.extend(
1382
- [
1383
- [quick_idata(r, get_displayed=idisp)]
1384
- + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols]
1385
- for r in rows
1386
- ]
1376
+ [quick_idata(r, get_displayed=idisp)]
1377
+ + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols]
1378
+ for r in rows
1387
1379
  )
1388
1380
  else:
1389
- res.extend([[quick_idata(r, get_displayed=idisp)] for r in rows])
1381
+ res.extend([quick_idata(r, get_displayed=idisp)] for r in rows)
1390
1382
  elif table:
1391
- res.extend([[quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols] for r in rows])
1383
+ res.extend([quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols] for r in rows)
1392
1384
  if not span.ndim:
1393
1385
  # it's a cell
1394
1386
  if len(res) == 1 and len(res[0]) == 1:
@@ -1521,7 +1513,7 @@ class Sheet(tk.Frame):
1521
1513
  )
1522
1514
 
1523
1515
  @data.setter
1524
- def data(self, value):
1516
+ def data(self, value: list[list[object]]) -> None:
1525
1517
  self.data_reference(value)
1526
1518
 
1527
1519
  def set_data(
@@ -2850,12 +2842,7 @@ class Sheet(tk.Frame):
2850
2842
  self.set_refresh_timer(redraw)
2851
2843
  return self
2852
2844
 
2853
- def index_align(
2854
- self,
2855
- align: str = None,
2856
- redraw: bool = True,
2857
- ) -> str | Sheet:
2858
- return self.row_index_align(align, redraw)
2845
+ index_align = row_index_align
2859
2846
 
2860
2847
  def align(
2861
2848
  self,
@@ -2913,12 +2900,25 @@ class Sheet(tk.Frame):
2913
2900
  def selected(self) -> tuple[()] | Selected:
2914
2901
  return self.MT.selected
2915
2902
 
2903
+ @selected.setter
2904
+ def selected(self, selected: tuple[()] | Selected) -> Sheet:
2905
+ if selected:
2906
+ self.MT.set_currently_selected(
2907
+ r=selected[0],
2908
+ c=selected[1],
2909
+ item=selected[4],
2910
+ box=selected[3],
2911
+ )
2912
+ else:
2913
+ self.MT.deselect()
2914
+ return self
2915
+
2916
2916
  def get_selected_rows(
2917
2917
  self,
2918
2918
  get_cells: bool = False,
2919
2919
  get_cells_as_rows: bool = False,
2920
2920
  return_tuple: bool = False,
2921
- ) -> tuple | set:
2921
+ ) -> tuple[int] | tuple[tuple[int, int]] | set[int] | set[tuple[int, int]]:
2922
2922
  if return_tuple:
2923
2923
  return tuple(self.MT.get_selected_rows(get_cells=get_cells, get_cells_as_rows=get_cells_as_rows))
2924
2924
  return self.MT.get_selected_rows(get_cells=get_cells, get_cells_as_rows=get_cells_as_rows)
@@ -2928,7 +2928,7 @@ class Sheet(tk.Frame):
2928
2928
  get_cells: bool = False,
2929
2929
  get_cells_as_columns: bool = False,
2930
2930
  return_tuple: bool = False,
2931
- ) -> tuple | set:
2931
+ ) -> tuple[int] | tuple[tuple[int, int]] | set[int] | set[tuple[int, int]]:
2932
2932
  if return_tuple:
2933
2933
  return tuple(self.MT.get_selected_cols(get_cells=get_cells, get_cells_as_cols=get_cells_as_columns))
2934
2934
  return self.MT.get_selected_cols(get_cells=get_cells, get_cells_as_cols=get_cells_as_columns)
@@ -2939,7 +2939,7 @@ class Sheet(tk.Frame):
2939
2939
  get_columns: bool = False,
2940
2940
  sort_by_row: bool = False,
2941
2941
  sort_by_column: bool = False,
2942
- ) -> list | set:
2942
+ ) -> list[tuple[int, int]] | set[tuple[int, int]]:
2943
2943
  if sort_by_row and sort_by_column:
2944
2944
  sels = sorted(
2945
2945
  self.MT.get_selected_cells(get_rows=get_rows, get_cols=get_columns),
@@ -2968,6 +2968,14 @@ class Sheet(tk.Frame):
2968
2968
  def boxes(self) -> list[tuple[tuple[int, int, int, int], str]]:
2969
2969
  return self.MT.get_all_selection_boxes_with_types()
2970
2970
 
2971
+ @boxes.setter
2972
+ def boxes(self, boxes: Sequence[tuple[tuple[int, int, int, int], str]]) -> Sheet:
2973
+ self.MT.deselect()
2974
+ self.MT.reselect_from_get_boxes(
2975
+ boxes={box[0] if isinstance(box[0], tuple) else tuple(box[0]): box[1] for box in boxes}
2976
+ )
2977
+ return self
2978
+
2971
2979
  def cell_selected(
2972
2980
  self,
2973
2981
  r: int,
@@ -3023,7 +3031,7 @@ class Sheet(tk.Frame):
3023
3031
 
3024
3032
  def select_row(self, row: int, redraw: bool = True, run_binding_func: bool = True) -> Sheet:
3025
3033
  self.RI.select_row(
3026
- int(row) if not isinstance(row, int) else row,
3034
+ row if isinstance(row, int) else int(row),
3027
3035
  redraw=False,
3028
3036
  run_binding_func=run_binding_func,
3029
3037
  )
@@ -3032,7 +3040,7 @@ class Sheet(tk.Frame):
3032
3040
 
3033
3041
  def select_column(self, column: int, redraw: bool = True, run_binding_func: bool = True) -> Sheet:
3034
3042
  self.CH.select_col(
3035
- int(column) if not isinstance(column, int) else column,
3043
+ column if isinstance(column, int) else int(column),
3036
3044
  redraw=False,
3037
3045
  run_binding_func=run_binding_func,
3038
3046
  )
@@ -3041,8 +3049,8 @@ class Sheet(tk.Frame):
3041
3049
 
3042
3050
  def select_cell(self, row: int, column: int, redraw: bool = True, run_binding_func: bool = True) -> Sheet:
3043
3051
  self.MT.select_cell(
3044
- int(row) if not isinstance(row, int) else row,
3045
- int(column) if not isinstance(column, int) else column,
3052
+ row if isinstance(row, int) else int(row),
3053
+ column if isinstance(column, int) else int(column),
3046
3054
  redraw=False,
3047
3055
  run_binding_func=run_binding_func,
3048
3056
  )
@@ -3722,10 +3730,24 @@ class Sheet(tk.Frame):
3722
3730
  self.MT.all_columns_displayed = a
3723
3731
  return v
3724
3732
 
3733
+ @property
3734
+ def all_columns(self) -> bool:
3735
+ return self.MT.all_columns_displayed
3736
+
3737
+ @all_columns.setter
3738
+ def all_columns(self, a: bool) -> Sheet:
3739
+ self.MT.all_columns_displayed = a
3740
+ return self
3741
+
3725
3742
  @property
3726
3743
  def displayed_columns(self) -> list[int]:
3727
3744
  return self.MT.displayed_columns
3728
3745
 
3746
+ @displayed_columns.setter
3747
+ def displayed_columns(self, columns: list[int]) -> Sheet:
3748
+ self.display_columns(columns=columns, reset_col_positions=False, redraw=True)
3749
+ return self
3750
+
3729
3751
  # Hiding Rows
3730
3752
 
3731
3753
  def displayed_row_to_data(self, r: int) -> int:
@@ -3828,10 +3850,24 @@ class Sheet(tk.Frame):
3828
3850
  self.MT.all_rows_displayed = a
3829
3851
  return v
3830
3852
 
3853
+ @property
3854
+ def all_rows(self) -> bool:
3855
+ return self.MT.all_rows_displayed
3856
+
3857
+ @all_rows.setter
3858
+ def all_rows(self, a: bool) -> Sheet:
3859
+ self.MT.all_rows_displayed = a
3860
+ return self
3861
+
3831
3862
  @property
3832
3863
  def displayed_rows(self) -> list[int]:
3833
3864
  return self.MT.displayed_rows
3834
3865
 
3866
+ @displayed_rows.setter
3867
+ def displayed_rows(self, rows: list[int]) -> Sheet:
3868
+ self.display_rows(rows=rows, reset_row_positions=False, redraw=True)
3869
+ return self
3870
+
3835
3871
  # Hiding Sheet Elements
3836
3872
 
3837
3873
  def hide(
@@ -4242,9 +4278,7 @@ class Sheet(tk.Frame):
4242
4278
  self.MT.main_table_redraw_grid_and_text(redraw_header=redraw_header, redraw_row_index=redraw_row_index)
4243
4279
  return self
4244
4280
 
4245
- def refresh(self, redraw_header: bool = True, redraw_row_index: bool = True) -> Sheet:
4246
- self.MT.main_table_redraw_grid_and_text(redraw_header=redraw_header, redraw_row_index=redraw_row_index)
4247
- return self
4281
+ refresh = redraw
4248
4282
 
4249
4283
  # Tags
4250
4284
 
@@ -4381,7 +4415,10 @@ class Sheet(tk.Frame):
4381
4415
  data: list[list[object]],
4382
4416
  iid_column: int,
4383
4417
  parent_column: int,
4418
+ text_column: None | int = None,
4384
4419
  ) -> Sheet:
4420
+ if text_column is None:
4421
+ text_column = iid_column
4385
4422
  tally_of_ids = defaultdict(lambda: -1)
4386
4423
  ncols = max(map(len, data), default=0)
4387
4424
  for rn, row in enumerate(data):
@@ -4400,13 +4437,13 @@ class Sheet(tk.Frame):
4400
4437
  tally_of_ids[iid] += 1
4401
4438
  row[iid_column] = new
4402
4439
  if iid not in self.RI.tree:
4403
- self.RI.tree[iid] = Node(row[iid_column], iid, "")
4440
+ self.RI.tree[iid] = Node(row[text_column], iid, "")
4404
4441
  if iid == pid or self.RI.pid_causes_recursive_loop(iid, pid):
4405
4442
  row[parent_column] = ""
4406
4443
  pid = ""
4407
4444
  if pid:
4408
4445
  if pid not in self.RI.tree:
4409
- self.RI.tree[pid] = Node(row[parent_column], pid)
4446
+ self.RI.tree[pid] = Node(row[text_column], pid)
4410
4447
  self.RI.tree[iid].parent = self.RI.tree[pid]
4411
4448
  self.RI.tree[pid].children.append(self.RI.tree[iid])
4412
4449
  else:
@@ -4416,7 +4453,7 @@ class Sheet(tk.Frame):
4416
4453
  if n.parent is None:
4417
4454
  n.parent = ""
4418
4455
  newrow = self.MT.get_empty_row_seq(len(data), ncols)
4419
- newrow[iid_column] = n.text
4456
+ newrow[iid_column] = n.iid
4420
4457
  self.RI.tree_rns[n.iid] = len(data)
4421
4458
  data.append(newrow)
4422
4459
  self.insert_rows(
@@ -4450,7 +4487,7 @@ class Sheet(tk.Frame):
4450
4487
  Accepts set[str] of iids that are open in the treeview
4451
4488
  Closes everything else
4452
4489
  """
4453
- self.RI.tree_open_ids = open_ids
4490
+ self.RI.tree_open_ids = open_ids if isinstance(open_ids, set) else set(open_ids)
4454
4491
  self.hide_rows(
4455
4492
  set(self.MT.displayed_rows),
4456
4493
  redraw=False,
@@ -4811,8 +4848,9 @@ class Sheet(tk.Frame):
4811
4848
  ]
4812
4849
 
4813
4850
  def selection_set(self, *items) -> Sheet:
4814
- self.deselect()
4815
- self.selection_add(*items)
4851
+ if any(item.lower() in self.RI.tree for item in unpack(items)):
4852
+ self.deselect()
4853
+ self.selection_add(*items)
4816
4854
  return self
4817
4855
 
4818
4856
  def selection_add(self, *items) -> Sheet:
@@ -4868,12 +4906,8 @@ class Sheet(tk.Frame):
4868
4906
  if redraw and self.after_redraw_id is None:
4869
4907
  self.after_redraw_id = self.after(self.after_redraw_time_ms, self.after_redraw)
4870
4908
 
4871
- def after_redraw(
4872
- self,
4873
- redraw_header: bool = True,
4874
- redraw_row_index: bool = True,
4875
- ) -> None:
4876
- self.MT.main_table_redraw_grid_and_text(redraw_header=redraw_header, redraw_row_index=redraw_row_index)
4909
+ def after_redraw(self) -> None:
4910
+ self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
4877
4911
  self.after_redraw_id = None
4878
4912
 
4879
4913
  def del_options_using_span(
tksheet/vars.py CHANGED
@@ -26,6 +26,16 @@ emitted_events: set[str] = {
26
26
  backwards_compatibility_keys: dict[str, str] = {
27
27
  "font": "table_font",
28
28
  }
29
+ text_editor_to_unbind: tuple[str] = (
30
+ "<Alt-Return>",
31
+ "<Alt-KP_Enter>",
32
+ "<Option-Return>",
33
+ "<Tab>",
34
+ "<Return>",
35
+ "<KP_Enter>",
36
+ "<FocusOut>",
37
+ "<Escape>",
38
+ )
29
39
  scrollbar_options_keys: set[str] = {
30
40
  "vertical_scroll_background",
31
41
  "horizontal_scroll_background",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.1.7
3
+ Version: 7.1.8
4
4
  Summary: Tkinter table / sheet widget
5
5
  Author-email: ragardner <github@ragardner.simplelogin.com>
6
6
  License: Copyright (c) 2019 ragardner and open source contributors
@@ -0,0 +1,20 @@
1
+ tksheet/__init__.py,sha256=QkLl7gG86v_1GMYTSGmOr137dpoTBZE2IpCEgCB40d8,1994
2
+ tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
+ tksheet/column_headers.py,sha256=u5SRsI3VAoqxpUpPQZfu2Zimmf2OmZUBD_hMJKso-pw,100204
4
+ tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
+ tksheet/functions.py,sha256=__21LS0cft9quuzFXcJ0BMbB0DEntvS4NQvreGk2U8Y,39709
6
+ tksheet/main_table.py,sha256=zY5RNV2AyJ3jM8JPMmYrwCXGsnefnVVlXcjaqYxdxvg,318290
7
+ tksheet/other_classes.py,sha256=P3FYUYreLhstATvHCNow8sDQoCsD_02KB6oXcca3ahE,13628
8
+ tksheet/row_index.py,sha256=wfOPHitGfipTysCMfQA-Nl4mJawmkv9gm5CAtIlKgxo,105673
9
+ tksheet/sheet.py,sha256=WvCuIszL31oJLhf0XJpvc0kHxa1yMAwEjiPrjeLkAQ8,257298
10
+ tksheet/sheet_options.py,sha256=mh0rTvWrFvIKaiv88jtMZy0TSA8zTS1GXSe88u8_rzk,11978
11
+ tksheet/text_editor.py,sha256=81_IZKrTVa2KIx2cJ4n3cFvFMAwvbHIQYgqtyat-97I,6681
12
+ tksheet/themes.py,sha256=OwUe31NRbosjw3ZoZsMyB8lNVyYin9YcKLhCturi5q8,13398
13
+ tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
14
+ tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
+ tksheet/vars.py,sha256=8Qxas-m5nU-yMaeAweO4Z30FM9cOQoRTiOsH4kgZp5s,2288
16
+ tksheet-7.1.8.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
+ tksheet-7.1.8.dist-info/METADATA,sha256=eyi1aRtOSI35o-qYZpAJSZMyYjisRqRyZk_qg1JWx74,6013
18
+ tksheet-7.1.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ tksheet-7.1.8.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
+ tksheet-7.1.8.dist-info/RECORD,,
tksheet/listbox.py DELETED
@@ -1,19 +0,0 @@
1
- from __future__ import annotations
2
- import tkinter as tk
3
- # from collections.abc import Callable, Generator, Iterator, Sequence
4
-
5
- from .sheet import (
6
- Sheet,
7
- )
8
-
9
-
10
- class ListBox(Sheet):
11
- def __init__(
12
- self,
13
- parent: tk.Misc,
14
- ) -> None:
15
- Sheet.__init__(
16
- self,
17
- parent=parent,
18
- )
19
- self.parent = parent
@@ -1,21 +0,0 @@
1
- tksheet/__init__.py,sha256=UgweIADXnlw1-KpD4Xr0sA_l6qAWTP3yzQ1Bo716Fkg,2010
2
- tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
- tksheet/column_headers.py,sha256=dBEnPjbI6nqcS0OISWJ0tXBBxtGjB67OE8z2-Bx8X1U,99870
4
- tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
- tksheet/functions.py,sha256=dMJwG27Qo5WsfwzkL7A9X-PERGuGFhpQvP95BnlohJ8,39612
6
- tksheet/listbox.py,sha256=BUHx-PsZL6yGMewxAaEZV_8mOXCVWenWqzHp3tasGvo,384
7
- tksheet/main_table.py,sha256=ngwXVNqrtOZPtR-BqCuh7UVAubfB8v_JfdI2peJAzPM,323154
8
- tksheet/other_classes.py,sha256=Hjr7c0kD2_880xjtGuFn9gQ-7ED5kSiNahniBeXcf84,13604
9
- tksheet/row_index.py,sha256=NHFu5a35nPMuxajHhpS2RH8sOTYKKKb6WGO8zWofxqs,105354
10
- tksheet/sheet.py,sha256=PbCa8RCiBYg3Zl_26j1aIKphGst84S2lGHKodnZ6Kk0,256166
11
- tksheet/sheet_options.py,sha256=mh0rTvWrFvIKaiv88jtMZy0TSA8zTS1GXSe88u8_rzk,11978
12
- tksheet/text_editor.py,sha256=81_IZKrTVa2KIx2cJ4n3cFvFMAwvbHIQYgqtyat-97I,6681
13
- tksheet/themes.py,sha256=OwUe31NRbosjw3ZoZsMyB8lNVyYin9YcKLhCturi5q8,13398
14
- tksheet/top_left_rectangle.py,sha256=-2u9GfOvcqhkKwHEtbqdFvXCY3RbvL5k2Sh9l3r_k04,8275
15
- tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
16
- tksheet/vars.py,sha256=Iukk7-MMT9X7vv0m3nQPKzbp2Iw2Pg1wJEW7js919Mo,2092
17
- tksheet-7.1.7.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
18
- tksheet-7.1.7.dist-info/METADATA,sha256=w5PeLRxO5tOgSz577YZLks3-OtluVDYw6Kw--fixI8w,6013
19
- tksheet-7.1.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
20
- tksheet-7.1.7.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
21
- tksheet-7.1.7.dist-info/RECORD,,