tksheet 7.2.22__py3-none-any.whl → 7.3.0__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/row_index.py CHANGED
@@ -74,6 +74,7 @@ class RowIndex(tk.Canvas):
74
74
  self.MT = None # is set from within MainTable() __init__
75
75
  self.CH = None # is set from within MainTable() __init__
76
76
  self.TL = None # is set from within TopLeftRectangle() __init__
77
+ self.current_width = None
77
78
  self.popup_menu_loc = None
78
79
  self.extra_begin_edit_cell_func = None
79
80
  self.extra_end_edit_cell_func = None
@@ -95,7 +96,6 @@ class RowIndex(tk.Canvas):
95
96
  self.ri_extra_end_drag_drop_func = None
96
97
  self.extra_double_b1_func = None
97
98
  self.row_height_resize_func = None
98
- self.new_row_width = 0
99
99
  self.cell_options = {}
100
100
  self.drag_and_drop_enabled = False
101
101
  self.dragged_row = None
@@ -178,13 +178,15 @@ class RowIndex(tk.Canvas):
178
178
  self.MT.saved_row_heights = {}
179
179
 
180
180
  def set_width(self, new_width: int, set_TL: bool = False, recreate_selection_boxes: bool = True) -> None:
181
- self.current_width = new_width
182
181
  try:
183
182
  self.config(width=new_width)
184
183
  except Exception:
185
184
  return
186
185
  if set_TL:
187
- self.TL.set_dimensions(new_w=new_width, recreate_selection_boxes=recreate_selection_boxes)
186
+ self.TL.set_dimensions(new_w=new_width)
187
+ if isinstance(self.current_width, int) and new_width > self.current_width and recreate_selection_boxes:
188
+ self.MT.recreate_all_selection_boxes()
189
+ self.current_width = new_width
188
190
 
189
191
  def rc(self, event: object) -> None:
190
192
  self.mouseclick_outside_editor_or_dropdown_all_canvases(inside=True)
@@ -480,11 +482,6 @@ class RowIndex(tk.Canvas):
480
482
  self.MT.create_resize_line(x1, line2y, x2, line2y, width=1, fill=self.PAR.ops.resizing_line_fg, tag="rhl2")
481
483
  elif self.width_resizing_enabled and self.rsz_h is None and self.rsz_w is True:
482
484
  self.currently_resizing_width = True
483
- x1, y1, x2, y2 = self.MT.get_canvas_visible_area()
484
- x = int(event.x)
485
- if x < self.MT.min_column_width:
486
- x = int(self.MT.min_column_width)
487
- self.new_row_width = x
488
485
  elif self.MT.identify_row(y=event.y, allow_end=False) is None:
489
486
  self.MT.deselect("all")
490
487
  elif self.row_selection_enabled and self.rsz_h is None and self.rsz_w is None:
@@ -513,7 +510,7 @@ class RowIndex(tk.Canvas):
513
510
  if self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
514
511
  y = self.canvasy(event.y)
515
512
  size = y - self.MT.row_positions[self.rsz_h - 1]
516
- if size >= self.MT.min_row_height and size < self.MT.max_row_height:
513
+ if size >= self.MT.min_row_height and size < self.PAR.ops.max_row_height:
517
514
  self.hide_resize_and_ctrl_lines(ctrl_lines=False)
518
515
  line2y = self.MT.row_positions[self.rsz_h - 1]
519
516
  self.create_resize_line(
@@ -548,18 +545,14 @@ class RowIndex(tk.Canvas):
548
545
  elif self.width_resizing_enabled and self.rsz_w is not None and self.currently_resizing_width:
549
546
  evx = event.x
550
547
  if evx > self.current_width:
551
- x = self.MT.canvasx(evx - self.current_width)
552
- if evx > self.MT.max_index_width:
553
- evx = int(self.MT.max_index_width)
554
- x = self.MT.canvasx(evx - self.current_width)
555
- self.new_row_width = evx
548
+ if evx > self.PAR.ops.max_index_width:
549
+ evx = int(self.PAR.ops.max_index_width)
550
+ self.drag_width_resize(evx)
556
551
  else:
557
- x = evx
558
- if x < self.MT.min_column_width:
559
- x = int(self.MT.min_column_width)
560
- self.new_row_width = x
561
- self.drag_width_resize()
562
- if (
552
+ if evx < self.PAR.ops.min_column_width:
553
+ evx = self.PAR.ops.min_column_width
554
+ self.drag_width_resize(evx)
555
+ elif (
563
556
  self.drag_and_drop_enabled
564
557
  and self.row_selection_enabled
565
558
  and self.MT.anything_selected(exclude_cells=True, exclude_columns=True)
@@ -777,9 +770,9 @@ class RowIndex(tk.Canvas):
777
770
  and event.x < self.MT.index_txt_height + 4
778
771
  )
779
772
 
780
- def drag_width_resize(self) -> None:
781
- self.set_width(self.new_row_width, set_TL=True)
782
- self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
773
+ def drag_width_resize(self, width: int) -> None:
774
+ self.set_width(width, set_TL=True)
775
+ self.MT.main_table_redraw_grid_and_text(redraw_header=False, redraw_row_index=True, redraw_table=False)
783
776
 
784
777
  def drag_height_resize(self) -> None:
785
778
  new_row_pos = int(self.coords("rhl")[1])
@@ -787,8 +780,8 @@ class RowIndex(tk.Canvas):
787
780
  size = new_row_pos - self.MT.row_positions[self.rsz_h - 1]
788
781
  if size < self.MT.min_row_height:
789
782
  new_row_pos = ceil(self.MT.row_positions[self.rsz_h - 1] + self.MT.min_row_height)
790
- elif size > self.MT.max_row_height:
791
- new_row_pos = floor(self.MT.row_positions[self.rsz_h - 1] + self.MT.max_row_height)
783
+ elif size > self.PAR.ops.max_row_height:
784
+ new_row_pos = floor(self.MT.row_positions[self.rsz_h - 1] + self.PAR.ops.max_row_height)
792
785
  increment = new_row_pos - self.MT.row_positions[self.rsz_h]
793
786
  self.MT.row_positions[self.rsz_h + 1 :] = [
794
787
  e + increment for e in islice(self.MT.row_positions, self.rsz_h + 1, None)
@@ -808,28 +801,22 @@ class RowIndex(tk.Canvas):
808
801
  )
809
802
 
810
803
  def b1_release(self, event: object) -> None:
804
+ to_hide = self.being_drawn_item
811
805
  if self.being_drawn_item is not None and (to_sel := self.MT.coords_and_type(self.being_drawn_item)):
812
806
  r_to_sel, c_to_sel = self.MT.selected.row, self.MT.selected.column
813
- self.MT.hide_selection_box(self.being_drawn_item)
807
+ self.being_drawn_item = None
814
808
  self.MT.set_currently_selected(
815
809
  r_to_sel,
816
810
  c_to_sel,
817
811
  item=self.MT.create_selection_box(*to_sel, set_current=False),
812
+ run_binding=False,
818
813
  )
819
- sel_event = self.MT.get_select_event(being_drawn_item=self.being_drawn_item)
820
- try_binding(self.drag_selection_binding_func, sel_event)
821
- self.PAR.emit_event("<<SheetSelect>>", data=sel_event)
822
- else:
823
- self.being_drawn_item = None
814
+ self.MT.hide_selection_box(to_hide)
824
815
  self.MT.bind("<MouseWheel>", self.MT.mousewheel)
825
816
  if self.height_resizing_enabled and self.rsz_h is not None and self.currently_resizing_height:
826
817
  self.drag_height_resize()
827
- self.currently_resizing_height = False
828
818
  self.hide_resize_and_ctrl_lines(ctrl_lines=False)
829
- elif self.width_resizing_enabled and self.rsz_w is not None and self.currently_resizing_width:
830
- self.currently_resizing_width = False
831
- self.drag_width_resize()
832
- if (
819
+ elif (
833
820
  self.drag_and_drop_enabled
834
821
  and self.MT.anything_selected(exclude_cells=True, exclude_columns=True)
835
822
  and self.row_selection_enabled
@@ -1094,8 +1081,8 @@ class RowIndex(tk.Canvas):
1094
1081
  return self.MT.row_positions[row + 1] - self.MT.row_positions[row]
1095
1082
  if h < self.MT.min_row_height:
1096
1083
  h = int(self.MT.min_row_height)
1097
- elif h > self.MT.max_row_height:
1098
- h = int(self.MT.max_row_height)
1084
+ elif h > self.PAR.ops.max_row_height:
1085
+ h = int(self.PAR.ops.max_row_height)
1099
1086
  return h
1100
1087
 
1101
1088
  def set_row_height(
@@ -1110,8 +1097,8 @@ class RowIndex(tk.Canvas):
1110
1097
  height = self.get_row_text_height(row=row, visible_only=visible_only)
1111
1098
  if height < self.MT.min_row_height:
1112
1099
  height = int(self.MT.min_row_height)
1113
- elif height > self.MT.max_row_height:
1114
- height = int(self.MT.max_row_height)
1100
+ elif height > self.PAR.ops.max_row_height:
1101
+ height = int(self.PAR.ops.max_row_height)
1115
1102
  if only_if_too_small and height <= self.MT.row_positions[row + 1] - self.MT.row_positions[row]:
1116
1103
  return self.MT.row_positions[row + 1] - self.MT.row_positions[row]
1117
1104
  new_row_pos = self.MT.row_positions[row] + height
@@ -1145,8 +1132,8 @@ class RowIndex(tk.Canvas):
1145
1132
  iterable = self.MT.displayed_rows
1146
1133
  if (new_w := max(map(itemgetter(0), map(self.get_cell_dimensions, iterable)), default=w)) > w:
1147
1134
  w = new_w
1148
- if w > self.MT.max_index_width:
1149
- w = int(self.MT.max_index_width)
1135
+ if w > self.PAR.ops.max_index_width:
1136
+ w = int(self.PAR.ops.max_index_width)
1150
1137
  return w
1151
1138
 
1152
1139
  def set_width_of_index_to_text(
@@ -1167,8 +1154,8 @@ class RowIndex(tk.Canvas):
1167
1154
  w = tw
1168
1155
  elif text is None:
1169
1156
  w = self.get_index_text_width(only_rows=only_rows)
1170
- if w > self.MT.max_index_width:
1171
- w = int(self.MT.max_index_width)
1157
+ if w > self.PAR.ops.max_index_width:
1158
+ w = int(self.PAR.ops.max_index_width)
1172
1159
  self.set_width(w, set_TL=True)
1173
1160
  self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
1174
1161
  return w
@@ -1639,7 +1626,7 @@ class RowIndex(tk.Canvas):
1639
1626
  outline=fill,
1640
1627
  tag="dd",
1641
1628
  draw_outline=not dd_drawn,
1642
- draw_arrow=mw >= 5,
1629
+ draw_arrow=True,
1643
1630
  open_=dd_coords == r,
1644
1631
  )
1645
1632
  else:
@@ -1658,7 +1645,7 @@ class RowIndex(tk.Canvas):
1658
1645
  outline=fill,
1659
1646
  tag="dd",
1660
1647
  draw_outline=not dd_drawn,
1661
- draw_arrow=mw >= 5,
1648
+ draw_arrow=True,
1662
1649
  open_=dd_coords == r,
1663
1650
  )
1664
1651
  else:
@@ -1678,7 +1665,7 @@ class RowIndex(tk.Canvas):
1678
1665
  outline=fill,
1679
1666
  tag="dd",
1680
1667
  draw_outline=not dd_drawn,
1681
- draw_arrow=mw >= 5,
1668
+ draw_arrow=True,
1682
1669
  open_=dd_coords == r,
1683
1670
  )
1684
1671
  else:
@@ -1787,7 +1774,7 @@ class RowIndex(tk.Canvas):
1787
1774
  txt = txt[:-1]
1788
1775
  self.itemconfig(iid, text=txt)
1789
1776
  wd = self.bbox(iid)
1790
- elif align == "e" and (dropdown_kwargs or checkbox_kwargs):
1777
+ elif align == "e" and checkbox_kwargs:
1791
1778
  txt = txt[len(txt) - int(len(txt) * (mw / wd)) :]
1792
1779
  self.itemconfig(iid, text=txt)
1793
1780
  wd = self.bbox(iid)
@@ -1926,7 +1913,6 @@ class RowIndex(tk.Canvas):
1926
1913
  h = self.MT.row_positions[r + 1] - y + 1
1927
1914
  if text is None:
1928
1915
  text = self.get_cell_data(self.MT.datarn(r), none_to_empty_str=True, redirect_int=True)
1929
- bg, fg = self.PAR.ops.index_bg, self.PAR.ops.index_fg
1930
1916
  kwargs = {
1931
1917
  "menu_kwargs": DotDict(
1932
1918
  {
@@ -1944,8 +1930,10 @@ class RowIndex(tk.Canvas):
1944
1930
  "width": w,
1945
1931
  "height": h,
1946
1932
  "show_border": True,
1947
- "bg": bg,
1948
- "fg": fg,
1933
+ "bg": self.PAR.ops.index_editor_bg,
1934
+ "fg": self.PAR.ops.index_editor_fg,
1935
+ "select_bg": self.PAR.ops.index_editor_select_bg,
1936
+ "select_fg": self.PAR.ops.index_editor_select_fg,
1949
1937
  "align": self.get_cell_align(r),
1950
1938
  "r": r,
1951
1939
  }
@@ -2160,22 +2148,15 @@ class RowIndex(tk.Canvas):
2160
2148
  selected=self.MT.selected,
2161
2149
  )
2162
2150
  try_binding(self.dropdown.window.modified_function, event_data)
2163
- val = self.dropdown.window.search_and_see(event_data)
2164
2151
  # return to tk.Text action if control/command is held down
2165
2152
  # or keysym was not a character
2166
2153
  if (hasattr(event, "state") and event.state & (0x0004 | 0x00000010)) or (
2167
- hasattr(event, "keysym") and len(event.keysym) > 2
2154
+ hasattr(event, "keysym") and len(event.keysym) > 2 and event.keysym != "space"
2168
2155
  ):
2169
2156
  return
2170
- self.text_editor.tktext.unbind("<KeyRelease>")
2171
- self.text_editor.autocomplete(val)
2172
- self.text_editor.tktext.bind(
2173
- "<KeyRelease>",
2174
- self.dropdown_text_editor_modified,
2175
- )
2157
+ self.text_editor.autocomplete(self.dropdown.window.search_and_see(event_data))
2176
2158
  return "break"
2177
2159
 
2178
- # r is displayed row
2179
2160
  def open_dropdown_window(self, r: int, event: object = None) -> None:
2180
2161
  self.hide_text_editor()
2181
2162
  kwargs = self.get_cell_kwargs(self.MT.datarn(r), key="dropdown")
@@ -2196,6 +2177,10 @@ class RowIndex(tk.Canvas):
2196
2177
  reset_kwargs = {
2197
2178
  "r": r,
2198
2179
  "c": 0,
2180
+ "bg": self.PAR.ops.index_editor_bg,
2181
+ "fg": self.PAR.ops.index_editor_fg,
2182
+ "select_bg": self.PAR.ops.index_editor_select_bg,
2183
+ "select_fg": self.PAR.ops.index_editor_select_fg,
2199
2184
  "width": win_w,
2200
2185
  "height": win_h,
2201
2186
  "font": self.PAR.ops.index_font,
@@ -2225,12 +2210,12 @@ class RowIndex(tk.Canvas):
2225
2210
  window=self.dropdown.window,
2226
2211
  anchor=anchor,
2227
2212
  )
2213
+ self.update_idletasks()
2228
2214
  if kwargs["state"] == "normal":
2229
2215
  self.text_editor.tktext.bind(
2230
2216
  "<KeyRelease>",
2231
2217
  self.dropdown_text_editor_modified,
2232
2218
  )
2233
- self.update_idletasks()
2234
2219
  try:
2235
2220
  self.after(1, lambda: self.text_editor.tktext.focus())
2236
2221
  self.after(2, self.text_editor.window.scroll_to_bottom())
@@ -2238,7 +2223,6 @@ class RowIndex(tk.Canvas):
2238
2223
  return
2239
2224
  redraw = False
2240
2225
  else:
2241
- self.update_idletasks()
2242
2226
  self.dropdown.window.bind("<FocusOut>", lambda _x: self.close_dropdown_window(r))
2243
2227
  self.dropdown.window.bind("<Escape>", self.close_dropdown_window)
2244
2228
  self.dropdown.window.focus_set()
tksheet/sheet.py CHANGED
@@ -126,10 +126,11 @@ class Sheet(tk.Frame):
126
126
  default_header_height: str | int = "1",
127
127
  default_row_index_width: int = 70,
128
128
  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",
129
+ min_column_width: int = 1,
130
+ max_column_width: float = float("inf"),
131
+ max_row_height: float = float("inf"),
132
+ max_header_height: float = float("inf"),
133
+ max_index_width: float = float("inf"),
133
134
  after_redraw_time_ms: int = 20,
134
135
  set_all_heights_and_widths: bool = False,
135
136
  zoom: int = 100,
@@ -200,8 +201,8 @@ class Sheet(tk.Frame):
200
201
  alternate_color: str = "",
201
202
  # colors
202
203
  outline_thickness: int = 0,
203
- outline_color: str = theme_light_blue["outline_color"],
204
204
  theme: str = "light blue",
205
+ outline_color: str = theme_light_blue["outline_color"],
205
206
  frame_bg: str = theme_light_blue["table_bg"],
206
207
  popup_menu_fg: str = theme_light_blue["popup_menu_fg"],
207
208
  popup_menu_bg: str = theme_light_blue["popup_menu_bg"],
@@ -210,6 +211,10 @@ class Sheet(tk.Frame):
210
211
  table_grid_fg: str = theme_light_blue["table_grid_fg"],
211
212
  table_bg: str = theme_light_blue["table_bg"],
212
213
  table_fg: str = theme_light_blue["table_fg"],
214
+ table_editor_bg: str = theme_light_blue["table_editor_bg"],
215
+ table_editor_fg: str = theme_light_blue["table_editor_fg"],
216
+ table_editor_select_bg: str = theme_light_blue["table_editor_select_bg"],
217
+ table_editor_select_fg: str = theme_light_blue["table_editor_select_fg"],
213
218
  table_selected_box_cells_fg: str = theme_light_blue["table_selected_box_cells_fg"],
214
219
  table_selected_box_rows_fg: str = theme_light_blue["table_selected_box_rows_fg"],
215
220
  table_selected_box_columns_fg: str = theme_light_blue["table_selected_box_columns_fg"],
@@ -228,6 +233,10 @@ class Sheet(tk.Frame):
228
233
  index_border_fg: str = theme_light_blue["index_border_fg"],
229
234
  index_grid_fg: str = theme_light_blue["index_grid_fg"],
230
235
  index_fg: str = theme_light_blue["index_fg"],
236
+ index_editor_bg: str = theme_light_blue["index_editor_bg"],
237
+ index_editor_fg: str = theme_light_blue["index_editor_fg"],
238
+ index_editor_select_bg: str = theme_light_blue["index_editor_select_bg"],
239
+ index_editor_select_fg: str = theme_light_blue["index_editor_select_fg"],
231
240
  index_selected_cells_bg: str = theme_light_blue["index_selected_cells_bg"],
232
241
  index_selected_cells_fg: str = theme_light_blue["index_selected_cells_fg"],
233
242
  index_selected_rows_bg: str = theme_light_blue["index_selected_rows_bg"],
@@ -237,6 +246,10 @@ class Sheet(tk.Frame):
237
246
  header_border_fg: str = theme_light_blue["header_border_fg"],
238
247
  header_grid_fg: str = theme_light_blue["header_grid_fg"],
239
248
  header_fg: str = theme_light_blue["header_fg"],
249
+ header_editor_bg: str = theme_light_blue["header_editor_bg"],
250
+ header_editor_fg: str = theme_light_blue["header_editor_fg"],
251
+ header_editor_select_bg: str = theme_light_blue["header_editor_select_bg"],
252
+ header_editor_select_fg: str = theme_light_blue["header_editor_select_fg"],
240
253
  header_selected_cells_bg: str = theme_light_blue["header_selected_cells_bg"],
241
254
  header_selected_cells_fg: str = theme_light_blue["header_selected_cells_fg"],
242
255
  header_selected_columns_bg: str = theme_light_blue["header_selected_columns_bg"],
@@ -259,10 +272,6 @@ class Sheet(tk.Frame):
259
272
  horizontal_scroll_troughrelief: str = theme_light_blue["horizontal_scroll_troughrelief"],
260
273
  vertical_scroll_bordercolor: str = theme_light_blue["vertical_scroll_bordercolor"],
261
274
  horizontal_scroll_bordercolor: str = theme_light_blue["horizontal_scroll_bordercolor"],
262
- vertical_scroll_borderwidth: int = 1,
263
- horizontal_scroll_borderwidth: int = 1,
264
- vertical_scroll_gripcount: int = 0,
265
- horizontal_scroll_gripcount: int = 0,
266
275
  vertical_scroll_active_bg: str = theme_light_blue["vertical_scroll_active_bg"],
267
276
  horizontal_scroll_active_bg: str = theme_light_blue["horizontal_scroll_active_bg"],
268
277
  vertical_scroll_not_active_bg: str = theme_light_blue["vertical_scroll_not_active_bg"],
@@ -275,6 +284,10 @@ class Sheet(tk.Frame):
275
284
  horizontal_scroll_not_active_fg: str = theme_light_blue["horizontal_scroll_not_active_fg"],
276
285
  vertical_scroll_pressed_fg: str = theme_light_blue["vertical_scroll_pressed_fg"],
277
286
  horizontal_scroll_pressed_fg: str = theme_light_blue["horizontal_scroll_pressed_fg"],
287
+ vertical_scroll_borderwidth: int = 1,
288
+ horizontal_scroll_borderwidth: int = 1,
289
+ vertical_scroll_gripcount: int = 0,
290
+ horizontal_scroll_gripcount: int = 0,
278
291
  scrollbar_theme_inheritance: str = "default",
279
292
  scrollbar_show_arrows: bool = True,
280
293
  # changing the arrowsize (width) of the scrollbars
@@ -351,10 +364,6 @@ class Sheet(tk.Frame):
351
364
  )
352
365
  self.MT = MainTable(
353
366
  parent=self,
354
- max_column_width=max_column_width,
355
- max_header_height=max_header_height,
356
- max_row_height=max_row_height,
357
- max_index_width=max_index_width,
358
367
  show_index=show_row_index,
359
368
  show_header=show_header,
360
369
  column_headers_canvas=self.CH,
@@ -1035,6 +1044,21 @@ class Sheet(tk.Frame):
1035
1044
  func: Callable,
1036
1045
  add: str | None = None,
1037
1046
  ) -> Sheet:
1047
+ """
1048
+ In addition to normal use, the following special tksheet bindings can be used:
1049
+ - "<<SheetModified>>"
1050
+ - "<<SheetRedrawn>>"
1051
+ - "<<SheetSelect>>"
1052
+ - "<<Copy>>"
1053
+ - "<<Cut>>"
1054
+ - "<<Paste>>"
1055
+ - "<<Delete>>"
1056
+ - "<<Undo>>"
1057
+ - "<<Redo>>"
1058
+ - "<<SelectAll>>"
1059
+
1060
+ Use `add` parameter to bind to multiple functions
1061
+ """
1038
1062
  if binding == "<ButtonPress-1>":
1039
1063
  self.MT.extra_b1_press_func = func
1040
1064
  self.CH.extra_b1_press_func = func
@@ -3770,25 +3794,25 @@ class Sheet(tk.Frame):
3770
3794
  if column_widths[0] != 0:
3771
3795
  return False
3772
3796
  return not any(
3773
- x - z < self.MT.min_column_width or not isinstance(x, int) or isinstance(x, bool)
3797
+ x - z < self.ops.min_column_width or not isinstance(x, int) or isinstance(x, bool)
3774
3798
  for z, x in zip(column_widths, islice(column_widths, 1, None))
3775
3799
  )
3776
3800
  return not any(
3777
- z < self.MT.min_column_width or not isinstance(z, int) or isinstance(z, bool) for z in column_widths
3801
+ z < self.ops.min_column_width or not isinstance(z, int) or isinstance(z, bool) for z in column_widths
3778
3802
  )
3779
3803
 
3780
3804
  def valid_row_height(self, height: int) -> int:
3781
3805
  if height < self.MT.min_row_height:
3782
3806
  return self.MT.min_row_height
3783
- elif height > self.MT.max_row_height:
3784
- return self.MT.max_row_height
3807
+ elif height > self.ops.max_row_height:
3808
+ return self.ops.max_row_height
3785
3809
  return height
3786
3810
 
3787
3811
  def valid_column_width(self, width: int) -> int:
3788
- if width < self.MT.min_column_width:
3789
- return self.MT.min_column_width
3790
- elif width > self.MT.max_column_width:
3791
- return self.MT.max_column_width
3812
+ if width < self.ops.min_column_width:
3813
+ return self.ops.min_column_width
3814
+ elif width > self.ops.max_column_width:
3815
+ return self.ops.max_column_width
3792
3816
  return width
3793
3817
 
3794
3818
  @property
@@ -4413,6 +4437,10 @@ class Sheet(tk.Frame):
4413
4437
  self.ops[k] = v
4414
4438
  if k.endswith("bindings"):
4415
4439
  self.MT._enable_binding(k.split("_")[0])
4440
+ if "name" in kwargs:
4441
+ self.name = kwargs["name"]
4442
+ if "min_column_width" in kwargs:
4443
+ self.MT.set_min_column_width(kwargs["min_column_width"])
4416
4444
  if "from_clipboard_delimiters" in kwargs:
4417
4445
  self.ops.from_clipboard_delimiters = (
4418
4446
  self.ops.from_clipboard_delimiters
@@ -4421,14 +4449,6 @@ class Sheet(tk.Frame):
4421
4449
  )
4422
4450
  if "default_row_height" in kwargs:
4423
4451
  self.default_row_height(kwargs["default_row_height"])
4424
- if "max_column_width" in kwargs:
4425
- self.MT.max_column_width = float(kwargs["max_column_width"])
4426
- if "max_row_height" in kwargs:
4427
- self.MT.max_row_height = float(kwargs["max_row_height"])
4428
- if "max_header_height" in kwargs:
4429
- self.MT.max_header_height = float(kwargs["max_header_height"])
4430
- if "max_index_width" in kwargs:
4431
- self.MT.max_index_width = float(kwargs["max_index_width"])
4432
4452
  if "expand_sheet_if_paste_too_big" in kwargs:
4433
4453
  self.ops.paste_can_expand_x = kwargs["expand_sheet_if_paste_too_big"]
4434
4454
  self.ops.paste_can_expand_y = kwargs["expand_sheet_if_paste_too_big"]
@@ -4467,7 +4487,6 @@ class Sheet(tk.Frame):
4467
4487
  self.set_scrollbar_options()
4468
4488
  self.MT.create_rc_menus()
4469
4489
  if "treeview" in kwargs:
4470
- self.set_options(auto_resize_row_index=True, redraw=False)
4471
4490
  self.index_align("w", redraw=False)
4472
4491
  return self.set_refresh_timer(redraw)
4473
4492
 
@@ -7149,6 +7168,10 @@ class Dropdown(Sheet):
7149
7168
  parent: tk.Misc,
7150
7169
  r: int,
7151
7170
  c: int,
7171
+ bg: str,
7172
+ fg: str,
7173
+ select_bg: str,
7174
+ select_fg: str,
7152
7175
  ops: dict,
7153
7176
  outline_color: str,
7154
7177
  width: int | None = None,
@@ -7187,8 +7210,6 @@ class Dropdown(Sheet):
7187
7210
  )
7188
7211
  self.parent = parent
7189
7212
  self.close_dropdown_window = close_dropdown_window
7190
- self.search_function = search_function
7191
- self.modified_function = modified_function
7192
7213
  self.arrowkey_RIGHT = arrowkey_RIGHT
7193
7214
  self.arrowkey_LEFT = arrowkey_LEFT
7194
7215
  self.single_index = single_index
@@ -7202,12 +7223,32 @@ class Dropdown(Sheet):
7202
7223
  self.bind("<Prior>", self.arrowkey_UP)
7203
7224
  self.bind("<Next>", self.arrowkey_DOWN)
7204
7225
  self.bind("<Return>", self.b1)
7205
- self.reset(r, c, width, height, font, ops, outline_color, align, values)
7226
+ self.reset(
7227
+ r=r,
7228
+ c=c,
7229
+ bg=bg,
7230
+ fg=fg,
7231
+ select_bg=select_bg,
7232
+ select_fg=select_fg,
7233
+ width=width,
7234
+ height=height,
7235
+ font=font,
7236
+ ops=ops,
7237
+ outline_color=outline_color,
7238
+ align=align,
7239
+ values=values,
7240
+ search_function=search_function,
7241
+ modified_function=modified_function,
7242
+ )
7206
7243
 
7207
7244
  def reset(
7208
7245
  self,
7209
7246
  r: int,
7210
7247
  c: int,
7248
+ bg: str,
7249
+ fg: str,
7250
+ select_bg: str,
7251
+ select_fg: str,
7211
7252
  width: int,
7212
7253
  height: int,
7213
7254
  font: tuple[str, int, str],
@@ -7228,17 +7269,17 @@ class Dropdown(Sheet):
7228
7269
  self.table_align(align)
7229
7270
  self.set_options(
7230
7271
  outline_color=outline_color,
7231
- table_grid_fg=ops.popup_menu_fg,
7232
- table_selected_cells_border_fg=ops.popup_menu_fg,
7233
- table_selected_cells_bg=ops.popup_menu_highlight_bg,
7234
- table_selected_rows_border_fg=ops.popup_menu_fg,
7235
- table_selected_rows_bg=ops.popup_menu_highlight_bg,
7236
- table_selected_rows_fg=ops.popup_menu_highlight_fg,
7237
- table_selected_box_cells_fg=ops.popup_menu_highlight_bg,
7238
- table_selected_box_rows_fg=ops.popup_menu_highlight_bg,
7272
+ table_grid_fg=fg,
7273
+ table_selected_cells_border_fg=fg,
7274
+ table_selected_cells_bg=select_bg,
7275
+ table_selected_rows_border_fg=fg,
7276
+ table_selected_rows_bg=select_bg,
7277
+ table_selected_rows_fg=select_fg,
7278
+ table_selected_box_cells_fg=select_bg,
7279
+ table_selected_box_rows_fg=select_bg,
7239
7280
  font=font,
7240
- table_fg=ops.popup_menu_fg,
7241
- table_bg=ops.popup_menu_bg,
7281
+ table_fg=fg,
7282
+ table_bg=bg,
7242
7283
  **{k: ops[k] for k in scrollbar_options_keys},
7243
7284
  )
7244
7285
  self.values(values, width=width - self.yscroll.winfo_width() - 4)
tksheet/sheet_options.py CHANGED
@@ -16,6 +16,7 @@ from .vars import (
16
16
  def new_sheet_options() -> DotDict:
17
17
  return DotDict(
18
18
  {
19
+ **theme_light_blue,
19
20
  "popup_menu_font": FontTuple(
20
21
  "Calibri",
21
22
  13 if USER_OS == "darwin" else 11,
@@ -136,78 +137,6 @@ def new_sheet_options() -> DotDict:
136
137
  "next_bindings": [
137
138
  "<Next>",
138
139
  ],
139
- "popup_menu_fg": theme_light_blue["popup_menu_fg"],
140
- "popup_menu_bg": theme_light_blue["popup_menu_bg"],
141
- "popup_menu_highlight_bg": theme_light_blue["popup_menu_highlight_bg"],
142
- "popup_menu_highlight_fg": theme_light_blue["popup_menu_highlight_fg"],
143
- "index_hidden_rows_expander_bg": theme_light_blue["index_hidden_rows_expander_bg"],
144
- "header_hidden_columns_expander_bg": theme_light_blue["header_hidden_columns_expander_bg"],
145
- "header_bg": theme_light_blue["header_bg"],
146
- "header_border_fg": theme_light_blue["header_border_fg"],
147
- "header_grid_fg": theme_light_blue["header_grid_fg"],
148
- "header_fg": theme_light_blue["header_fg"],
149
- "header_selected_cells_bg": theme_light_blue["header_selected_cells_bg"],
150
- "header_selected_cells_fg": theme_light_blue["header_selected_cells_fg"],
151
- "index_bg": theme_light_blue["index_bg"],
152
- "index_border_fg": theme_light_blue["index_border_fg"],
153
- "index_grid_fg": theme_light_blue["index_grid_fg"],
154
- "index_fg": theme_light_blue["index_fg"],
155
- "index_selected_cells_bg": theme_light_blue["index_selected_cells_bg"],
156
- "index_selected_cells_fg": theme_light_blue["index_selected_cells_fg"],
157
- "top_left_bg": theme_light_blue["top_left_bg"],
158
- "top_left_fg": theme_light_blue["top_left_fg"],
159
- "top_left_fg_highlight": theme_light_blue["top_left_fg_highlight"],
160
- "table_bg": theme_light_blue["table_bg"],
161
- "table_grid_fg": theme_light_blue["table_grid_fg"],
162
- "table_fg": theme_light_blue["table_fg"],
163
- "tree_arrow_fg": theme_light_blue["tree_arrow_fg"],
164
- "selected_cells_tree_arrow_fg": theme_light_blue["selected_cells_tree_arrow_fg"],
165
- "selected_rows_tree_arrow_fg": theme_light_blue["selected_rows_tree_arrow_fg"],
166
- "table_selected_box_cells_fg": theme_light_blue["table_selected_box_cells_fg"],
167
- "table_selected_box_rows_fg": theme_light_blue["table_selected_box_rows_fg"],
168
- "table_selected_box_columns_fg": theme_light_blue["table_selected_box_columns_fg"],
169
- "table_selected_cells_border_fg": theme_light_blue["table_selected_cells_border_fg"],
170
- "table_selected_cells_bg": theme_light_blue["table_selected_cells_bg"],
171
- "table_selected_cells_fg": theme_light_blue["table_selected_cells_fg"],
172
- "resizing_line_fg": theme_light_blue["resizing_line_fg"],
173
- "drag_and_drop_bg": theme_light_blue["drag_and_drop_bg"],
174
- "outline_color": theme_light_blue["outline_color"],
175
- "header_selected_columns_bg": theme_light_blue["header_selected_columns_bg"],
176
- "header_selected_columns_fg": theme_light_blue["header_selected_columns_fg"],
177
- "index_selected_rows_bg": theme_light_blue["index_selected_rows_bg"],
178
- "index_selected_rows_fg": theme_light_blue["index_selected_rows_fg"],
179
- "table_selected_rows_border_fg": theme_light_blue["table_selected_rows_border_fg"],
180
- "table_selected_rows_bg": theme_light_blue["table_selected_rows_bg"],
181
- "table_selected_rows_fg": theme_light_blue["table_selected_rows_fg"],
182
- "table_selected_columns_border_fg": theme_light_blue["table_selected_columns_border_fg"],
183
- "table_selected_columns_bg": theme_light_blue["table_selected_columns_bg"],
184
- "table_selected_columns_fg": theme_light_blue["table_selected_columns_fg"],
185
- "vertical_scroll_background": theme_light_blue["vertical_scroll_background"],
186
- "horizontal_scroll_background": theme_light_blue["horizontal_scroll_background"],
187
- "vertical_scroll_troughcolor": theme_light_blue["vertical_scroll_troughcolor"],
188
- "horizontal_scroll_troughcolor": theme_light_blue["horizontal_scroll_troughcolor"],
189
- "vertical_scroll_lightcolor": theme_light_blue["vertical_scroll_lightcolor"],
190
- "horizontal_scroll_lightcolor": theme_light_blue["horizontal_scroll_lightcolor"],
191
- "vertical_scroll_darkcolor": theme_light_blue["vertical_scroll_darkcolor"],
192
- "horizontal_scroll_darkcolor": theme_light_blue["horizontal_scroll_darkcolor"],
193
- "vertical_scroll_relief": theme_light_blue["vertical_scroll_relief"],
194
- "horizontal_scroll_relief": theme_light_blue["horizontal_scroll_relief"],
195
- "vertical_scroll_troughrelief": theme_light_blue["vertical_scroll_troughrelief"],
196
- "horizontal_scroll_troughrelief": theme_light_blue["horizontal_scroll_troughrelief"],
197
- "vertical_scroll_bordercolor": theme_light_blue["vertical_scroll_bordercolor"],
198
- "horizontal_scroll_bordercolor": theme_light_blue["horizontal_scroll_bordercolor"],
199
- "vertical_scroll_active_bg": theme_light_blue["vertical_scroll_active_bg"],
200
- "horizontal_scroll_active_bg": theme_light_blue["horizontal_scroll_active_bg"],
201
- "vertical_scroll_not_active_bg": theme_light_blue["vertical_scroll_not_active_bg"],
202
- "horizontal_scroll_not_active_bg": theme_light_blue["horizontal_scroll_not_active_bg"],
203
- "vertical_scroll_pressed_bg": theme_light_blue["vertical_scroll_pressed_bg"],
204
- "horizontal_scroll_pressed_bg": theme_light_blue["horizontal_scroll_pressed_bg"],
205
- "vertical_scroll_active_fg": theme_light_blue["vertical_scroll_active_fg"],
206
- "horizontal_scroll_active_fg": theme_light_blue["horizontal_scroll_active_fg"],
207
- "vertical_scroll_not_active_fg": theme_light_blue["vertical_scroll_not_active_fg"],
208
- "horizontal_scroll_not_active_fg": theme_light_blue["horizontal_scroll_not_active_fg"],
209
- "vertical_scroll_pressed_fg": theme_light_blue["vertical_scroll_pressed_fg"],
210
- "horizontal_scroll_pressed_fg": theme_light_blue["horizontal_scroll_pressed_fg"],
211
140
  "vertical_scroll_borderwidth": 1,
212
141
  "horizontal_scroll_borderwidth": 1,
213
142
  "vertical_scroll_gripcount": 0,
@@ -257,5 +186,10 @@ def new_sheet_options() -> DotDict:
257
186
  "treeview_indent": "5",
258
187
  "rounded_boxes": True,
259
188
  "alternate_color": "",
189
+ "min_column_width": 1,
190
+ "max_column_width": float("inf"),
191
+ "max_header_height": float("inf"),
192
+ "max_row_height": float("inf"),
193
+ "max_index_width": float("inf"),
260
194
  }
261
195
  )