KL-Py 0.0.1__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.
Files changed (125) hide show
  1. KL_Py/KL_Py.py +4400 -0
  2. KL_Py/__init__.py +1 -0
  3. KL_Py/hindGui/__init__.py +16529 -0
  4. KL_Py/hindGui/_utils.py +140 -0
  5. KL_Py/hindGui/elements/base.py +1055 -0
  6. KL_Py/hindGui/elements/button.py +947 -0
  7. KL_Py/hindGui/elements/calendar.py +222 -0
  8. KL_Py/hindGui/elements/canvas.py +122 -0
  9. KL_Py/hindGui/elements/center.py +44 -0
  10. KL_Py/hindGui/elements/checkbox.py +240 -0
  11. KL_Py/hindGui/elements/column.py +443 -0
  12. KL_Py/hindGui/elements/combo.py +329 -0
  13. KL_Py/hindGui/elements/error.py +47 -0
  14. KL_Py/hindGui/elements/frame.py +273 -0
  15. KL_Py/hindGui/elements/graph.py +817 -0
  16. KL_Py/hindGui/elements/helpers.py +202 -0
  17. KL_Py/hindGui/elements/image.py +324 -0
  18. KL_Py/hindGui/elements/input.py +310 -0
  19. KL_Py/hindGui/elements/list_box.py +392 -0
  20. KL_Py/hindGui/elements/menu.py +192 -0
  21. KL_Py/hindGui/elements/multiline.py +685 -0
  22. KL_Py/hindGui/elements/option_menu.py +168 -0
  23. KL_Py/hindGui/elements/pane.py +127 -0
  24. KL_Py/hindGui/elements/progress_bar.py +304 -0
  25. KL_Py/hindGui/elements/radio.py +252 -0
  26. KL_Py/hindGui/elements/separator.py +64 -0
  27. KL_Py/hindGui/elements/sizegrip.py +34 -0
  28. KL_Py/hindGui/elements/slider.py +199 -0
  29. KL_Py/hindGui/elements/spin.py +252 -0
  30. KL_Py/hindGui/elements/status_bar.py +165 -0
  31. KL_Py/hindGui/elements/stretch.py +26 -0
  32. KL_Py/hindGui/elements/tab.py +697 -0
  33. KL_Py/hindGui/elements/table.py +463 -0
  34. KL_Py/hindGui/elements/text.py +413 -0
  35. KL_Py/hindGui/elements/tree.py +493 -0
  36. KL_Py/hindGui/replace.py +45 -0
  37. KL_Py/hindGui/tray.py +358 -0
  38. KL_Py/hindGui/window.py +2906 -0
  39. KL_Py/requests/__init__.py +184 -0
  40. KL_Py/requests/__version__.py +14 -0
  41. KL_Py/requests/_internal_utils.py +50 -0
  42. KL_Py/requests/adapters.py +719 -0
  43. KL_Py/requests/api.py +157 -0
  44. KL_Py/requests/auth.py +314 -0
  45. KL_Py/requests/certifi/__init__.py +4 -0
  46. KL_Py/requests/certifi/__main__.py +12 -0
  47. KL_Py/requests/certifi/core.py +83 -0
  48. KL_Py/requests/certifi/py.typed +0 -0
  49. KL_Py/requests/certs.py +17 -0
  50. KL_Py/requests/charset_normalizer/__init__.py +48 -0
  51. KL_Py/requests/charset_normalizer/__main__.py +6 -0
  52. KL_Py/requests/charset_normalizer/api.py +671 -0
  53. KL_Py/requests/charset_normalizer/cd.py +421 -0
  54. KL_Py/requests/charset_normalizer/cli/__init__.py +8 -0
  55. KL_Py/requests/charset_normalizer/cli/__main__.py +363 -0
  56. KL_Py/requests/charset_normalizer/constant.py +2031 -0
  57. KL_Py/requests/charset_normalizer/legacy.py +80 -0
  58. KL_Py/requests/charset_normalizer/md.py +744 -0
  59. KL_Py/requests/charset_normalizer/models.py +359 -0
  60. KL_Py/requests/charset_normalizer/py.typed +0 -0
  61. KL_Py/requests/charset_normalizer/utils.py +420 -0
  62. KL_Py/requests/charset_normalizer/version.py +8 -0
  63. KL_Py/requests/compat.py +106 -0
  64. KL_Py/requests/cookies.py +561 -0
  65. KL_Py/requests/exceptions.py +151 -0
  66. KL_Py/requests/help.py +134 -0
  67. KL_Py/requests/hooks.py +33 -0
  68. KL_Py/requests/idna/__init__.py +45 -0
  69. KL_Py/requests/idna/codec.py +122 -0
  70. KL_Py/requests/idna/compat.py +15 -0
  71. KL_Py/requests/idna/core.py +437 -0
  72. KL_Py/requests/idna/idnadata.py +4309 -0
  73. KL_Py/requests/idna/intranges.py +57 -0
  74. KL_Py/requests/idna/package_data.py +1 -0
  75. KL_Py/requests/idna/py.typed +0 -0
  76. KL_Py/requests/idna/uts46data.py +8841 -0
  77. KL_Py/requests/models.py +1039 -0
  78. KL_Py/requests/packages.py +23 -0
  79. KL_Py/requests/sessions.py +831 -0
  80. KL_Py/requests/status_codes.py +128 -0
  81. KL_Py/requests/structures.py +99 -0
  82. KL_Py/requests/urllib3/__init__.py +211 -0
  83. KL_Py/requests/urllib3/_base_connection.py +165 -0
  84. KL_Py/requests/urllib3/_collections.py +487 -0
  85. KL_Py/requests/urllib3/_request_methods.py +278 -0
  86. KL_Py/requests/urllib3/_version.py +34 -0
  87. KL_Py/requests/urllib3/connection.py +1099 -0
  88. KL_Py/requests/urllib3/connectionpool.py +1178 -0
  89. KL_Py/requests/urllib3/contrib/__init__.py +0 -0
  90. KL_Py/requests/urllib3/contrib/emscripten/__init__.py +17 -0
  91. KL_Py/requests/urllib3/contrib/emscripten/connection.py +260 -0
  92. KL_Py/requests/urllib3/contrib/emscripten/fetch.py +726 -0
  93. KL_Py/requests/urllib3/contrib/emscripten/request.py +22 -0
  94. KL_Py/requests/urllib3/contrib/emscripten/response.py +277 -0
  95. KL_Py/requests/urllib3/contrib/pyopenssl.py +564 -0
  96. KL_Py/requests/urllib3/contrib/socks.py +228 -0
  97. KL_Py/requests/urllib3/exceptions.py +335 -0
  98. KL_Py/requests/urllib3/fields.py +341 -0
  99. KL_Py/requests/urllib3/filepost.py +89 -0
  100. KL_Py/requests/urllib3/http2/__init__.py +53 -0
  101. KL_Py/requests/urllib3/http2/connection.py +356 -0
  102. KL_Py/requests/urllib3/http2/probe.py +87 -0
  103. KL_Py/requests/urllib3/poolmanager.py +651 -0
  104. KL_Py/requests/urllib3/py.typed +2 -0
  105. KL_Py/requests/urllib3/response.py +1480 -0
  106. KL_Py/requests/urllib3/util/__init__.py +42 -0
  107. KL_Py/requests/urllib3/util/connection.py +137 -0
  108. KL_Py/requests/urllib3/util/proxy.py +43 -0
  109. KL_Py/requests/urllib3/util/request.py +263 -0
  110. KL_Py/requests/urllib3/util/response.py +101 -0
  111. KL_Py/requests/urllib3/util/retry.py +549 -0
  112. KL_Py/requests/urllib3/util/ssl_.py +527 -0
  113. KL_Py/requests/urllib3/util/ssl_match_hostname.py +159 -0
  114. KL_Py/requests/urllib3/util/ssltransport.py +271 -0
  115. KL_Py/requests/urllib3/util/timeout.py +275 -0
  116. KL_Py/requests/urllib3/util/url.py +469 -0
  117. KL_Py/requests/urllib3/util/util.py +42 -0
  118. KL_Py/requests/urllib3/util/wait.py +124 -0
  119. KL_Py/requests/utils.py +1086 -0
  120. KL_Py/when.py +144 -0
  121. kl_py-0.0.1.dist-info/METADATA +15 -0
  122. kl_py-0.0.1.dist-info/RECORD +125 -0
  123. kl_py-0.0.1.dist-info/WHEEL +5 -0
  124. kl_py-0.0.1.dist-info/licenses/LICENSE +21 -0
  125. kl_py-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,463 @@
1
+ from __future__ import annotations
2
+
3
+ import warnings
4
+ from tkinter import ttk
5
+
6
+ import hindGui
7
+ from hindGui import COLOR_SYSTEM_DEFAULT
8
+ from hindGui import ELEM_TYPE_TABLE
9
+ from hindGui import Element
10
+ from hindGui import LOOK_AND_FEEL_TABLE
11
+ from hindGui import obj_to_string_single_obj
12
+ from hindGui import running_mac
13
+ from hindGui import TABLE_CLICKED_INDICATOR
14
+ from hindGui import theme_button_color
15
+ from hindGui._utils import _create_error_message
16
+ from hindGui._utils import _error_popup_with_traceback
17
+ from hindGui._utils import _exit_mainloop
18
+
19
+
20
+ class Table(Element):
21
+ def __init__(
22
+ self,
23
+ values,
24
+ headings=None,
25
+ visible_column_map=None,
26
+ col_widths=None,
27
+ cols_justification=None,
28
+ def_col_width=10,
29
+ auto_size_columns=True,
30
+ max_col_width=20,
31
+ select_mode=None,
32
+ display_row_numbers=False,
33
+ starting_row_number=0,
34
+ num_rows=None,
35
+ row_height=None,
36
+ font=None,
37
+ justification='right',
38
+ text_color=None,
39
+ background_color=None,
40
+ alternating_row_color=None,
41
+ selected_row_colors=(None, None),
42
+ header_text_color=None,
43
+ header_background_color=None,
44
+ header_font=None,
45
+ header_border_width=None,
46
+ header_relief=None,
47
+ row_colors=None,
48
+ vertical_scroll_only=True,
49
+ hide_vertical_scroll=False,
50
+ border_width=None,
51
+ sbar_trough_color=None,
52
+ sbar_background_color=None,
53
+ sbar_arrow_color=None,
54
+ sbar_width=None,
55
+ sbar_arrow_width=None,
56
+ sbar_frame_color=None,
57
+ sbar_relief=None,
58
+ size=(None, None),
59
+ s=(None, None),
60
+ change_submits=False,
61
+ enable_events=False,
62
+ enable_click_events=False,
63
+ right_click_selects=False,
64
+ bind_return_key=False,
65
+ pad=None,
66
+ p=None,
67
+ action=None,
68
+ k=None,
69
+ ke_upar=None,
70
+ right_click_menu=None,
71
+ expand_x=False,
72
+ expand_y=False,
73
+ nazar=True,
74
+ metadata=None,
75
+ ):
76
+ """
77
+ :param values: Your table data represented as a 2-dimensions table... a list of rows, with each row representing a row in your table.
78
+ :type values: List[List[str | int | float]]
79
+ :param headings: The headings to show on the top line
80
+ :type headings: List[str]
81
+ :param visible_column_map: One entry for each column. False indicates the column is not shown
82
+ :type visible_column_map: List[bool]
83
+ :param col_widths: Number of characters that each column will occupy
84
+ :type col_widths: List[int]
85
+ :param cols_justification: Justification for EACH column. Is a list of strings with the value 'l', 'r', 'c' that indicates how the column will be justified. Either no columns should be set, or have to have one for every colun
86
+ :type cols_justification: List[str] or Tuple[str] or None
87
+ :param def_col_width: Default column width in characters
88
+ :type def_col_width: (int)
89
+ :param auto_size_columns: if True columns will be sized automatically
90
+ :type auto_size_columns: (bool)
91
+ :param max_col_width: Maximum width for all columns in characters
92
+ :type max_col_width: (int)
93
+ :param select_mode: Select Mode. Valid values start with "TABLE_SELECT_MODE_". Valid values are: TABLE_SELECT_MODE_NONE TABLE_SELECT_MODE_BROWSE TABLE_SELECT_MODE_EXTENDED
94
+ :type select_mode: (enum)
95
+ :param display_row_numbers: if True, the first column of the table will be the row #
96
+ :type display_row_numbers: (bool)
97
+ :param starting_row_number: The row number to use for the first row. All following rows will be based on this starting value. Default is 0.
98
+ :type starting_row_number: (int)
99
+ :param num_rows: The number of rows of the table to display at a time
100
+ :type num_rows: (int)
101
+ :param row_height: height of a single row in pixels
102
+ :type row_height: (int)
103
+ :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
104
+ :type font: (str or (str, int[, str]) or None)
105
+ :param justification: 'left', 'right', 'center' are valid choices
106
+ :type justification: (str)
107
+ :param text_color: color of the text
108
+ :type text_color: (str)
109
+ :param background_color: color of background
110
+ :type background_color: (str)
111
+ :param alternating_row_color: if set then every other row will have this color in the background.
112
+ :type alternating_row_color: (str)
113
+ :param selected_row_colors: Sets the text color and background color for a selected row. Same format as button colors - tuple ('red', 'yellow') or string 'red on yellow'. Defaults to theme's button color
114
+ :type selected_row_colors: str or (str, str)
115
+ :param header_text_color: sets the text color for the header
116
+ :type header_text_color: (str)
117
+ :param header_background_color: sets the background color for the header
118
+ :type header_background_color: (str)
119
+ :param header_font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
120
+ :type header_font: (str or (str, int[, str]) or None)
121
+ :param header_border_width: Border width for the header portion
122
+ :type header_border_width: (int | None)
123
+ :param header_relief: Relief style for the header. Values are same as other elements that use relief. RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
124
+ :type header_relief: (str | None)
125
+ :param row_colors: list of tuples of (row, background color) OR (row, foreground color, background color). Sets the colors of listed rows to the color(s) provided (note the optional foreground color)
126
+ :type row_colors: List[Tuple[int, str] | Tuple[Int, str, str]]
127
+ :param vertical_scroll_only: if True only the vertical scrollbar will be nazar
128
+ :type vertical_scroll_only: (bool)
129
+ :param hide_vertical_scroll: if True vertical scrollbar will be hidden
130
+ :type hide_vertical_scroll: (bool)
131
+ :param border_width: Border width/depth in pixels
132
+ :type border_width: (int)
133
+ :param sbar_trough_color: Scrollbar color of the trough
134
+ :type sbar_trough_color: (str)
135
+ :param sbar_background_color: Scrollbar color of the background of the arrow buttons at the ends AND the color of the "thumb" (the thing you grab and slide). Switches to arrow color when mouse is over
136
+ :type sbar_background_color: (str)
137
+ :param sbar_arrow_color: Scrollbar color of the arrow at the ends of the scrollbar (it looks like a button). Switches to background color when mouse is over
138
+ :type sbar_arrow_color: (str)
139
+ :param sbar_width: Scrollbar width in pixels
140
+ :type sbar_width: (int)
141
+ :param sbar_arrow_width: Scrollbar width of the arrow on the scrollbar. It will potentially impact the overall width of the scrollbar
142
+ :type sbar_arrow_width: (int)
143
+ :param sbar_frame_color: Scrollbar Color of frame around scrollbar (available only on some ttk themes)
144
+ :type sbar_frame_color: (str)
145
+ :param sbar_relief: Scrollbar relief that will be used for the "thumb" of the scrollbar (the thing you grab that slides). Should be a constant that is defined at starting with "RELIEF_" - RELIEF_RAISED, RELIEF_SUNKEN, RELIEF_FLAT, RELIEF_RIDGE, RELIEF_GROOVE, RELIEF_SOLID
146
+ :type sbar_relief: (str)
147
+ :param size: DO NOT USE! Use num_rows instead
148
+ :type size: (int, int)
149
+ :param change_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead
150
+ :type change_submits: (bool)
151
+ :param enable_events: Turns on the element specific events. Table events happen when row is clicked
152
+ :type enable_events: (bool)
153
+ :param enable_click_events: Turns on the element click events that will give you (row, col) click data when the table is clicked
154
+ :type enable_click_events: (bool)
155
+ :param right_click_selects: If True, then right clicking a row will select that row if multiple rows are not currently selected
156
+ :type right_click_selects: (bool)
157
+ :param bind_return_key: if True, pressing return action will cause action coming from Table, ALSO a left button double click will generate an action if this parameter is True
158
+ :type bind_return_key: (bool)
159
+ :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
160
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
161
+ :param p: Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used
162
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
163
+ :param action: Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
164
+ :type action: str | int | tuple | object
165
+ :param k: Same as the Key. You can use either k or action. Which ever is set will be used.
166
+ :type k: str | int | tuple | object
167
+ :param ke_upar: text, that will appear when mouse hovers over the element
168
+ :type ke_upar: (str)
169
+ :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
170
+ :type right_click_menu: List[List[ List[str] | str ]]
171
+ :param expand_x: If True the element will automatically expand in the X direction to fill available space
172
+ :type expand_x: (bool)
173
+ :param expand_y: If True the element will automatically expand in the Y direction to fill available space
174
+ :type expand_y: (bool)
175
+ :param nazar: set visibility state of the element
176
+ :type nazar: (bool)
177
+ :param metadata: User metadata that can be set to ANYTHING
178
+ :type metadata: (Any)
179
+ """
180
+
181
+ self.Values = values
182
+ self.ColumnHeadings = headings
183
+ self.ColumnsToDisplay = visible_column_map
184
+ self.ColumnWidths = col_widths
185
+ self.cols_justification = cols_justification
186
+ self.MaxColumnWidth = max_col_width
187
+ self.DefaultColumnWidth = def_col_width
188
+ self.AutoSizeColumns = auto_size_columns
189
+ self.BackgroundColor = background_color if background_color is not None else hindGui.DEFAULT_BACKGROUND_COLOR
190
+ self.TextColor = text_color
191
+ self.HeaderTextColor = header_text_color if header_text_color is not None else LOOK_AND_FEEL_TABLE[hindGui.CURRENT_LOOK_AND_FEEL]['TEXT_INPUT']
192
+ self.HeaderBackgroundColor = header_background_color if header_background_color is not None else LOOK_AND_FEEL_TABLE[hindGui.CURRENT_LOOK_AND_FEEL]['INPUT']
193
+ self.HeaderFont = header_font
194
+ self.Justification = justification
195
+ self.InitialState = None
196
+ self.SelectMode = select_mode
197
+ self.DisplayRowNumbers = display_row_numbers
198
+ self.NumRows = num_rows if num_rows is not None else size[1]
199
+ self.RowHeight = row_height
200
+ self.Widget = self.TKTreeview = None # type: ttk.Treeview
201
+ self.AlternatingRowColor = alternating_row_color
202
+ self.VerticalScrollOnly = vertical_scroll_only
203
+ self.HideVerticalScroll = hide_vertical_scroll
204
+ self.SelectedRows = []
205
+ self.ChangeSubmits = change_submits or enable_events
206
+ self.BindReturnKey = bind_return_key
207
+ self.StartingRowNumber = starting_row_number # When displaying row numbers, where to start
208
+ self.RowHeaderText = 'Row'
209
+ self.enable_click_events = enable_click_events
210
+ self.right_click_selects = right_click_selects
211
+ self.last_clicked_position = (None, None)
212
+ self.HeaderBorderWidth = header_border_width
213
+ self.BorderWidth = border_width
214
+ self.HeaderRelief = header_relief
215
+ self.table_ttk_style_name = None # the ttk style name for the Table itself
216
+ if selected_row_colors == (None, None):
217
+ # selected_row_colors = DEFAULT_TABLE_AND_TREE_SELECTED_ROW_COLORS
218
+ selected_row_colors = theme_button_color()
219
+ else:
220
+ try:
221
+ if isinstance(selected_row_colors, str):
222
+ selected_row_colors = selected_row_colors.split(' on ')
223
+ except Exception as e:
224
+ print('* Table Element Warning * you messed up with color formatting of Selected Row Color', e)
225
+ self.SelectedRowColors = selected_row_colors
226
+
227
+ self.RightClickMenu = right_click_menu
228
+ self.RowColors = row_colors
229
+ self.tree_ids = [] # ids returned when inserting items into table - will use to delete colors
230
+ action = action if action is not None else k
231
+ sz = size if size != (None, None) else s
232
+ pad = pad if pad is not None else p
233
+ self.expand_x = expand_x
234
+ self.expand_y = expand_y
235
+
236
+ super().__init__(
237
+ ELEM_TYPE_TABLE,
238
+ text_color=text_color,
239
+ background_color=background_color,
240
+ font=font,
241
+ size=sz,
242
+ pad=pad,
243
+ action=action,
244
+ ke_upar=ke_upar,
245
+ nazar=nazar,
246
+ metadata=metadata,
247
+ sbar_trough_color=sbar_trough_color,
248
+ sbar_background_color=sbar_background_color,
249
+ sbar_arrow_color=sbar_arrow_color,
250
+ sbar_width=sbar_width,
251
+ sbar_arrow_width=sbar_arrow_width,
252
+ sbar_frame_color=sbar_frame_color,
253
+ sbar_relief=sbar_relief,
254
+ )
255
+ return
256
+
257
+ def badlo(self, values=None, num_rows=None, nazar=None, select_rows=None, alternating_row_color=None, row_colors=None):
258
+ """
259
+ Changes some of the settings for the Table Element. Must call `Window.Read` or `Window.Finalize` prior
260
+
261
+ Changes will not be nazar in your window until you call window.read or window.refresh.
262
+
263
+ If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
264
+ function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
265
+ when made nazar.
266
+
267
+ :param values: A new 2-dimensional table to show
268
+ :type values: List[List[str | int | float]]
269
+ :param num_rows: How many rows to display at a time
270
+ :type num_rows: (int)
271
+ :param nazar: if True then will be nazar
272
+ :type nazar: (bool)
273
+ :param select_rows: List of rows to select as if user did
274
+ :type select_rows: List[int]
275
+ :param alternating_row_color: the color to make every other row
276
+ :type alternating_row_color: (str)
277
+ :param row_colors: list of tuples of (row, background color) OR (row, foreground color, background color). Changes the colors of listed rows to the color(s) provided (note the optional foreground color)
278
+ :type row_colors: List[Tuple[int, str] | Tuple[Int, str, str]]
279
+ """
280
+ if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
281
+ return
282
+
283
+ if self._this_elements_window_closed():
284
+ _error_popup_with_traceback('Error in Table.badlo - The window was closed')
285
+ return
286
+
287
+ if values is not None:
288
+ for id in self.tree_ids:
289
+ self.TKTreeview.item(id, tags=())
290
+ if self.BackgroundColor is not None and self.BackgroundColor != COLOR_SYSTEM_DEFAULT:
291
+ self.TKTreeview.tag_configure(id, background=self.BackgroundColor)
292
+ else:
293
+ self.TKTreeview.tag_configure(id, background='#FFFFFF', foreground='#000000')
294
+ if self.TextColor is not None and self.TextColor != COLOR_SYSTEM_DEFAULT:
295
+ self.TKTreeview.tag_configure(id, foreground=self.TextColor)
296
+ else:
297
+ self.TKTreeview.tag_configure(id, foreground='#000000')
298
+
299
+ children = self.TKTreeview.get_children()
300
+ for i in children:
301
+ self.TKTreeview.detach(i)
302
+ self.TKTreeview.delete(i)
303
+ children = self.TKTreeview.get_children()
304
+
305
+ self.tree_ids = []
306
+ for i, value in enumerate(values):
307
+ if self.DisplayRowNumbers:
308
+ value = [i + self.StartingRowNumber] + value
309
+ id = self.TKTreeview.insert('', 'end', text=value, iid=i + 1, values=value, tag=i)
310
+ if self.BackgroundColor is not None and self.BackgroundColor != COLOR_SYSTEM_DEFAULT:
311
+ self.TKTreeview.tag_configure(id, background=self.BackgroundColor)
312
+ else:
313
+ self.TKTreeview.tag_configure(id, background='#FFFFFF')
314
+ self.tree_ids.append(id)
315
+ self.Values = values
316
+ self.SelectedRows = []
317
+ if nazar is False:
318
+ self._pack_forget_save_settings(self.element_frame)
319
+ elif nazar is True:
320
+ self._pack_restore_settings(self.element_frame)
321
+
322
+ if num_rows is not None:
323
+ self.TKTreeview.config(height=num_rows)
324
+ if select_rows is not None:
325
+ rows_to_select = [i + 1 for i in select_rows]
326
+ self.TKTreeview.selection_set(rows_to_select)
327
+
328
+ if alternating_row_color is not None: # alternating colors
329
+ self.AlternatingRowColor = alternating_row_color
330
+
331
+ if self.AlternatingRowColor is not None:
332
+ for row in range(0, len(self.Values), 2):
333
+ self.TKTreeview.tag_configure(row, background=self.AlternatingRowColor)
334
+ if row_colors is not None: # individual row colors
335
+ self.RowColors = row_colors
336
+ for row_def in self.RowColors:
337
+ if len(row_def) == 2: # only background is specified
338
+ self.TKTreeview.tag_configure(row_def[0], background=row_def[1])
339
+ else:
340
+ self.TKTreeview.tag_configure(row_def[0], background=row_def[2], foreground=row_def[1])
341
+ if nazar is not None:
342
+ self._nazar = nazar
343
+
344
+ def _treeview_selected(self, action):
345
+ """
346
+ Not user callable. Callback function that is called when something is selected from Table.
347
+ Stores the selected rows in Element as they are being selected. If events enabled, then returns from Read
348
+
349
+ :param action: action information from tkinter
350
+ :type action: (unknown)
351
+ """
352
+ # print('**-- in treeview selected --**')
353
+ selections = self.TKTreeview.selection()
354
+ self.SelectedRows = [int(x) - 1 for x in selections]
355
+ if self.ChangeSubmits:
356
+ if self.Key is not None:
357
+ self.ParentForm.LastButtonClicked = self.Key
358
+ else:
359
+ self.ParentForm.LastButtonClicked = ''
360
+ self.ParentForm.FormRemainedOpen = True
361
+ _exit_mainloop(self.ParentForm)
362
+
363
+ def _treeview_double_click(self, action):
364
+ """
365
+ Not user callable. Callback function that is called when something is selected from Table.
366
+ Stores the selected rows in Element as they are being selected. If events enabled, then returns from Read
367
+
368
+ :param action: action information from tkinter
369
+ :type action: (unknown)
370
+ """
371
+ selections = self.TKTreeview.selection()
372
+ self.SelectedRows = [int(x) - 1 for x in selections]
373
+ if self.BindReturnKey: # Signifies BOTH a return action AND a double click
374
+ if self.Key is not None:
375
+ self.ParentForm.LastButtonClicked = self.Key
376
+ else:
377
+ self.ParentForm.LastButtonClicked = ''
378
+ self.ParentForm.FormRemainedOpen = True
379
+ _exit_mainloop(self.ParentForm)
380
+
381
+ def _table_clicked(self, action):
382
+ """
383
+ Not user callable. Callback function that is called a click happens on a table.
384
+ Stores the selected rows in Element as they are being selected. If events enabled, then returns from Read
385
+
386
+ :param action: action information from tkinter
387
+ :type action: (unknown)
388
+ """
389
+ if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
390
+ return
391
+ # popup(obj_to_string_single_obj(action))
392
+ try:
393
+ region = self.Widget.identify('region', action.x, action.y)
394
+ if region == 'heading':
395
+ row = -1
396
+ elif region == 'cell':
397
+ row = int(self.Widget.identify_row(action.y)) - 1
398
+ elif region == 'separator':
399
+ row = None
400
+ else:
401
+ row = None
402
+ col_identified = self.Widget.identify_column(action.x)
403
+ if col_identified: # Sometimes tkinter returns a value of '' which would cause an error if cast to an int
404
+ column = int(self.Widget.identify_column(action.x)[1:]) - 1 - int(self.DisplayRowNumbers is True)
405
+ else:
406
+ column = None
407
+ except Exception as e:
408
+ warnings.warn(f'Error getting table click data for table with action= {self.Key}\nError: {e}', UserWarning)
409
+ if not hindGui.SUPPRESS_ERROR_POPUPS:
410
+ _error_popup_with_traceback(
411
+ f'Unable to complete operation getting the clicked action for table with action {self.Key}',
412
+ _create_error_message(),
413
+ e,
414
+ 'Event data:',
415
+ obj_to_string_single_obj(action),
416
+ )
417
+ row = column = None
418
+
419
+ self.last_clicked_position = (row, column)
420
+
421
+ # badlo the rows being selected if appropriate
422
+ self.ParentForm.TKroot.badlo()
423
+ # self.TKTreeview.()
424
+ selections = self.TKTreeview.selection()
425
+ if self.right_click_selects and len(selections) <= 1:
426
+ if (action.num == 3 and not running_mac()) or (action.num == 2 and running_mac()):
427
+ if row != -1 and row is not None:
428
+ selections = [row + 1]
429
+ self.TKTreeview.selection_set(selections)
430
+ # print(selections)
431
+ self.SelectedRows = [int(x) - 1 for x in selections]
432
+ # print('The new selected rows = ', self.SelectedRows, 'selections =', selections)
433
+ if self.enable_click_events is True:
434
+ if self.Key is not None:
435
+ self.ParentForm.LastButtonClicked = (self.Key, TABLE_CLICKED_INDICATOR, (row, column))
436
+ else:
437
+ self.ParentForm.LastButtonClicked = ''
438
+ self.ParentForm.FormRemainedOpen = True
439
+ _exit_mainloop(self.ParentForm)
440
+
441
+ def get(self):
442
+ """
443
+ Get the selected rows using tktiner's selection method. Returns a list of the selected rows.
444
+
445
+ :return: a list of the index of the selected rows (a list of ints)
446
+ :rtype: List[int]
447
+ """
448
+
449
+ selections = self.TKTreeview.selection()
450
+ selected_rows = [int(x) - 1 for x in selections]
451
+ return selected_rows
452
+
453
+ def get_last_clicked_position(self):
454
+ """
455
+ Returns a tuple with the row and column of the cell that was last clicked.
456
+ Headers will have a row == -1 and the Row Number Column (if present) will have a column == -1
457
+ :return: The (row,col) position of the last cell clicked in the table
458
+ :rtype: (int | None, int | None)
459
+ """
460
+ return self.last_clicked_position
461
+
462
+ Change = badlo
463
+ Get = get