tksheet 7.2.11__py3-none-any.whl → 7.2.12__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.2.11"
7
+ __version__ = "7.2.12"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
tksheet/column_headers.py CHANGED
@@ -599,7 +599,7 @@ class ColumnHeaders(tk.Canvas):
599
599
  if need_redraw:
600
600
  self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=False)
601
601
  try_binding(self.extra_b1_motion_func, event)
602
-
602
+
603
603
  def drag_height_resize(self) -> None:
604
604
  self.set_height(self.new_col_height, set_TL=True)
605
605
  self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
@@ -2176,7 +2176,16 @@ class ColumnHeaders(tk.Canvas):
2176
2176
  )
2177
2177
  edited = False
2178
2178
  if isinstance(self.MT._headers, int):
2179
- edited = self.MT.set_cell_data_undo(r=self.MT._headers, c=c, datacn=datacn, value=value, undo=True)
2179
+ disprn = self.MT.try_disprn(self.MT._headers)
2180
+ edited = self.MT.set_cell_data_undo(
2181
+ r=disprn if isinstance(disprn, int) else 0,
2182
+ c=c,
2183
+ datarn=self.MT._headers,
2184
+ datacn=datacn,
2185
+ value=value,
2186
+ undo=True,
2187
+ cell_resize=isinstance(disprn, int),
2188
+ )
2180
2189
  else:
2181
2190
  self.fix_header(datacn)
2182
2191
  if not check_input_valid or self.input_valid_for_cell(datacn, value):
tksheet/functions.py CHANGED
@@ -1,12 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
- import bisect
4
3
  import csv
5
4
  import io
6
5
  import pickle
7
6
  import re
8
7
  import tkinter as tk
9
8
  import zlib
9
+ from bisect import (
10
+ bisect_left,
11
+ )
10
12
  from collections import deque
11
13
  from collections.abc import (
12
14
  Callable,
@@ -208,6 +210,16 @@ def len_to_idx(n: int) -> int:
208
210
  return n - 1
209
211
 
210
212
 
213
+ def b_index(sorted_seq: Sequence[int], num_to_index: int) -> int:
214
+ """
215
+ Designed to be a faster way of finding the index of an int
216
+ in a sorted list of ints than list.index()
217
+ """
218
+ if (idx := bisect_left(sorted_seq, num_to_index)) == len(sorted_seq) or sorted_seq[idx] != num_to_index:
219
+ raise ValueError(f"{num_to_index} is not in Sequence")
220
+ return idx
221
+
222
+
211
223
  def get_dropdown_kwargs(
212
224
  values: list = [],
213
225
  set_value: object = None,
@@ -379,7 +391,7 @@ def get_seq_without_gaps_at_index(
379
391
  position: int,
380
392
  get_st_end: bool = False,
381
393
  ) -> tuple[int, int] | list[int]:
382
- start_idx = bisect.bisect_left(seq, position)
394
+ start_idx = bisect_left(seq, position)
383
395
  forward_gap = get_index_of_gap_in_sorted_integer_seq_forward(seq, start_idx)
384
396
  reverse_gap = get_index_of_gap_in_sorted_integer_seq_reverse(seq, start_idx)
385
397
  if forward_gap is not None:
tksheet/main_table.py CHANGED
@@ -49,6 +49,7 @@ from .formatters import (
49
49
  try_to_bool,
50
50
  )
51
51
  from .functions import (
52
+ b_index,
52
53
  consecutive_ranges,
53
54
  decompress_load,
54
55
  diff_gen,
@@ -7460,3 +7461,21 @@ class MainTable(tk.Canvas):
7460
7461
 
7461
7462
  def datarn(self, r: int) -> int:
7462
7463
  return r if self.all_rows_displayed else self.displayed_rows[r]
7464
+
7465
+ def dispcn(self, datacn: int) -> int:
7466
+ return datacn if self.all_columns_displayed else b_index(self.displayed_columns, datacn)
7467
+
7468
+ def try_dispcn(self, datacn: int) -> int | None:
7469
+ try:
7470
+ return self.dispcn(datacn)
7471
+ except Exception:
7472
+ return None
7473
+
7474
+ def disprn(self, datarn: int) -> int:
7475
+ return datarn if self.all_rows_displayed else b_index(self.displayed_rows, datarn)
7476
+
7477
+ def try_disprn(self, datarn: int) -> int | None:
7478
+ try:
7479
+ return self.disprn(datarn)
7480
+ except Exception:
7481
+ return None
tksheet/row_index.py CHANGED
@@ -780,7 +780,7 @@ class RowIndex(tk.Canvas):
780
780
  and self.get_cell_kwargs(datarn, key="checkbox")
781
781
  and event.x < self.MT.index_txt_height + 4
782
782
  )
783
-
783
+
784
784
  def drag_width_resize(self) -> None:
785
785
  self.set_width(self.new_row_width, set_TL=True)
786
786
  self.MT.main_table_redraw_grid_and_text(redraw_header=True, redraw_row_index=True)
@@ -2296,7 +2296,16 @@ class RowIndex(tk.Canvas):
2296
2296
  )
2297
2297
  edited = False
2298
2298
  if isinstance(self.MT._row_index, int):
2299
- edited = self.MT.set_cell_data_undo(r=r, c=self.MT._row_index, datarn=datarn, value=value, undo=True)
2299
+ dispcn = self.MT.try_dispcn(self.MT._row_index)
2300
+ edited = self.MT.set_cell_data_undo(
2301
+ r=r,
2302
+ c=dispcn if isinstance(dispcn, int) else 0,
2303
+ datarn=datarn,
2304
+ datacn=self.MT._row_index,
2305
+ value=value,
2306
+ undo=True,
2307
+ cell_resize=isinstance(dispcn, int),
2308
+ )
2300
2309
  else:
2301
2310
  self.fix_index(datarn)
2302
2311
  if not check_input_valid or self.input_valid_for_cell(datarn, value):
@@ -2431,7 +2440,7 @@ class RowIndex(tk.Canvas):
2431
2440
  elif isinstance(self.MT._row_index, int):
2432
2441
  value = (
2433
2442
  not self.MT.data[datarn][self.MT._row_index]
2434
- if type(self.MT.data[datarn][self.MT._row_index], bool)
2443
+ if isinstance(self.MT.data[datarn][self.MT._row_index], bool)
2435
2444
  else False
2436
2445
  )
2437
2446
  else:
@@ -2476,8 +2485,7 @@ class RowIndex(tk.Canvas):
2476
2485
  if iid not in self.tree_open_ids:
2477
2486
  return False
2478
2487
  return True
2479
- else:
2480
- return all(iid in self.tree_open_ids for iid in self.get_iid_ancestors(iid))
2488
+ return all(map(self.tree_open_ids.__contains__, self.get_iid_ancestors(iid)))
2481
2489
 
2482
2490
  def get_iid_ancestors(self, iid: str) -> Generator[str]:
2483
2491
  if self.tree[iid].parent:
tksheet/sheet.py CHANGED
@@ -1556,7 +1556,7 @@ class Sheet(tk.Frame):
1556
1556
  @data.setter
1557
1557
  def data(self, value: list[list[object]]) -> None:
1558
1558
  self.data_reference(value)
1559
-
1559
+
1560
1560
  def new_tksheet_event(self) -> EventDataDict:
1561
1561
  return event_dict(
1562
1562
  name="",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tksheet
3
- Version: 7.2.11
3
+ Version: 7.2.12
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=5utL7_7hWEF1rltV8vnjbzRcT0pUIFoi3BcQ7yMK6gU,2145
2
+ tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
+ tksheet/column_headers.py,sha256=rqebiS9z6iKIsHk9yIATgqZ3gUF4uSWLsXVv5iiPxl0,102334
4
+ tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
+ tksheet/functions.py,sha256=u-m4p7AfRnLLgtX95AJ4QoRBerBAyi2t1JXTfOQNpS8,41118
6
+ tksheet/main_table.py,sha256=XTqqmigEzTiqVArfo0CHYwVKpMkieFUXBNCKGcYRB4k,328744
7
+ tksheet/other_classes.py,sha256=HIKIDNXJRv0H5qbftcCtLVWW8NKSBAwyNXQOlmPWTDQ,15633
8
+ tksheet/row_index.py,sha256=zfBLQ5npuaun9UOQgG3B97q9yp57K3YEcit-MIZuBNc,109062
9
+ tksheet/sheet.py,sha256=9meeBpTm5WNNU5g8vYAuYpnV3Zce20o8gYFFNPcJUKk,274973
10
+ tksheet/sheet_options.py,sha256=Azo7_-H0e0ssYEoU7Mq_OWy3S-U05rp4_6Q2E2Ffuu8,12262
11
+ tksheet/text_editor.py,sha256=aRm1Y5GfORiEAJthtN1uQ30CT3VoF8mRWvR-SIXPrJU,6548
12
+ tksheet/themes.py,sha256=ZO4RqnAhEpApsoA5ZGUkYvb7huaNHSmrV_ug2TWWzOE,14474
13
+ tksheet/top_left_rectangle.py,sha256=ri7hb9CC5l37ynmxceprq11UuWWRpWEI_0AI42wzv0A,8444
14
+ tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
+ tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
+ tksheet-7.2.12.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
+ tksheet-7.2.12.dist-info/METADATA,sha256=UZJSAJ17UMGSqqX32lFm0jvYDjAI4s-Z2lGHGpWRI3M,6285
18
+ tksheet-7.2.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ tksheet-7.2.12.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
+ tksheet-7.2.12.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- tksheet/__init__.py,sha256=CDNQyyZaOcN--biH6npJTIkTxJYsarIsJwA8dPzaLbY,2145
2
- tksheet/colors.py,sha256=1k06VorynLmnC4FdJg8H4reIA6rXaeXBpdMwXLhN8oc,51594
3
- tksheet/column_headers.py,sha256=ey_7SNmbxoV-r_a6rLTvgD1y_RoTzyJUBo9jRFQyY8U,102062
4
- tksheet/formatters.py,sha256=DXif00aq9DgFpXwkbiqD86KxtDg0Meop51hLY-KcGNQ,10037
5
- tksheet/functions.py,sha256=PgigHSO_cnQoWSXFSfJ5YlPbyOVd2BYUHU4UBbUCCFE,40706
6
- tksheet/main_table.py,sha256=HazCfFKiI0XbXahcYxsrWqWHoumgPe4rUwb9LumNOVU,328126
7
- tksheet/other_classes.py,sha256=HIKIDNXJRv0H5qbftcCtLVWW8NKSBAwyNXQOlmPWTDQ,15633
8
- tksheet/row_index.py,sha256=g6YVYXIEp-YQxa1C5YsBvqOC8gABDewq_yZEl3S9kPg,108800
9
- tksheet/sheet.py,sha256=S9bNBOozxiJNxv8s8Ae7fGuhBapFmm_c8QmZycdpXUE,274981
10
- tksheet/sheet_options.py,sha256=Azo7_-H0e0ssYEoU7Mq_OWy3S-U05rp4_6Q2E2Ffuu8,12262
11
- tksheet/text_editor.py,sha256=aRm1Y5GfORiEAJthtN1uQ30CT3VoF8mRWvR-SIXPrJU,6548
12
- tksheet/themes.py,sha256=ZO4RqnAhEpApsoA5ZGUkYvb7huaNHSmrV_ug2TWWzOE,14474
13
- tksheet/top_left_rectangle.py,sha256=ri7hb9CC5l37ynmxceprq11UuWWRpWEI_0AI42wzv0A,8444
14
- tksheet/types.py,sha256=IgoEHMbceKpakcZtanxKaKJ4RdCq7UW6EoEIIz5O59k,340
15
- tksheet/vars.py,sha256=86ubZZElsnQuC6Lv6bW2lt2NhD9wAp6PxtkK7ufKqq0,3452
16
- tksheet-7.2.11.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
17
- tksheet-7.2.11.dist-info/METADATA,sha256=nwyvMmO2XHZC6oPfHuYD2vtN-mLf3jX3KAFnFwV4Ars,6285
18
- tksheet-7.2.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- tksheet-7.2.11.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
20
- tksheet-7.2.11.dist-info/RECORD,,