tksheet 7.5.2__py3-none-any.whl → 7.5.4__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.5.2"
7
+ __version__ = "7.5.4"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
tksheet/column_headers.py CHANGED
@@ -24,6 +24,7 @@ from .functions import (
24
24
  event_dict,
25
25
  event_has_char_key,
26
26
  event_opens_dropdown_or_checkbox,
27
+ get_menu_kwargs,
27
28
  get_n2a,
28
29
  int_x_tuple,
29
30
  is_contiguous,
@@ -35,7 +36,7 @@ from .functions import (
35
36
  try_binding,
36
37
  wrap_text,
37
38
  )
38
- from .other_classes import DotDict, DraggedRowColumn, DropdownStorage, EventDataDict, TextEditorStorage
39
+ from .other_classes import DraggedRowColumn, DropdownStorage, EventDataDict, TextEditorStorage
39
40
  from .row_index import RowIndex
40
41
  from .sorting import sort_column, sort_rows_by_column, sort_tree_rows_by_column
41
42
  from .text_editor import TextEditor
@@ -1804,16 +1805,9 @@ class ColumnHeaders(tk.Canvas):
1804
1805
  w = self.MT.col_positions[c + 1] - x
1805
1806
  h = self.current_height + 1
1806
1807
  kwargs = {
1807
- "menu_kwargs": DotDict(
1808
- {
1809
- "font": self.ops.table_font,
1810
- "foreground": self.ops.popup_menu_fg,
1811
- "background": self.ops.popup_menu_bg,
1812
- "activebackground": self.ops.popup_menu_highlight_bg,
1813
- "activeforeground": self.ops.popup_menu_highlight_fg,
1814
- }
1815
- ),
1808
+ "menu_kwargs": get_menu_kwargs(self.ops),
1816
1809
  "sheet_ops": self.ops,
1810
+ "font": self.ops.header_font,
1817
1811
  "border_color": self.ops.header_selected_columns_bg,
1818
1812
  "text": text,
1819
1813
  "state": state,
tksheet/find_window.py CHANGED
@@ -434,7 +434,7 @@ class FindWindow(tk.Frame):
434
434
  self.tktext.reset(
435
435
  menu_kwargs=menu_kwargs,
436
436
  sheet_ops=sheet_ops,
437
- font=menu_kwargs.font,
437
+ font=sheet_ops.table_font,
438
438
  bg=bg,
439
439
  fg=fg,
440
440
  select_bg=select_bg,
@@ -443,7 +443,7 @@ class FindWindow(tk.Frame):
443
443
  self.replace_tktext.reset(
444
444
  menu_kwargs=menu_kwargs,
445
445
  sheet_ops=sheet_ops,
446
- font=menu_kwargs.font,
446
+ font=sheet_ops.table_font,
447
447
  bg=bg,
448
448
  fg=fg,
449
449
  select_bg=select_bg,
@@ -459,7 +459,7 @@ class FindWindow(tk.Frame):
459
459
  self.replace_all,
460
460
  ):
461
461
  widget.config(
462
- font=menu_kwargs.font,
462
+ font=sheet_ops.table_font,
463
463
  bg=bg,
464
464
  fg=fg,
465
465
  highlightbackground=bg,
tksheet/functions.py CHANGED
@@ -853,18 +853,6 @@ def insert_items(
853
853
  return seq
854
854
 
855
855
 
856
- def del_placeholder_dict_key(
857
- d: dict[Hashable, Any],
858
- k: Hashable,
859
- v: Any,
860
- p: tuple = (),
861
- ) -> dict[Hashable, Any]:
862
- if p in d:
863
- del d[p]
864
- d[k] = v
865
- return d
866
-
867
-
868
856
  def data_to_displayed_idxs(
869
857
  to_convert: list[int],
870
858
  displayed: list[int],
tksheet/main_table.py CHANGED
@@ -1222,7 +1222,7 @@ class MainTable(tk.Canvas):
1222
1222
  lastbox_numcols = lastbox_c2 - lastbox_c1
1223
1223
  if lastbox_numrows > new_data_numrows and not lastbox_numrows % new_data_numrows:
1224
1224
  repeat_num = int(lastbox_numrows / new_data_numrows)
1225
- data.extend(chain.from_iterable([r.copy() for r in data] for _ in range(repeat_num - 1)))
1225
+ data.extend(list(chain.from_iterable([r.copy() for r in data] for _ in range(repeat_num - 1))))
1226
1226
  new_data_numrows *= repeat_num
1227
1227
 
1228
1228
  if lastbox_numcols > new_data_numcols and not lastbox_numcols % new_data_numcols:
@@ -1967,6 +1967,7 @@ class MainTable(tk.Canvas):
1967
1967
  )
1968
1968
  else:
1969
1969
  self.recreate_all_selection_boxes()
1970
+
1970
1971
  return data_new_idxs, disp_new_idxs, event_data
1971
1972
 
1972
1973
  def get_max_row_idx(self, maxidx: int | None = None) -> int:
@@ -2117,6 +2118,7 @@ class MainTable(tk.Canvas):
2117
2118
  event_data["selection_boxes"] = modification["selection_boxes"]
2118
2119
  event_data["selected"] = modification["selected"]
2119
2120
  saved_cells = False
2121
+
2120
2122
  if modification["added"]["rows"] or modification["added"]["columns"]:
2121
2123
  event_data = self.save_cells_using_modification(modification, event_data)
2122
2124
  saved_cells = True
@@ -5629,12 +5631,8 @@ class MainTable(tk.Canvas):
5629
5631
  return {
5630
5632
  "row_positions": list(self.row_positions),
5631
5633
  "col_positions": list(self.col_positions),
5632
- "displayed_rows": int(self.displayed_rows)
5633
- if isinstance(self.displayed_rows, int)
5634
- else list(self.displayed_rows),
5635
- "displayed_columns": int(self.displayed_columns)
5636
- if isinstance(self.displayed_columns, int)
5637
- else list(self.displayed_columns),
5634
+ "displayed_rows": list(self.displayed_rows),
5635
+ "displayed_columns": list(self.displayed_columns),
5638
5636
  "all_rows_displayed": bool(self.all_rows_displayed),
5639
5637
  "saved_row_heights": dict(self.saved_row_heights),
5640
5638
  "saved_column_widths": dict(self.saved_column_widths),
@@ -7587,6 +7585,7 @@ class MainTable(tk.Canvas):
7587
7585
  kwargs = {
7588
7586
  "menu_kwargs": get_menu_kwargs(self.PAR.ops),
7589
7587
  "sheet_ops": self.PAR.ops,
7588
+ "font": self.PAR.ops.table_font,
7590
7589
  "border_color": self.PAR.ops.table_selected_box_cells_fg,
7591
7590
  "text": text,
7592
7591
  "state": state,
tksheet/other_classes.py CHANGED
@@ -481,10 +481,10 @@ class Node:
481
481
  parent: str = "",
482
482
  children: list[str] | None = None,
483
483
  ) -> None:
484
- self.text = text
485
- self.iid = iid
486
- self.parent = parent
487
- self.children = children if children else []
484
+ self.text: str = text
485
+ self.iid: str = iid
486
+ self.parent: str = parent
487
+ self.children: list[str] = children if children else []
488
488
 
489
489
 
490
490
  class StorageBase:
tksheet/row_index.py CHANGED
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  import tkinter as tk
4
4
  from collections import defaultdict
5
5
  from collections.abc import Callable, Generator, Hashable, Iterator, Sequence
6
- from contextlib import suppress
7
6
  from functools import partial
8
7
  from itertools import islice, repeat
9
8
  from math import ceil
@@ -22,10 +21,10 @@ from .formatters import is_bool_like, try_to_bool
22
21
  from .functions import (
23
22
  add_to_displayed,
24
23
  consecutive_ranges,
25
- del_placeholder_dict_key,
26
24
  event_dict,
27
25
  event_has_char_key,
28
26
  event_opens_dropdown_or_checkbox,
27
+ get_menu_kwargs,
29
28
  get_n2a,
30
29
  get_new_indexes,
31
30
  int_x_tuple,
@@ -39,7 +38,7 @@ from .functions import (
39
38
  try_binding,
40
39
  wrap_text,
41
40
  )
42
- from .other_classes import DotDict, DraggedRowColumn, DropdownStorage, EventDataDict, Node, TextEditorStorage
41
+ from .other_classes import DraggedRowColumn, DropdownStorage, EventDataDict, Node, TextEditorStorage
43
42
  from .sorting import sort_columns_by_row, sort_row
44
43
  from .text_editor import TextEditor
45
44
 
@@ -838,7 +837,7 @@ class RowIndex(tk.Canvas):
838
837
  move_heights=self.ops.row_drag_and_drop_perform,
839
838
  event_data=event_data,
840
839
  )
841
- if data_new_idxs and disp_new_idxs:
840
+ if data_new_idxs:
842
841
  event_data["moved"]["rows"] = {
843
842
  "data": data_new_idxs,
844
843
  "displayed": disp_new_idxs,
@@ -1976,16 +1975,9 @@ class RowIndex(tk.Canvas):
1976
1975
  w = self.current_width + 1
1977
1976
  h = self.MT.row_positions[r + 1] - y + 1
1978
1977
  kwargs = {
1979
- "menu_kwargs": DotDict(
1980
- {
1981
- "font": self.ops.index_font,
1982
- "foreground": self.ops.popup_menu_fg,
1983
- "background": self.ops.popup_menu_bg,
1984
- "activebackground": self.ops.popup_menu_highlight_bg,
1985
- "activeforeground": self.ops.popup_menu_highlight_fg,
1986
- }
1987
- ),
1978
+ "menu_kwargs": get_menu_kwargs(self.ops),
1988
1979
  "sheet_ops": self.ops,
1980
+ "font": self.ops.index_font,
1989
1981
  "border_color": self.ops.index_selected_rows_bg,
1990
1982
  "text": text,
1991
1983
  "state": state,
@@ -2681,34 +2673,38 @@ class RowIndex(tk.Canvas):
2681
2673
  moved_rows = [self.rns[item]]
2682
2674
  new_parent = node_change[1]
2683
2675
  move_to_index = node_change[2]
2676
+ # new parent exists
2684
2677
  if new_parent:
2678
+ new_par_cn = self.iid_children(new_parent)
2679
+ # determine index
2685
2680
  if isinstance(move_to_index, int):
2686
- move_to_index = min(move_to_index, len(self.iid_children(new_parent)))
2681
+ move_to_index = min(move_to_index, len(new_par_cn))
2687
2682
  else:
2688
- move_to_index = len(self.iid_children(new_parent))
2689
- move_to_row = self.rns[new_parent]
2690
- _find = move_to_index + 1 if new_parent == self.iid_parent(item) else move_to_index
2691
- move_to_row += _find + sum(
2692
- self.num_descendants(cid) for cid in islice(self.iid_children(new_parent), _find)
2693
- )
2694
- insert_row = move_to_row + 1
2683
+ move_to_index = len(new_par_cn)
2684
+ # determine insert row
2685
+ if not new_par_cn:
2686
+ insert_row = self.rns[new_parent] + 1
2687
+ elif move_to_index >= len(new_par_cn):
2688
+ insert_row = self.rns[new_par_cn[-1]] + self.num_descendants(new_par_cn[-1]) + 1
2689
+ elif new_parent == self.iid_parent(item):
2690
+ if move_to_index <= self.PAR.index(item):
2691
+ # Insert before the sibling at move_to_index
2692
+ insert_row = self.rns[new_par_cn[move_to_index]]
2693
+ else:
2694
+ # Insert after the sibling at move_to_index
2695
+ insert_row = self.rns[new_par_cn[move_to_index]]
2696
+ insert_row += 1 + self.num_descendants(new_par_cn[move_to_index])
2697
+ else:
2698
+ insert_row = self.rns[new_par_cn[move_to_index]]
2699
+ # no new parent
2695
2700
  else:
2696
- num_top_nodes = sum(1 for _ in self.gen_top_nodes())
2697
- if move_to_index is None:
2698
- move_to_row = self.PAR.top_index_row(num_top_nodes - 1)
2699
- move_to_index = num_top_nodes
2700
- insert_row = move_to_row
2701
+ # determine index
2702
+ if isinstance(move_to_index, int):
2703
+ move_to_index = min(move_to_index, sum(1 for _ in self.gen_top_nodes()))
2701
2704
  else:
2702
- move_to_row = self.PAR.top_index_row(move_to_index)
2703
- insert_row = move_to_row
2704
- if move_to_row is None:
2705
- move_to_row = self.PAR.top_index_row(num_top_nodes - 1)
2706
- move_to_index = num_top_nodes
2707
- insert_row = move_to_row + 1
2708
-
2709
- move_to_iid = self.MT._row_index[move_to_row].iid
2710
- disp_insert_row = None
2711
-
2705
+ move_to_index = sum(1 for _ in self.gen_top_nodes())
2706
+ # determine insert row
2707
+ insert_row = self.PAR._get_id_insert_row(move_to_index, new_parent)
2712
2708
  else:
2713
2709
  iids = {self.MT._row_index[r].iid for r in event_data["moved"]["rows"]["data"]}
2714
2710
  iids_descendants = {iid: set(self.get_iid_descendants(iid)) for iid in iids}
@@ -2719,21 +2715,18 @@ class RowIndex(tk.Canvas):
2719
2715
  item = self.MT._row_index[moved_rows[0]].iid
2720
2716
 
2721
2717
  if isinstance(event_data.value, int):
2722
- disp_insert_row = event_data.value
2723
- if disp_insert_row >= len(self.MT.displayed_rows):
2718
+ if event_data.value >= len(self.MT.displayed_rows):
2724
2719
  insert_row = len(self.MT._row_index)
2725
2720
  else:
2726
- insert_row = self.MT.datarn(disp_insert_row)
2721
+ insert_row = self.MT.datarn(event_data.value)
2727
2722
  move_to_iid = self.MT._row_index[min(insert_row, len(self.MT._row_index) - 1)].iid
2728
2723
 
2729
2724
  else:
2730
- disp_insert_row = None
2731
2725
  min_from = min(event_data["moved"]["rows"]["data"])
2732
2726
  # max_from = max(event_data.moved.rows)
2733
2727
  min_to = min(event_data["moved"]["rows"]["data"].values())
2734
2728
  max_to = max(event_data["moved"]["rows"]["data"].values())
2735
2729
  insert_row = max_to if min_from <= min_to else min_to
2736
- move_to_row = insert_row
2737
2730
  move_to_iid = self.MT._row_index[insert_row].iid
2738
2731
 
2739
2732
  move_to_index = self.PAR.index(move_to_iid)
@@ -2744,19 +2737,7 @@ class RowIndex(tk.Canvas):
2744
2737
  new_loc_is_displayed = not new_parent or (
2745
2738
  new_parent and new_parent in self.tree_open_ids and self.PAR.item_displayed(new_parent)
2746
2739
  )
2747
- # deal with displayed mapping
2748
2740
  event_data["moved"]["rows"]["displayed"] = {}
2749
- with suppress(Exception):
2750
- if new_loc_is_displayed:
2751
- if disp_insert_row is None:
2752
- if new_parent or insert_row > move_to_row:
2753
- disp_insert_row = self.MT.disprn(self.rns[move_to_iid]) + 1
2754
- else:
2755
- disp_insert_row = self.MT.disprn(self.rns[move_to_iid])
2756
- if (disp_from_row := self.MT.try_disprn(self.rns[item])) is not None:
2757
- event_data["moved"]["rows"]["displayed"] = {disp_from_row: disp_insert_row}
2758
- else:
2759
- event_data["moved"]["rows"]["displayed"] = {(): disp_insert_row}
2760
2741
 
2761
2742
  if any(self.move_pid_causes_recursive_loop(self.MT._row_index[r].iid, new_parent) for r in moved_rows):
2762
2743
  event_data["moved"]["rows"] = {}
@@ -2778,15 +2759,6 @@ class RowIndex(tk.Canvas):
2778
2759
  )
2779
2760
  data_new_idxs = event_data["moved"]["rows"]["data"]
2780
2761
  data_old_idxs = {v: k for k, v in data_new_idxs.items()}
2781
-
2782
- if () in event_data["moved"]["rows"]["displayed"]:
2783
- del event_data["moved"]["rows"]["displayed"][()]
2784
-
2785
- if event_data["moved"]["rows"]["displayed"]:
2786
- event_data["moved"]["rows"]["displayed"] = get_new_indexes(
2787
- disp_insert_row,
2788
- event_data["moved"]["rows"]["displayed"],
2789
- )
2790
2762
  disp_new_idxs = event_data["moved"]["rows"]["displayed"]
2791
2763
 
2792
2764
  if data_new_idxs:
@@ -2823,8 +2795,7 @@ class RowIndex(tk.Canvas):
2823
2795
  # its the same parent, we're just moving index
2824
2796
  if parent == item_node.parent:
2825
2797
  event_data = self.copy_nodes((item, parent), event_data)
2826
- pop_index = parent_node.children.index(item)
2827
- parent_node.children.insert(index, parent_node.children.pop(pop_index))
2798
+ parent_node.children.insert(index, parent_node.children.pop(parent_node.children.index(item)))
2828
2799
 
2829
2800
  else:
2830
2801
  if item_node.parent:
@@ -2848,29 +2819,16 @@ class RowIndex(tk.Canvas):
2848
2819
  mapping = event_data["moved"]["rows"]["data"]
2849
2820
  row_ctr = next(reversed(mapping.values())) + 1
2850
2821
 
2851
- if disp_mapping := event_data["moved"]["rows"]["displayed"]:
2852
- if () in disp_mapping:
2853
- disp_row_ctr = next(reversed(disp_mapping.values()))
2854
- else:
2855
- disp_row_ctr = next(reversed(disp_mapping.values())) + 1
2856
-
2857
2822
  rn = self.rns[item]
2858
2823
  if rn not in mapping:
2859
2824
  mapping[rn] = row_ctr
2860
2825
  row_ctr += 1
2861
- if disp_mapping and (disp_from := self.MT.try_disprn(rn)) is not None:
2862
- disp_mapping = del_placeholder_dict_key(disp_mapping, disp_from, disp_row_ctr)
2863
- disp_row_ctr += 1
2864
2826
 
2865
2827
  for did in self.get_iid_descendants(item):
2866
2828
  mapping[self.rns[did]] = row_ctr
2867
2829
  row_ctr += 1
2868
- if disp_mapping and (disp_from := self.MT.try_disprn(self.rns[did])) is not None:
2869
- disp_mapping = del_placeholder_dict_key(disp_mapping, disp_from, disp_row_ctr)
2870
- disp_row_ctr += 1
2871
2830
 
2872
2831
  event_data["moved"]["rows"]["data"] = mapping
2873
- event_data["moved"]["rows"]["displayed"] = disp_mapping
2874
2832
 
2875
2833
  return event_data
2876
2834
 
@@ -2878,21 +2836,11 @@ class RowIndex(tk.Canvas):
2878
2836
  for iid, node in event_data["treeview"]["nodes"].items():
2879
2837
  self.MT._row_index[self.rns[iid]] = node
2880
2838
 
2881
- def copy_node(self, item: str) -> Node:
2882
- n = self.iid_node(item)
2883
- return Node(
2884
- text=n.text,
2885
- iid=n.iid,
2886
- parent=n.parent,
2887
- children=n.children.copy(),
2888
- )
2889
-
2890
2839
  def copy_nodes(self, items: Iterator[str], event_data: EventDataDict) -> EventDataDict:
2891
- nodes = event_data["treeview"]["nodes"]
2892
2840
  for iid in items:
2893
- if iid not in nodes:
2841
+ if iid not in event_data["treeview"]["nodes"]:
2894
2842
  n = self.iid_node(iid)
2895
- nodes[iid] = Node(
2843
+ event_data["treeview"]["nodes"][iid] = Node(
2896
2844
  text=n.text,
2897
2845
  iid=n.iid,
2898
2846
  parent=n.parent,
tksheet/sheet.py CHANGED
@@ -4744,7 +4744,7 @@ class Sheet(tk.Frame):
4744
4744
  self.hide_rows(datarn, deselect_all=False, data_indexes=True)
4745
4745
  return iid
4746
4746
 
4747
- def _get_id_insert_row(self, index: int, parent: str) -> int:
4747
+ def _get_id_insert_row(self, index: int | None, parent: str) -> int:
4748
4748
  if parent:
4749
4749
  if isinstance(index, int):
4750
4750
  index = min(index, len(self.RI.iid_children(parent)))
@@ -4759,7 +4759,7 @@ class Sheet(tk.Frame):
4759
4759
  else:
4760
4760
  if isinstance(index, int):
4761
4761
  datarn = index
4762
- if index and (datarn := self.top_index_row(datarn)) is None:
4762
+ if index and (datarn := self.top_index_row(index)) is None:
4763
4763
  datarn = len(self.MT._row_index)
4764
4764
  else:
4765
4765
  datarn = len(self.MT._row_index)
@@ -4792,6 +4792,8 @@ class Sheet(tk.Frame):
4792
4792
  rns_to_add = {}
4793
4793
  for rn, r in enumerate(data, start=datarn):
4794
4794
  iid = self.RI.new_iid() if iid_column is None else r[iid_column]
4795
+ if iid in self.RI.rns:
4796
+ raise ValueError(f"iid '{iid}' already exists.")
4795
4797
  new_node = Node(
4796
4798
  r[text_column] if isinstance(text_column, int) else text_column if isinstance(text_column, str) else "",
4797
4799
  iid,
@@ -4995,11 +4997,24 @@ class Sheet(tk.Frame):
4995
4997
  raise ValueError(f"Item '{item}' does not exist.")
4996
4998
  return self.RI.iid_parent(item)
4997
4999
 
4998
- def index(self, item: str) -> int:
5000
+ def index(self, item: str, safety: bool = False) -> int:
5001
+ """
5002
+ Finds the index of an item amongst it's siblings in the
5003
+ treeview.
5004
+
5005
+ 'safety' is only necessary when the internal row number dict
5006
+ is not able to provide row numbers, e.g. when modifying the
5007
+ tree and before the action is complete.
5008
+
5009
+ When 'True' the fn uses list.index() instead.
5010
+ """
4999
5011
  if item not in self.RI.rns:
5000
5012
  raise ValueError(f"Item '{item}' does not exist.")
5001
- elif self.RI.iid_parent(item):
5002
- return self.RI.parent_node(item).children.index(item)
5013
+ elif par := self.RI.iid_parent(item):
5014
+ if not safety:
5015
+ return self.RI.rns[item] - self.RI.rns[par] - 1
5016
+ else:
5017
+ return self.RI.parent_node(item).children.index(item)
5003
5018
  else:
5004
5019
  return next(index for index, iid in enumerate(self.get_children("")) if iid == item)
5005
5020
 
@@ -5500,17 +5515,8 @@ class Sheet(tk.Frame):
5500
5515
  readonly: bool = True,
5501
5516
  redraw: bool = False,
5502
5517
  ) -> Sheet:
5503
- if isinstance(rows, int):
5504
- rows = [rows]
5505
- if not readonly:
5506
- for r in rows:
5507
- if r in self.MT.row_options and "readonly" in self.MT.row_options[r]:
5508
- del self.MT.row_options[r]["readonly"]
5509
- else:
5510
- for r in rows:
5511
- if r not in self.MT.row_options:
5512
- self.MT.row_options[r] = {}
5513
- self.MT.row_options[r]["readonly"] = True
5518
+ for r in (rows,) if isinstance(rows, int) else rows:
5519
+ set_readonly(self.MT.row_options, r, readonly)
5514
5520
  return self.set_refresh_timer(redraw)
5515
5521
 
5516
5522
  def readonly_columns(
@@ -5519,17 +5525,8 @@ class Sheet(tk.Frame):
5519
5525
  readonly: bool = True,
5520
5526
  redraw: bool = False,
5521
5527
  ) -> Sheet:
5522
- if isinstance(columns, int):
5523
- columns = [columns]
5524
- if not readonly:
5525
- for c in columns:
5526
- if c in self.MT.col_options and "readonly" in self.MT.col_options[c]:
5527
- del self.MT.col_options[c]["readonly"]
5528
- else:
5529
- for c in columns:
5530
- if c not in self.MT.col_options:
5531
- self.MT.col_options[c] = {}
5532
- self.MT.col_options[c]["readonly"] = True
5528
+ for c in (columns,) if isinstance(columns, int) else columns:
5529
+ set_readonly(self.MT.col_options, c, readonly)
5533
5530
  return self.set_refresh_timer(redraw)
5534
5531
 
5535
5532
  def readonly_cells(
@@ -5540,45 +5537,31 @@ class Sheet(tk.Frame):
5540
5537
  readonly: bool = True,
5541
5538
  redraw: bool = False,
5542
5539
  ) -> Sheet:
5543
- if not readonly:
5544
- if cells:
5545
- for r, c in cells:
5546
- if (r, c) in self.MT.cell_options and "readonly" in self.MT.cell_options[(r, c)]:
5547
- del self.MT.cell_options[(r, c)]["readonly"]
5548
- else:
5549
- if (
5550
- row,
5551
- column,
5552
- ) in self.MT.cell_options and "readonly" in self.MT.cell_options[(row, column)]:
5553
- del self.MT.cell_options[(row, column)]["readonly"]
5540
+ if cells:
5541
+ for r, c in cells:
5542
+ set_readonly(self.MT.cell_options, (r, c), readonly=readonly)
5554
5543
  else:
5555
- if cells:
5556
- for r, c in cells:
5557
- if (r, c) not in self.MT.cell_options:
5558
- self.MT.cell_options[(r, c)] = {}
5559
- self.MT.cell_options[(r, c)]["readonly"] = True
5560
- else:
5561
- if (row, column) not in self.MT.cell_options:
5562
- self.MT.cell_options[(row, column)] = {}
5563
- self.MT.cell_options[(row, column)]["readonly"] = True
5544
+ set_readonly(self.MT.cell_options, (row, column), readonly=readonly)
5564
5545
  return self.set_refresh_timer(redraw)
5565
5546
 
5566
5547
  def readonly_header(
5567
5548
  self,
5568
- columns: list[int],
5549
+ columns: list[int] | int,
5569
5550
  readonly: bool = True,
5570
5551
  redraw: bool = False,
5571
5552
  ) -> Sheet:
5572
- self.CH.readonly_header(columns=columns, readonly=readonly)
5553
+ for c in (columns, int) if isinstance(columns, int) else columns:
5554
+ set_readonly(self.CH.cell_options, c, readonly)
5573
5555
  return self.set_refresh_timer(redraw)
5574
5556
 
5575
5557
  def readonly_index(
5576
5558
  self,
5577
- rows: list[int],
5559
+ rows: list[int] | int,
5578
5560
  readonly: bool = True,
5579
5561
  redraw: bool = False,
5580
5562
  ) -> Sheet:
5581
- self.RI.readonly_index(rows=rows, readonly=readonly)
5563
+ for r in (rows,) if isinstance(rows, int) else rows:
5564
+ set_readonly(self.RI.cell_options, r, readonly)
5582
5565
  return self.set_refresh_timer(redraw)
5583
5566
 
5584
5567
  def dehighlight_rows(
@@ -6381,20 +6364,14 @@ class Sheet(tk.Frame):
6381
6364
  **{k: v["dropdown"] for k, v in self.MT.row_options.items() if "dropdown" in v},
6382
6365
  **{k: v["dropdown"] for k, v in self.MT.col_options.items() if "dropdown" in v},
6383
6366
  }
6384
- if "dropdown" in self.MT.options:
6385
- return {**d, "dropdown": self.MT.options["dropdown"]}
6386
6367
  return d
6387
6368
 
6388
6369
  def get_header_dropdowns(self) -> dict:
6389
6370
  d = {k: v["dropdown"] for k, v in self.CH.cell_options.items() if "dropdown" in v}
6390
- if "dropdown" in self.CH.options:
6391
- return {**d, "dropdown": self.CH.options["dropdown"]}
6392
6371
  return d
6393
6372
 
6394
6373
  def get_index_dropdowns(self) -> dict:
6395
6374
  d = {k: v["dropdown"] for k, v in self.RI.cell_options.items() if "dropdown" in v}
6396
- if "dropdown" in self.RI.options:
6397
- return {**d, "dropdown": self.RI.options["dropdown"]}
6398
6375
  return d
6399
6376
 
6400
6377
  def set_dropdown_values(
tksheet/text_editor.py CHANGED
@@ -6,7 +6,7 @@ from typing import Any, Literal
6
6
 
7
7
  from .constants import align_helper, ctrl_key, rc_binding
8
8
  from .functions import convert_align
9
- from .other_classes import DotDict
9
+ from .other_classes import DotDict, FontTuple
10
10
 
11
11
 
12
12
  class TextEditorTkText(tk.Text):
@@ -231,6 +231,7 @@ class TextEditor(tk.Frame):
231
231
  show_border: bool,
232
232
  menu_kwargs: DotDict,
233
233
  sheet_ops: DotDict,
234
+ font: FontTuple,
234
235
  bg: str,
235
236
  fg: str,
236
237
  select_bg: str,
@@ -247,7 +248,7 @@ class TextEditor(tk.Frame):
247
248
  menu_kwargs=menu_kwargs,
248
249
  sheet_ops=sheet_ops,
249
250
  align=align,
250
- font=menu_kwargs.font,
251
+ font=font,
251
252
  bg=bg,
252
253
  fg=fg,
253
254
  select_bg=select_bg,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tksheet
3
- Version: 7.5.2
3
+ Version: 7.5.4
4
4
  Summary: Tkinter table / sheet and treeview widget
5
5
  Author-email: ragardner <github@ragardner.simplelogin.com>
6
6
  License: Copyright (c) 2019 ragardner and open source contributors
@@ -0,0 +1,22 @@
1
+ tksheet/__init__.py,sha256=KEml35Fw4hv8ZHdA1ptLN3zp76EBlrz9vWE4os-Lf4Q,2532
2
+ tksheet/colors.py,sha256=dHhmdFuQDlwohDHsAfT9VdrKoSl_R33L72a3HCin5zo,51591
3
+ tksheet/column_headers.py,sha256=LioLw6JPuSqRD4E2b5EVfeEtz1Kja7N3ad7DdSf8HFs,103401
4
+ tksheet/constants.py,sha256=f-w31-cmBt2PNcCYWYnpWgi7vNzqpFqJKqZoE9HXlRs,25454
5
+ tksheet/find_window.py,sha256=6WMoCZcUbSLwIQNui4VwXfXhP9qtRp6-NE7UlwIaU2M,20929
6
+ tksheet/formatters.py,sha256=DGcRiMsDJnySNpQcjfiX84oJ7TmOSMdU6u9injIhA4g,10095
7
+ tksheet/functions.py,sha256=EfyfTgfymbi1AsHvCgzMDs-vXzYSqY7xSUiCOL_L6S8,52959
8
+ tksheet/main_table.py,sha256=gFJCJJEiuN46ZyuQDxoP3UEx5ihCXD3lK5xldQcHtBU,378985
9
+ tksheet/other_classes.py,sha256=fKgQRnv8r4ZCum1twz22WKMlUmDMW_qpQV9L8A5BxU8,18203
10
+ tksheet/row_index.py,sha256=oOKJ_TjS77I-2Vr-lAnKgmebJAL3MH_sYDXe6sZC2VY,139489
11
+ tksheet/sheet.py,sha256=QM94tRZMdkaX-frHnTVEY0XrcWMC3oP0KFHYjyI8FXs,269238
12
+ tksheet/sheet_options.py,sha256=bB-XBs1sL2w9a47wSM6GD960ZKbvQuU2VvYIK2JRSjE,14567
13
+ tksheet/sorting.py,sha256=zcZPpRtP1h_xJGtGkG3E43H7deKQFnh9cMwZ1B2-aGc,17502
14
+ tksheet/text_editor.py,sha256=Ksz4kT7TrCIzDhRZK9EM54M7R_5CvrwC1aeTrUPNOTg,8391
15
+ tksheet/themes.py,sha256=kUUCUmvgu8vUlzfVNk9a3BEbeBcU3asNwPB_u-OejCY,18471
16
+ tksheet/tksheet_types.py,sha256=1MjXR34EmvP1KfHlLTvKKVnf0VMz_LU_WOM2q4o5hfI,4598
17
+ tksheet/top_left_rectangle.py,sha256=A4wWL8PFl57Pn2Ek71rASCE1-bW844cTl7bgt4tLWzI,8499
18
+ tksheet-7.5.4.dist-info/licenses/LICENSE.txt,sha256=n1UvJHBr-AYNOf6ExICDsEggh9R7U4V4m_gH7FD-y-o,2305
19
+ tksheet-7.5.4.dist-info/METADATA,sha256=6wQAHuE09fFVfCPToXMJJs-kxCb819eKUKQWxNIt4rY,9474
20
+ tksheet-7.5.4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
21
+ tksheet-7.5.4.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
22
+ tksheet-7.5.4.dist-info/RECORD,,
@@ -1,22 +0,0 @@
1
- tksheet/__init__.py,sha256=EZB4NOF4UErow0D_-Ze7PuT4wryT-NdmDfeToLGNuTI,2532
2
- tksheet/colors.py,sha256=dHhmdFuQDlwohDHsAfT9VdrKoSl_R33L72a3HCin5zo,51591
3
- tksheet/column_headers.py,sha256=BMNT6v6d6TcD6erAMtgX-n3aoC5uMRu3W1P--zXOsxA,103699
4
- tksheet/constants.py,sha256=f-w31-cmBt2PNcCYWYnpWgi7vNzqpFqJKqZoE9HXlRs,25454
5
- tksheet/find_window.py,sha256=P27qQsj9BxjALgfVfWV5tyRTDlnws-rCjnmZmoGzq1c,20917
6
- tksheet/formatters.py,sha256=DGcRiMsDJnySNpQcjfiX84oJ7TmOSMdU6u9injIhA4g,10095
7
- tksheet/functions.py,sha256=8d5T8UgNrJ3XmDFLGWXw19yVZQclLgMkinnTi5aDaLo,53163
8
- tksheet/main_table.py,sha256=rORIeqtDLbuBfR_law1ae1L13gl8KlantPyr1HKOK1I,379127
9
- tksheet/other_classes.py,sha256=4VcAxiPH8SxuNbbLSve5ynqfnLwMUGSUs1ZQp0Yc1Gc,18177
10
- tksheet/row_index.py,sha256=VYS5XdT1ERJggxMm0TBg8hw_3TqUrcR5sDIr66hM69c,141971
11
- tksheet/sheet.py,sha256=WlSC7ivRRAyJRtpVMfLiaugAWhjZ0EW51MinZvO690E,270284
12
- tksheet/sheet_options.py,sha256=bB-XBs1sL2w9a47wSM6GD960ZKbvQuU2VvYIK2JRSjE,14567
13
- tksheet/sorting.py,sha256=zcZPpRtP1h_xJGtGkG3E43H7deKQFnh9cMwZ1B2-aGc,17502
14
- tksheet/text_editor.py,sha256=bkVRWYE3fCIo5xvwUBkmkBJ6nBGV2X1VsZ4LhQ5146I,8366
15
- tksheet/themes.py,sha256=kUUCUmvgu8vUlzfVNk9a3BEbeBcU3asNwPB_u-OejCY,18471
16
- tksheet/tksheet_types.py,sha256=1MjXR34EmvP1KfHlLTvKKVnf0VMz_LU_WOM2q4o5hfI,4598
17
- tksheet/top_left_rectangle.py,sha256=A4wWL8PFl57Pn2Ek71rASCE1-bW844cTl7bgt4tLWzI,8499
18
- tksheet-7.5.2.dist-info/licenses/LICENSE.txt,sha256=n1UvJHBr-AYNOf6ExICDsEggh9R7U4V4m_gH7FD-y-o,2305
19
- tksheet-7.5.2.dist-info/METADATA,sha256=doJjhw-uW86R60e4x6qhTEJ_a2GabkloseGYizgocXs,9474
20
- tksheet-7.5.2.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
21
- tksheet-7.5.2.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
22
- tksheet-7.5.2.dist-info/RECORD,,