tksheet 7.4.8__py3-none-any.whl → 7.4.9__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.4.8"
7
+ __version__ = "7.4.9"
8
8
 
9
9
  from .colors import (
10
10
  color_map,
tksheet/column_headers.py CHANGED
@@ -1094,7 +1094,7 @@ class ColumnHeaders(tk.Canvas):
1094
1094
  self.itemconfig(item, state="hidden")
1095
1095
 
1096
1096
  def get_cell_dimensions(self, datacn: int) -> tuple[int, int]:
1097
- txt = self.get_valid_cell_data_as_str(datacn, fix=False)
1097
+ txt = self.cell_str(datacn, fix=False)
1098
1098
  if txt:
1099
1099
  self.MT.txt_measure_canvas.itemconfig(
1100
1100
  self.MT.txt_measure_canvas_text,
@@ -1150,7 +1150,7 @@ class ColumnHeaders(tk.Canvas):
1150
1150
  elif isinstance(self.MT._headers, int):
1151
1151
  datarn = self.MT._headers
1152
1152
  for datacn in iterable:
1153
- if txt := self.MT.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True):
1153
+ if txt := self.MT.cell_str(datarn, datacn, get_displayed=True):
1154
1154
  qconf(qtxtm, text=txt, font=qfont)
1155
1155
  b = qbbox(qtxtm)
1156
1156
  th = b[3] - b[1] + 5
@@ -1197,7 +1197,7 @@ class ColumnHeaders(tk.Canvas):
1197
1197
  qtxth = self.MT.table_txt_height
1198
1198
  qfont = self.ops.table_font
1199
1199
  for datarn in iterable:
1200
- if txt := self.MT.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True):
1200
+ if txt := self.MT.cell_str(datarn, datacn, get_displayed=True):
1201
1201
  qconf(qtxtm, text=txt, font=qfont)
1202
1202
  b = qbbox(qtxtm)
1203
1203
  if (
@@ -1629,7 +1629,7 @@ class ColumnHeaders(tk.Canvas):
1629
1629
  or (align.endswith("n") and cleftgridln + 5 > scrollpos_right)
1630
1630
  ):
1631
1631
  continue
1632
- text = self.get_valid_cell_data_as_str(datacn, fix=False)
1632
+ text = self.cell_str(datacn, fix=False)
1633
1633
  if not text:
1634
1634
  continue
1635
1635
  max_lines = int((self.current_height - top - 2) / txt_h)
@@ -2223,7 +2223,7 @@ class ColumnHeaders(tk.Canvas):
2223
2223
  edited = True
2224
2224
  if edited and cell_resize and self.ops.cell_auto_resize_enabled:
2225
2225
  if self.height_resizing_enabled:
2226
- self.set_height_of_header_to_text(self.get_valid_cell_data_as_str(datacn, fix=False))
2226
+ self.set_height_of_header_to_text(self.cell_str(datacn, fix=False))
2227
2227
  self.set_col_width_run_binding(c)
2228
2228
  if redraw:
2229
2229
  self.MT.refresh()
@@ -2270,7 +2270,7 @@ class ColumnHeaders(tk.Canvas):
2270
2270
  redirect_int: bool = False,
2271
2271
  ) -> Any:
2272
2272
  if get_displayed:
2273
- return self.get_valid_cell_data_as_str(datacn, fix=False)
2273
+ return self.cell_str(datacn, fix=False)
2274
2274
  if redirect_int and isinstance(self.MT._headers, int): # internal use
2275
2275
  return self.MT.get_cell_data(self.MT._headers, datacn, none_to_empty_str=True)
2276
2276
  if (
@@ -2282,7 +2282,7 @@ class ColumnHeaders(tk.Canvas):
2282
2282
  return ""
2283
2283
  return self.MT._headers[datacn]
2284
2284
 
2285
- def get_valid_cell_data_as_str(self, datacn: int, fix: bool = True) -> str:
2285
+ def cell_str(self, datacn: int, fix: bool = True) -> str:
2286
2286
  kwargs = self.get_cell_kwargs(datacn, key="dropdown")
2287
2287
  if kwargs:
2288
2288
  if kwargs["text"] is not None:
@@ -2292,7 +2292,7 @@ class ColumnHeaders(tk.Canvas):
2292
2292
  if kwargs:
2293
2293
  return f"{kwargs['text']}"
2294
2294
  if isinstance(self.MT._headers, int):
2295
- return self.MT.get_valid_cell_data_as_str(self.MT._headers, datacn, get_displayed=True)
2295
+ return self.MT.cell_str(self.MT._headers, datacn, get_displayed=True)
2296
2296
  if fix:
2297
2297
  self.fix_header(datacn)
2298
2298
  try:
tksheet/main_table.py CHANGED
@@ -4349,7 +4349,7 @@ class MainTable(tk.Canvas):
4349
4349
  return self.data
4350
4350
 
4351
4351
  def get_cell_dimensions(self, datarn: int, datacn: int) -> tuple[int, int]:
4352
- txt = self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True)
4352
+ txt = self.cell_str(datarn, datacn, get_displayed=True)
4353
4353
  if txt:
4354
4354
  self.txt_measure_canvas.itemconfig(self.txt_measure_canvas_text, text=txt, font=self.PAR.ops.table_font)
4355
4355
  b = self.txt_measure_canvas.bbox(self.txt_measure_canvas_text)
@@ -4478,7 +4478,7 @@ class MainTable(tk.Canvas):
4478
4478
  sum(
4479
4479
  1
4480
4480
  for _ in wrap_text(
4481
- text=self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True),
4481
+ text=self.cell_str(datarn, datacn, get_displayed=True),
4482
4482
  max_width=self.get_cell_max_width(datarn, dispcn),
4483
4483
  max_lines=float("inf"),
4484
4484
  char_width_fn=self.wrap_get_char_w,
@@ -4524,7 +4524,7 @@ class MainTable(tk.Canvas):
4524
4524
  w = min_column_width if width is None else width
4525
4525
  w = hw if (hw := self.CH.get_cell_dimensions(datacn)[0]) > w else min_column_width
4526
4526
  for datarn in iterrows:
4527
- if txt := self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True):
4527
+ if txt := self.cell_str(datarn, datacn, get_displayed=True):
4528
4528
  qconf(qtxtm, text=txt, font=qfont)
4529
4529
  b = qbbox(qtxtm)
4530
4530
  tw = b[2] - b[0] + added_w_space
@@ -6240,7 +6240,7 @@ class MainTable(tk.Canvas):
6240
6240
  cells["dropdown"][(datarn, datacn)] = kwargs
6241
6241
  elif kwargs := self.get_cell_kwargs(datarn, datacn, key="checkbox"):
6242
6242
  cells["checkbox"][(datarn, datacn)] = kwargs
6243
- cells[(datarn, datacn)] = self.get_valid_cell_data_as_str(datarn, datacn, get_displayed=True)
6243
+ cells[(datarn, datacn)] = self.cell_str(datarn, datacn, get_displayed=True)
6244
6244
  return cells
6245
6245
 
6246
6246
  def wrap_get_char_w(self, c: str) -> int:
@@ -8075,31 +8075,30 @@ class MainTable(tk.Canvas):
8075
8075
  for datarn in range(len(self.data)):
8076
8076
  self.set_cell_data(datarn, datacn, get_val(datarn, datacn), expand_sheet=False)
8077
8077
 
8078
- # deals with possibility of formatter class being in self.data cell
8079
- # if cell is formatted - possibly returns invalid_value kwarg if
8080
- # cell value is not in datatypes kwarg
8081
- # if get displayed is true then Nones are replaced by ""
8082
- def get_valid_cell_data_as_str(self, datarn: int, datacn: int, get_displayed: bool = False, **kwargs) -> str:
8078
+ def cell_str(self, datarn: int, datacn: int, get_displayed: bool = False, **kwargs) -> str:
8079
+ """
8080
+ deals with possibility of formatter class being in self.data cell
8081
+ if cell is formatted - possibly returns invalid_value kwarg if
8082
+ cell value is not in datatypes kwarg
8083
+ if get displayed is true then Nones are replaced by
8084
+ """
8085
+ kwargs = self.get_cell_kwargs(datarn, datacn, key=None)
8083
8086
  if get_displayed:
8084
- kwargs = self.get_cell_kwargs(datarn, datacn, key="dropdown")
8085
- if kwargs:
8086
- if kwargs["text"] is not None:
8087
- return f"{kwargs['text']}"
8088
- else:
8089
- kwargs = self.get_cell_kwargs(datarn, datacn, key="checkbox")
8090
- if kwargs:
8091
- return f"{kwargs['text']}"
8087
+ if kwargs and "dropdown" in kwargs:
8088
+ if kwargs["dropdown"]["text"] is not None:
8089
+ return f"{kwargs['dropdown']['text']}"
8090
+ elif kwargs and "checkbox" in kwargs:
8091
+ return f"{kwargs['checkbox']['text']}"
8092
8092
  try:
8093
8093
  value = self.data[datarn][datacn]
8094
8094
  except Exception:
8095
8095
  value = ""
8096
- kwargs = self.get_cell_kwargs(datarn, datacn, key="format")
8097
- if kwargs:
8098
- if kwargs["formatter"] is None:
8096
+ if "format" in kwargs:
8097
+ if kwargs["format"]["formatter"] is None:
8099
8098
  if get_displayed:
8100
- return data_to_str(value, **kwargs)
8099
+ return data_to_str(value, **kwargs["format"])
8101
8100
  else:
8102
- return f"{get_data_with_valid_check(value, **kwargs)}"
8101
+ return f"{get_data_with_valid_check(value, **kwargs['format'])}"
8103
8102
  else:
8104
8103
  if get_displayed:
8105
8104
  # assumed given formatter class has __str__()
@@ -8114,9 +8113,15 @@ class MainTable(tk.Canvas):
8114
8113
  self,
8115
8114
  datarn: int,
8116
8115
  datacn: int,
8116
+ get_displayed: bool = False,
8117
8117
  none_to_empty_str: bool = False,
8118
8118
  fmt_kw: dict | None = None,
8119
8119
  ) -> Any:
8120
+ if get_displayed:
8121
+ if fmt_kw:
8122
+ return format_data(value=self.cell_str(datarn, datacn, get_displayed=True), **fmt_kw)
8123
+ else:
8124
+ return self.cell_str(datarn, datacn, get_displayed=True)
8120
8125
  try: # when successful try is more than twice as fast as len check
8121
8126
  value = self.data[datarn][datacn]
8122
8127
  except Exception:
tksheet/row_index.py CHANGED
@@ -1100,7 +1100,7 @@ class RowIndex(tk.Canvas):
1100
1100
  self.itemconfig(item, state="hidden")
1101
1101
 
1102
1102
  def get_cell_dimensions(self, datarn: int) -> tuple[int, int]:
1103
- txt = self.get_valid_cell_data_as_str(datarn, fix=False)
1103
+ txt = self.cell_str(datarn, fix=False)
1104
1104
  if txt:
1105
1105
  self.MT.txt_measure_canvas.itemconfig(self.MT.txt_measure_canvas_text, text=txt, font=self.ops.index_font)
1106
1106
  b = self.MT.txt_measure_canvas.bbox(self.MT.txt_measure_canvas_text)
@@ -1127,7 +1127,7 @@ class RowIndex(tk.Canvas):
1127
1127
  sum(
1128
1128
  1
1129
1129
  for _ in wrap_text(
1130
- text=self.get_valid_cell_data_as_str(datarn, fix=False),
1130
+ text=self.cell_str(datarn, fix=False),
1131
1131
  max_width=self.current_width,
1132
1132
  max_lines=float("inf"),
1133
1133
  char_width_fn=self.wrap_get_char_w,
@@ -1776,7 +1776,7 @@ class RowIndex(tk.Canvas):
1776
1776
  )
1777
1777
  if max_width <= 1:
1778
1778
  continue
1779
- text = self.get_valid_cell_data_as_str(datarn, fix=False)
1779
+ text = self.cell_str(datarn, fix=False)
1780
1780
  if not text:
1781
1781
  continue
1782
1782
  start_line = max(0, int((scrollpos_top - rtopgridln) / self.MT.index_txt_height))
@@ -2457,7 +2457,7 @@ class RowIndex(tk.Canvas):
2457
2457
  redirect_int: bool = False,
2458
2458
  ) -> Any:
2459
2459
  if get_displayed:
2460
- return self.get_valid_cell_data_as_str(datarn, fix=False)
2460
+ return self.cell_str(datarn, fix=False)
2461
2461
  if redirect_int and isinstance(self.MT._row_index, int): # internal use
2462
2462
  return self.MT.get_cell_data(datarn, self.MT._row_index, none_to_empty_str=True)
2463
2463
  if (
@@ -2471,7 +2471,7 @@ class RowIndex(tk.Canvas):
2471
2471
  return self.MT._row_index[datarn].text
2472
2472
  return self.MT._row_index[datarn]
2473
2473
 
2474
- def get_valid_cell_data_as_str(self, datarn: int, fix: bool = True) -> str:
2474
+ def cell_str(self, datarn: int, fix: bool = True) -> str:
2475
2475
  kwargs = self.get_cell_kwargs(datarn, key="dropdown")
2476
2476
  if kwargs:
2477
2477
  if kwargs["text"] is not None:
@@ -2481,7 +2481,7 @@ class RowIndex(tk.Canvas):
2481
2481
  if kwargs:
2482
2482
  return f"{kwargs['text']}"
2483
2483
  if isinstance(self.MT._row_index, int):
2484
- return self.MT.get_valid_cell_data_as_str(datarn, self.MT._row_index, get_displayed=True)
2484
+ return self.MT.cell_str(datarn, self.MT._row_index, get_displayed=True)
2485
2485
  if fix:
2486
2486
  self.fix_index(datarn)
2487
2487
  try:
tksheet/sheet.py CHANGED
@@ -1048,7 +1048,7 @@ class Sheet(tk.Frame):
1048
1048
  def get_data(self, *key: CreateSpanTypes) -> Any:
1049
1049
  """
1050
1050
  e.g. retrieves entire table as pandas dataframe
1051
- sheet["A1"].expand().options(pandas.DataFrame).data
1051
+ sheet["A1"].expand().options(convert=pandas.DataFrame).data
1052
1052
 
1053
1053
  must deal with
1054
1054
  - format
@@ -1107,56 +1107,48 @@ class Sheet(tk.Frame):
1107
1107
  """
1108
1108
  span = self.span_from_key(*key)
1109
1109
  rows, cols = self.ranges_from_span(span)
1110
- tdisp, idisp, hdisp = span.tdisp, span.idisp, span.hdisp
1111
1110
  table, index, header = span.table, span.index, span.header
1112
1111
  fmt_kw = span.kwargs if span.type_ == "format" and span.kwargs else None
1113
- quick_tdata, quick_idata, quick_hdata = self.MT.get_cell_data, self.RI.get_cell_data, self.CH.get_cell_data
1112
+ t_data = partial(self.MT.get_cell_data, get_displayed=True) if span.tdisp else self.MT.get_cell_data
1113
+ i_data = self.RI.cell_str if span.idisp else self.RI.get_cell_data
1114
+ h_data = self.CH.cell_str if span.hdisp else self.CH.get_cell_data
1114
1115
  res = []
1115
1116
  if span.transposed:
1117
+ # Index row (first row when transposed)
1116
1118
  if index:
1117
- if index and header:
1118
- if table:
1119
- res.append([""] + [quick_idata(r, get_displayed=idisp) for r in rows])
1120
- else:
1121
- res.append([quick_idata(r, get_displayed=idisp) for r in rows])
1122
- else:
1123
- res.append([quick_idata(r, get_displayed=idisp) for r in rows])
1119
+ index_row = [""] if header and table else []
1120
+ index_row.extend(i_data(r) for r in rows)
1121
+ res.append(index_row)
1122
+ # Header and/or table data as columns
1124
1123
  if header:
1125
- if table:
1126
- res.extend(
1127
- [quick_hdata(c, get_displayed=hdisp)]
1128
- + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows]
1129
- for c in cols
1130
- )
1131
- else:
1132
- res.extend([quick_hdata(c, get_displayed=hdisp)] for c in cols)
1124
+ for c in cols:
1125
+ col = [h_data(c)]
1126
+ if table:
1127
+ col.extend(t_data(r, c, fmt_kw=fmt_kw) for r in rows)
1128
+ res.append(col)
1133
1129
  elif table:
1134
- res.extend([quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for r in rows] for c in cols)
1135
- elif not span.transposed:
1130
+ res.extend([t_data(r, c, fmt_kw=fmt_kw) for r in rows] for c in cols)
1131
+ else:
1132
+ # Header row
1136
1133
  if header:
1137
- if header and index:
1138
- if table:
1139
- res.append([""] + [quick_hdata(c, get_displayed=hdisp) for c in cols])
1140
- else:
1141
- res.append([quick_hdata(c, get_displayed=hdisp) for c in cols])
1142
- else:
1143
- res.append([quick_hdata(c, get_displayed=hdisp) for c in cols])
1134
+ header_row = [""] if index and table else []
1135
+ header_row.extend(h_data(c) for c in cols)
1136
+ res.append(header_row)
1137
+ # Index and/or table data as rows
1144
1138
  if index:
1145
- if table:
1146
- res.extend(
1147
- [quick_idata(r, get_displayed=idisp)]
1148
- + [quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols]
1149
- for r in rows
1150
- )
1151
- else:
1152
- res.extend([quick_idata(r, get_displayed=idisp)] for r in rows)
1139
+ for r in rows:
1140
+ row = [i_data(r)]
1141
+ if table:
1142
+ row.extend(t_data(r, c, fmt_kw=fmt_kw) for c in cols)
1143
+ res.append(row)
1153
1144
  elif table:
1154
- res.extend([quick_tdata(r, c, get_displayed=tdisp, fmt_kw=fmt_kw) for c in cols] for r in rows)
1145
+ res.extend([t_data(r, c, fmt_kw=fmt_kw) for c in cols] for r in rows)
1146
+
1155
1147
  if not span.ndim:
1156
1148
  # it's a cell
1157
1149
  if len(res) == 1 and len(res[0]) == 1:
1158
1150
  res = res[0][0]
1159
- # it's a single list
1151
+ # it's a single sublist
1160
1152
  elif len(res) == 1:
1161
1153
  res = res[0]
1162
1154
  # retrieving a list of index cells or
@@ -1168,11 +1160,12 @@ class Sheet(tk.Frame):
1168
1160
  elif span.ndim == 1:
1169
1161
  # flatten sublists
1170
1162
  res = res[0] if len(res) == 1 and len(res[0]) == 1 else list(chain.from_iterable(res))
1171
- # if span.ndim == 2 res keeps its current
1172
- # dimensions as a list of lists
1173
- if span.convert is not None:
1163
+ # if span.ndim == 2 res keeps its current dimensions as a list of lists
1164
+
1165
+ if span.convert is None:
1166
+ return res
1167
+ else:
1174
1168
  return span.convert(res)
1175
- return res
1176
1169
 
1177
1170
  def get_total_rows(self, include_index: bool = False) -> int:
1178
1171
  return self.MT.total_data_rows(include_index=include_index)
@@ -2533,13 +2526,13 @@ class Sheet(tk.Frame):
2533
2526
  self.del_index_cell_options_dropdown_and_checkbox(r)
2534
2527
  add_to_options(self.RI.cell_options, r, "checkbox", d)
2535
2528
  if edit_data:
2536
- set_idata(r, checked if isinstance(checked, bool) else force_bool(self.get_index_data(r)))
2529
+ set_idata(r, checked if isinstance(checked, bool) else force_bool(self.RI.get_cell_data(r)))
2537
2530
  if header:
2538
2531
  for c in cols:
2539
2532
  self.del_header_cell_options_dropdown_and_checkbox(c)
2540
2533
  add_to_options(self.CH.cell_options, c, "checkbox", d)
2541
2534
  if edit_data:
2542
- set_hdata(c, checked if isinstance(checked, bool) else force_bool(self.get_header_data(c)))
2535
+ set_hdata(c, checked if isinstance(checked, bool) else force_bool(self.CH.get_cell_data(c)))
2543
2536
  if table:
2544
2537
  if span.kind == "cell":
2545
2538
  for r in rows:
@@ -5304,7 +5297,7 @@ class Sheet(tk.Frame):
5304
5297
 
5305
5298
  def get_cell_data(self, r: int, c: int, get_displayed: bool = False) -> Any:
5306
5299
  if get_displayed:
5307
- return self.MT.get_valid_cell_data_as_str(r, c, get_displayed=True)
5300
+ return self.MT.cell_str(r, c, get_displayed=True)
5308
5301
  else:
5309
5302
  return self.MT.get_cell_data(r, c)
5310
5303
 
@@ -5323,15 +5316,16 @@ class Sheet(tk.Frame):
5323
5316
  raise ValueError(tksheet_type_error("only_columns", ["int", "iterable", "None"], only_columns))
5324
5317
  if r >= self.MT.total_data_rows():
5325
5318
  raise IndexError(f"Row #{r} is out of range.")
5319
+
5326
5320
  if r >= len(self.MT.data):
5327
5321
  total_data_cols = self.MT.total_data_cols()
5328
5322
  self.MT.fix_data_len(r, total_data_cols - 1)
5323
+
5329
5324
  iterable = only_columns if only_columns is not None else range(len(self.MT.data[r]))
5330
- f = partial(self.MT.get_valid_cell_data_as_str, get_displayed=True) if get_displayed else self.MT.get_cell_data
5331
- if get_index:
5332
- return [self.get_index_data(r, get_displayed=get_index_displayed)] + [f(r, c) for c in iterable]
5333
- else:
5334
- return [f(r, c) for c in iterable]
5325
+ f = partial(self.MT.cell_str, get_displayed=True) if get_displayed else self.MT.get_cell_data
5326
+ row = [self.RI.get_cell_data(r, get_displayed=get_index_displayed)] if get_index else []
5327
+ row.extend(f(r, c) for c in iterable)
5328
+ return row
5335
5329
 
5336
5330
  def get_column_data(
5337
5331
  self,
@@ -5347,10 +5341,10 @@ class Sheet(tk.Frame):
5347
5341
  elif not is_iterable(only_rows):
5348
5342
  raise ValueError(tksheet_type_error("only_rows", ["int", "iterable", "None"], only_rows))
5349
5343
  iterable = only_rows if only_rows is not None else range(len(self.MT.data))
5350
- f = partial(self.MT.get_valid_cell_data_as_str, get_displayed=True) if get_displayed else self.MT.get_cell_data
5351
- return ([self.get_header_data(c, get_displayed=get_header_displayed)] if get_header else []) + [
5352
- f(r, c) for r in iterable
5353
- ]
5344
+ f = partial(self.MT.cell_str, get_displayed=True) if get_displayed else self.MT.get_cell_data
5345
+ col = [self.CH.get_cell_data(c, get_displayed=get_header_displayed)] if get_header else []
5346
+ col.extend(f(r, c) for r in iterable)
5347
+ return col
5354
5348
 
5355
5349
  def get_sheet_data(
5356
5350
  self,
@@ -5361,7 +5355,7 @@ class Sheet(tk.Frame):
5361
5355
  get_index_displayed: bool = True,
5362
5356
  only_rows: AnyIter[int] | int | None = None,
5363
5357
  only_columns: AnyIter[int] | int | None = None,
5364
- ) -> list[Any]:
5358
+ ) -> list[list[Any]]:
5365
5359
  if only_rows is not None:
5366
5360
  if isinstance(only_rows, int):
5367
5361
  only_rows = (only_rows,)
@@ -5372,6 +5366,7 @@ class Sheet(tk.Frame):
5372
5366
  only_columns = (only_columns,)
5373
5367
  elif not is_iterable(only_columns):
5374
5368
  raise ValueError(tksheet_type_error("only_columns", ["int", "iterable", "None"], only_columns))
5369
+
5375
5370
  if get_header:
5376
5371
  maxlen = len(self.MT._headers) if isinstance(self.MT._headers, (list, tuple)) else 0
5377
5372
  data = []
@@ -5380,15 +5375,19 @@ class Sheet(tk.Frame):
5380
5375
  if len(r) > maxlen:
5381
5376
  maxlen = len(r)
5382
5377
  if get_index:
5383
- data.append([self.get_index_data(rn, get_displayed=get_index_displayed)] + r)
5378
+ row = [self.RI.get_cell_data(rn, get_displayed=get_index_displayed)]
5379
+ row.extend(r)
5380
+ data.append(row)
5384
5381
  else:
5385
5382
  data.append(r)
5386
5383
  iterable = only_columns if only_columns is not None else range(maxlen)
5387
- if get_index:
5388
- return [[""] + [self.get_header_data(cn, get_displayed=get_header_displayed) for cn in iterable]] + data
5389
- else:
5390
- return [[self.get_header_data(cn, get_displayed=get_header_displayed) for cn in iterable]] + data
5391
- elif not get_header:
5384
+ header_row = [""] if get_index else []
5385
+ header_row.extend(self.CH.get_cell_data(cn, get_displayed=get_header_displayed) for cn in iterable)
5386
+ result = [header_row]
5387
+ result.extend(data)
5388
+ return result
5389
+
5390
+ else:
5392
5391
  iterable = only_rows if only_rows is not None else range(len(self.MT.data))
5393
5392
  return [
5394
5393
  self.get_row_data(
@@ -5410,7 +5409,7 @@ class Sheet(tk.Frame):
5410
5409
  get_header_displayed: bool = True,
5411
5410
  only_rows: int | AnyIter[int] | None = None,
5412
5411
  only_columns: int | AnyIter[int] | None = None,
5413
- ) -> Iterator[list[Any]]:
5412
+ ) -> Generator[list[Any]]:
5414
5413
  if only_rows is not None:
5415
5414
  if isinstance(only_rows, int):
5416
5415
  only_rows = (only_rows,)
@@ -5421,11 +5420,13 @@ class Sheet(tk.Frame):
5421
5420
  only_columns = (only_columns,)
5422
5421
  elif not is_iterable(only_columns):
5423
5422
  raise ValueError(tksheet_type_error("only_columns", ["int", "iterable", "None"], only_columns))
5423
+
5424
5424
  if get_header:
5425
5425
  iterable = only_columns if only_columns is not None else range(self.MT.total_data_cols())
5426
- yield ([""] if get_index else []) + [
5427
- self.get_header_data(c, get_displayed=get_header_displayed) for c in iterable
5428
- ]
5426
+ header_row = [""] if get_index else []
5427
+ header_row.extend(self.CH.get_cell_data(c, get_displayed=get_header_displayed) for c in iterable)
5428
+ yield header_row
5429
+
5429
5430
  iterable = only_rows if only_rows is not None else range(len(self.MT.data))
5430
5431
  yield from (
5431
5432
  self.get_row_data(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tksheet
3
- Version: 7.4.8
3
+ Version: 7.4.9
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
@@ -1,22 +1,22 @@
1
- tksheet/__init__.py,sha256=l619QID9OmLzoGYKcDr2pSJsVrSSFAzG17P5JHbii5s,2326
1
+ tksheet/__init__.py,sha256=PG3sPrOiYUk7iXSvl3d43mrTD12u2J-tLccwlMHMiZ0,2326
2
2
  tksheet/colors.py,sha256=dHhmdFuQDlwohDHsAfT9VdrKoSl_R33L72a3HCin5zo,51591
3
- tksheet/column_headers.py,sha256=FWDiKOX4LbaNA0zj2tbnnkOBW-RE6QuDxyc3EEEur5M,103267
3
+ tksheet/column_headers.py,sha256=lwCI2Cr4MINGo4u1qJnJIj22g6TLvANocFegm3GiGt8,103123
4
4
  tksheet/constants.py,sha256=aiDvUSaPtl_TSNtRRJ_p87c9iTBz9ksMd5IsSXzz4Hk,13316
5
5
  tksheet/find_window.py,sha256=TvbSqO42cw1o1AO0tQ0Q1iZogouNr4ObMo7JfkZCxgA,19877
6
6
  tksheet/formatters.py,sha256=DGcRiMsDJnySNpQcjfiX84oJ7TmOSMdU6u9injIhA4g,10095
7
7
  tksheet/functions.py,sha256=pCTnCniLIbJI1S9nnPauok93H2EQHEHVvTVWLWImG-I,51024
8
- tksheet/main_table.py,sha256=U95qEPjUV75jlpOF0pMBk5mas9qrG87zKeEuIUOzDXw,363142
8
+ tksheet/main_table.py,sha256=53cT-sOiAoH2Jbi9DBob7_hLgMONidOk6k81sU-q9qo,363313
9
9
  tksheet/other_classes.py,sha256=pe9_Cj6d3rdeMif9nGvUz0MEUChf0l4d669RNqcNhY4,16578
10
- tksheet/row_index.py,sha256=F7mjNJ8o0TNDGVF78JsAH0GxJAYCGx1pbjkmxTJjMbQ,134303
11
- tksheet/sheet.py,sha256=kvbmFekdwEm3hyRBILPYn3SJW905UOZJO3NUllmBUk0,272258
10
+ tksheet/row_index.py,sha256=IvM12M-NToq7te0drQFP5IoQunjA0uyOAAwHvvw-dOY,134195
11
+ tksheet/sheet.py,sha256=0zf8ANR0rBhN4CWgmdwkPsRfTUWd-fynqLV2_S6Hweo,271667
12
12
  tksheet/sheet_options.py,sha256=ob-XYgGfBoi2TaFAvUUmlWUkw9xB-yXmJw17gu9__Lw,9948
13
13
  tksheet/sorting.py,sha256=-x1ZBIYfaneRrQPhbb0Ehs70373o52ADXp481La3nOY,16806
14
14
  tksheet/text_editor.py,sha256=rU8Fz0-ltkM63W9io2DoZJPyzUGzCc9Z0qBtc4D1H40,7404
15
15
  tksheet/themes.py,sha256=AoNAxibnQi04MN0Zpbn9-kyDnkiiV8TDNWP9FYjpuf0,18473
16
16
  tksheet/tksheet_types.py,sha256=7FIDsInby1y1DZMpVINXem4Ol5RFG1ETE5fn9I9uXSk,4679
17
17
  tksheet/top_left_rectangle.py,sha256=M52IrPIeMoYE3jSpooZmqw_0W5Fz_R-Yu1ZqA685EZ8,8557
18
- tksheet-7.4.8.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
19
- tksheet-7.4.8.dist-info/METADATA,sha256=g03IKcPe7_orOLSvu_VQXmy_qC4Lw1Xyui75SVUoVzc,8005
20
- tksheet-7.4.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
21
- tksheet-7.4.8.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
22
- tksheet-7.4.8.dist-info/RECORD,,
18
+ tksheet-7.4.9.dist-info/LICENSE.txt,sha256=ndbcCPe9SlHfweE_W2RAueWUe2k7yudyxYLq6WjFdn4,1101
19
+ tksheet-7.4.9.dist-info/METADATA,sha256=y6eAdid6xbyjyquuZukynayAO893NM4unFj0Ubaww88,8005
20
+ tksheet-7.4.9.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
21
+ tksheet-7.4.9.dist-info/top_level.txt,sha256=my61PXCcck_HHAc9cq3NAlyAr3A3FXxCy9gptEOaCN8,8
22
+ tksheet-7.4.9.dist-info/RECORD,,