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.
- KL_Py/KL_Py.py +4400 -0
- KL_Py/__init__.py +1 -0
- KL_Py/hindGui/__init__.py +16529 -0
- KL_Py/hindGui/_utils.py +140 -0
- KL_Py/hindGui/elements/base.py +1055 -0
- KL_Py/hindGui/elements/button.py +947 -0
- KL_Py/hindGui/elements/calendar.py +222 -0
- KL_Py/hindGui/elements/canvas.py +122 -0
- KL_Py/hindGui/elements/center.py +44 -0
- KL_Py/hindGui/elements/checkbox.py +240 -0
- KL_Py/hindGui/elements/column.py +443 -0
- KL_Py/hindGui/elements/combo.py +329 -0
- KL_Py/hindGui/elements/error.py +47 -0
- KL_Py/hindGui/elements/frame.py +273 -0
- KL_Py/hindGui/elements/graph.py +817 -0
- KL_Py/hindGui/elements/helpers.py +202 -0
- KL_Py/hindGui/elements/image.py +324 -0
- KL_Py/hindGui/elements/input.py +310 -0
- KL_Py/hindGui/elements/list_box.py +392 -0
- KL_Py/hindGui/elements/menu.py +192 -0
- KL_Py/hindGui/elements/multiline.py +685 -0
- KL_Py/hindGui/elements/option_menu.py +168 -0
- KL_Py/hindGui/elements/pane.py +127 -0
- KL_Py/hindGui/elements/progress_bar.py +304 -0
- KL_Py/hindGui/elements/radio.py +252 -0
- KL_Py/hindGui/elements/separator.py +64 -0
- KL_Py/hindGui/elements/sizegrip.py +34 -0
- KL_Py/hindGui/elements/slider.py +199 -0
- KL_Py/hindGui/elements/spin.py +252 -0
- KL_Py/hindGui/elements/status_bar.py +165 -0
- KL_Py/hindGui/elements/stretch.py +26 -0
- KL_Py/hindGui/elements/tab.py +697 -0
- KL_Py/hindGui/elements/table.py +463 -0
- KL_Py/hindGui/elements/text.py +413 -0
- KL_Py/hindGui/elements/tree.py +493 -0
- KL_Py/hindGui/replace.py +45 -0
- KL_Py/hindGui/tray.py +358 -0
- KL_Py/hindGui/window.py +2906 -0
- KL_Py/requests/__init__.py +184 -0
- KL_Py/requests/__version__.py +14 -0
- KL_Py/requests/_internal_utils.py +50 -0
- KL_Py/requests/adapters.py +719 -0
- KL_Py/requests/api.py +157 -0
- KL_Py/requests/auth.py +314 -0
- KL_Py/requests/certifi/__init__.py +4 -0
- KL_Py/requests/certifi/__main__.py +12 -0
- KL_Py/requests/certifi/core.py +83 -0
- KL_Py/requests/certifi/py.typed +0 -0
- KL_Py/requests/certs.py +17 -0
- KL_Py/requests/charset_normalizer/__init__.py +48 -0
- KL_Py/requests/charset_normalizer/__main__.py +6 -0
- KL_Py/requests/charset_normalizer/api.py +671 -0
- KL_Py/requests/charset_normalizer/cd.py +421 -0
- KL_Py/requests/charset_normalizer/cli/__init__.py +8 -0
- KL_Py/requests/charset_normalizer/cli/__main__.py +363 -0
- KL_Py/requests/charset_normalizer/constant.py +2031 -0
- KL_Py/requests/charset_normalizer/legacy.py +80 -0
- KL_Py/requests/charset_normalizer/md.py +744 -0
- KL_Py/requests/charset_normalizer/models.py +359 -0
- KL_Py/requests/charset_normalizer/py.typed +0 -0
- KL_Py/requests/charset_normalizer/utils.py +420 -0
- KL_Py/requests/charset_normalizer/version.py +8 -0
- KL_Py/requests/compat.py +106 -0
- KL_Py/requests/cookies.py +561 -0
- KL_Py/requests/exceptions.py +151 -0
- KL_Py/requests/help.py +134 -0
- KL_Py/requests/hooks.py +33 -0
- KL_Py/requests/idna/__init__.py +45 -0
- KL_Py/requests/idna/codec.py +122 -0
- KL_Py/requests/idna/compat.py +15 -0
- KL_Py/requests/idna/core.py +437 -0
- KL_Py/requests/idna/idnadata.py +4309 -0
- KL_Py/requests/idna/intranges.py +57 -0
- KL_Py/requests/idna/package_data.py +1 -0
- KL_Py/requests/idna/py.typed +0 -0
- KL_Py/requests/idna/uts46data.py +8841 -0
- KL_Py/requests/models.py +1039 -0
- KL_Py/requests/packages.py +23 -0
- KL_Py/requests/sessions.py +831 -0
- KL_Py/requests/status_codes.py +128 -0
- KL_Py/requests/structures.py +99 -0
- KL_Py/requests/urllib3/__init__.py +211 -0
- KL_Py/requests/urllib3/_base_connection.py +165 -0
- KL_Py/requests/urllib3/_collections.py +487 -0
- KL_Py/requests/urllib3/_request_methods.py +278 -0
- KL_Py/requests/urllib3/_version.py +34 -0
- KL_Py/requests/urllib3/connection.py +1099 -0
- KL_Py/requests/urllib3/connectionpool.py +1178 -0
- KL_Py/requests/urllib3/contrib/__init__.py +0 -0
- KL_Py/requests/urllib3/contrib/emscripten/__init__.py +17 -0
- KL_Py/requests/urllib3/contrib/emscripten/connection.py +260 -0
- KL_Py/requests/urllib3/contrib/emscripten/fetch.py +726 -0
- KL_Py/requests/urllib3/contrib/emscripten/request.py +22 -0
- KL_Py/requests/urllib3/contrib/emscripten/response.py +277 -0
- KL_Py/requests/urllib3/contrib/pyopenssl.py +564 -0
- KL_Py/requests/urllib3/contrib/socks.py +228 -0
- KL_Py/requests/urllib3/exceptions.py +335 -0
- KL_Py/requests/urllib3/fields.py +341 -0
- KL_Py/requests/urllib3/filepost.py +89 -0
- KL_Py/requests/urllib3/http2/__init__.py +53 -0
- KL_Py/requests/urllib3/http2/connection.py +356 -0
- KL_Py/requests/urllib3/http2/probe.py +87 -0
- KL_Py/requests/urllib3/poolmanager.py +651 -0
- KL_Py/requests/urllib3/py.typed +2 -0
- KL_Py/requests/urllib3/response.py +1480 -0
- KL_Py/requests/urllib3/util/__init__.py +42 -0
- KL_Py/requests/urllib3/util/connection.py +137 -0
- KL_Py/requests/urllib3/util/proxy.py +43 -0
- KL_Py/requests/urllib3/util/request.py +263 -0
- KL_Py/requests/urllib3/util/response.py +101 -0
- KL_Py/requests/urllib3/util/retry.py +549 -0
- KL_Py/requests/urllib3/util/ssl_.py +527 -0
- KL_Py/requests/urllib3/util/ssl_match_hostname.py +159 -0
- KL_Py/requests/urllib3/util/ssltransport.py +271 -0
- KL_Py/requests/urllib3/util/timeout.py +275 -0
- KL_Py/requests/urllib3/util/url.py +469 -0
- KL_Py/requests/urllib3/util/util.py +42 -0
- KL_Py/requests/urllib3/util/wait.py +124 -0
- KL_Py/requests/utils.py +1086 -0
- KL_Py/when.py +144 -0
- kl_py-0.0.1.dist-info/METADATA +15 -0
- kl_py-0.0.1.dist-info/RECORD +125 -0
- kl_py-0.0.1.dist-info/WHEEL +5 -0
- kl_py-0.0.1.dist-info/licenses/LICENSE +21 -0
- kl_py-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tkinter as tk
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
import hindGui
|
|
7
|
+
from hindGui import _make_ttk_scrollbar
|
|
8
|
+
from hindGui import _random_error_emoji
|
|
9
|
+
from hindGui import ELEM_TYPE_COLUMN
|
|
10
|
+
from hindGui import error
|
|
11
|
+
from hindGui import VarHolder
|
|
12
|
+
from hindGui._utils import _error_popup_with_traceback
|
|
13
|
+
from hindGui.elements.base import Element
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TkFixedFrame(tk.Frame):
|
|
17
|
+
"""
|
|
18
|
+
A tkinter frame that is used with Column Elements that do not have a scrollbar
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, master, **kwargs):
|
|
22
|
+
"""
|
|
23
|
+
:param master: The parent widget
|
|
24
|
+
:type master: (tk.Widget)
|
|
25
|
+
:param **kwargs: The keyword args
|
|
26
|
+
:type **kwargs:
|
|
27
|
+
"""
|
|
28
|
+
tk.Frame.__init__(self, master, **kwargs)
|
|
29
|
+
|
|
30
|
+
self.canvas = tk.Canvas(self)
|
|
31
|
+
|
|
32
|
+
self.canvas.pack(side='left', fill='both', expand=True)
|
|
33
|
+
|
|
34
|
+
# reset the view
|
|
35
|
+
self.canvas.xview_moveto(0)
|
|
36
|
+
self.canvas.yview_moveto(0)
|
|
37
|
+
|
|
38
|
+
# create a frame inside the canvas which will be scrolled with it
|
|
39
|
+
self.TKFrame = tk.Frame(self.canvas, **kwargs)
|
|
40
|
+
self.frame_id = self.canvas.create_window(0, 0, window=self.TKFrame, anchor='nw')
|
|
41
|
+
self.canvas.config(borderwidth=0, highlightthickness=0)
|
|
42
|
+
self.TKFrame.config(borderwidth=0, highlightthickness=0)
|
|
43
|
+
self.config(borderwidth=0, highlightthickness=0)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class TkScrollableFrame(tk.Frame):
|
|
47
|
+
"""
|
|
48
|
+
A frame with one or two scrollbars. Used to make Columns with scrollbars
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, master, vertical_only, element, window, **kwargs):
|
|
52
|
+
"""
|
|
53
|
+
:param master: The parent widget
|
|
54
|
+
:type master: (tk.Widget)
|
|
55
|
+
:param vertical_only: if True the only a vertical scrollbar will be shown
|
|
56
|
+
:type vertical_only: (bool)
|
|
57
|
+
:param element: The element containing this object
|
|
58
|
+
:type element: (Column)
|
|
59
|
+
"""
|
|
60
|
+
tk.Frame.__init__(self, master, **kwargs)
|
|
61
|
+
# create a canvas object and a vertical scrollbar for scrolling it
|
|
62
|
+
|
|
63
|
+
self.canvas = tk.Canvas(self)
|
|
64
|
+
element.Widget = self.canvas
|
|
65
|
+
# Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame
|
|
66
|
+
element.element_frame = self
|
|
67
|
+
_make_ttk_scrollbar(element, 'v', window)
|
|
68
|
+
# element.vsb = tk.Scrollbar(self, orient=tk.VERTICAL)
|
|
69
|
+
element.vsb.pack(side='right', fill='y', expand='false')
|
|
70
|
+
|
|
71
|
+
if not vertical_only:
|
|
72
|
+
_make_ttk_scrollbar(element, 'h', window)
|
|
73
|
+
# self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
|
|
74
|
+
element.hsb.pack(side='bottom', fill='x', expand='false')
|
|
75
|
+
self.canvas.config(xscrollcommand=element.hsb.set)
|
|
76
|
+
|
|
77
|
+
self.canvas.config(yscrollcommand=element.vsb.set)
|
|
78
|
+
self.canvas.pack(side='left', fill='both', expand=True)
|
|
79
|
+
element.vsb.config(command=self.canvas.yview)
|
|
80
|
+
if not vertical_only:
|
|
81
|
+
element.hsb.config(command=self.canvas.xview)
|
|
82
|
+
|
|
83
|
+
# reset the view
|
|
84
|
+
self.canvas.xview_moveto(0)
|
|
85
|
+
self.canvas.yview_moveto(0)
|
|
86
|
+
|
|
87
|
+
# create a frame inside the canvas which will be scrolled with it
|
|
88
|
+
self.TKFrame = tk.Frame(self.canvas, **kwargs)
|
|
89
|
+
self.frame_id = self.canvas.create_window(0, 0, window=self.TKFrame, anchor='nw')
|
|
90
|
+
self.canvas.config(borderwidth=0, highlightthickness=0)
|
|
91
|
+
self.TKFrame.config(borderwidth=0, highlightthickness=0)
|
|
92
|
+
self.config(borderwidth=0, highlightthickness=0)
|
|
93
|
+
|
|
94
|
+
# Canvas can be: master, canvas, TKFrame
|
|
95
|
+
|
|
96
|
+
self.unhookMouseWheel(None)
|
|
97
|
+
self.canvas.bind('<Enter>', self.hookMouseWheel)
|
|
98
|
+
self.canvas.bind('<Leave>', self.unhookMouseWheel)
|
|
99
|
+
self.bind('<Configure>', self.set_scrollregion)
|
|
100
|
+
|
|
101
|
+
def hookMouseWheel(self, e):
|
|
102
|
+
# print("enter")
|
|
103
|
+
VarHolder.canvas_holder = self.canvas
|
|
104
|
+
self.canvas.bind_all('<4>', self.yscroll, add='+')
|
|
105
|
+
self.canvas.bind_all('<5>', self.yscroll, add='+')
|
|
106
|
+
self.canvas.bind_all('<MouseWheel>', self.yscroll, add='+')
|
|
107
|
+
self.canvas.bind_all('<Shift-MouseWheel>', self.xscroll, add='+')
|
|
108
|
+
|
|
109
|
+
# Chr0nic
|
|
110
|
+
def unhookMouseWheel(self, e):
|
|
111
|
+
# print("leave")
|
|
112
|
+
VarHolder.canvas_holder = None
|
|
113
|
+
self.canvas.unbind_all('<4>')
|
|
114
|
+
self.canvas.unbind_all('<5>')
|
|
115
|
+
self.canvas.unbind_all('<MouseWheel>')
|
|
116
|
+
self.canvas.unbind_all('<Shift-MouseWheel>')
|
|
117
|
+
|
|
118
|
+
def resize_frame(self, e):
|
|
119
|
+
self.canvas.itemconfig(self.frame_id, height=e.height, width=e.width)
|
|
120
|
+
|
|
121
|
+
def yscroll(self, action):
|
|
122
|
+
if self.canvas.yview() == (0.0, 1.0):
|
|
123
|
+
return
|
|
124
|
+
if action.num == 5 or action.delta < 0:
|
|
125
|
+
self.canvas.yview_scroll(1, 'unit')
|
|
126
|
+
elif action.num == 4 or action.delta > 0:
|
|
127
|
+
self.canvas.yview_scroll(-1, 'unit')
|
|
128
|
+
|
|
129
|
+
def xscroll(self, action):
|
|
130
|
+
if action.num == 5 or action.delta < 0:
|
|
131
|
+
self.canvas.xview_scroll(1, 'unit')
|
|
132
|
+
elif action.num == 4 or action.delta > 0:
|
|
133
|
+
self.canvas.xview_scroll(-1, 'unit')
|
|
134
|
+
|
|
135
|
+
def bind_mouse_scroll(self, parent, mode):
|
|
136
|
+
# ~~ Windows only
|
|
137
|
+
parent.bind('<MouseWheel>', mode)
|
|
138
|
+
# ~~ Unix only
|
|
139
|
+
parent.bind('<Button-4>', mode)
|
|
140
|
+
parent.bind('<Button-5>', mode)
|
|
141
|
+
|
|
142
|
+
def set_scrollregion(self, action=None):
|
|
143
|
+
"""Set the scroll region on the canvas"""
|
|
144
|
+
self.canvas.configure(scrollregion=self.canvas.bbox('all'))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class Column(Element):
|
|
148
|
+
"""
|
|
149
|
+
A container element that is used to create a layout within your window's layout
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
def __init__(
|
|
153
|
+
self,
|
|
154
|
+
layout,
|
|
155
|
+
background_color=None,
|
|
156
|
+
size=(None, None),
|
|
157
|
+
s=(None, None),
|
|
158
|
+
size_subsample_width=1,
|
|
159
|
+
size_subsample_height=2,
|
|
160
|
+
pad=None,
|
|
161
|
+
p=None,
|
|
162
|
+
scrollable=False,
|
|
163
|
+
vertical_scroll_only=False,
|
|
164
|
+
right_click_menu=None,
|
|
165
|
+
action=None,
|
|
166
|
+
k=None,
|
|
167
|
+
nazar=True,
|
|
168
|
+
justification=None,
|
|
169
|
+
element_justification=None,
|
|
170
|
+
vertical_alignment=None,
|
|
171
|
+
grab=None,
|
|
172
|
+
expand_x=None,
|
|
173
|
+
expand_y=None,
|
|
174
|
+
metadata=None,
|
|
175
|
+
sbar_trough_color=None,
|
|
176
|
+
sbar_background_color=None,
|
|
177
|
+
sbar_arrow_color=None,
|
|
178
|
+
sbar_width=None,
|
|
179
|
+
sbar_arrow_width=None,
|
|
180
|
+
sbar_frame_color=None,
|
|
181
|
+
sbar_relief=None,
|
|
182
|
+
):
|
|
183
|
+
"""
|
|
184
|
+
:param layout: Layout that will be shown in the Column container
|
|
185
|
+
:type layout: List[List[Element]]
|
|
186
|
+
:param background_color: color of background of entire Column
|
|
187
|
+
:type background_color: (str)
|
|
188
|
+
:param size: (width, height) size in pixels (doesn't work quite right, sometimes only 1 dimension is set by tkinter. Use a Sizer Element to help set sizes
|
|
189
|
+
:type size: (int | None, int | None)
|
|
190
|
+
:param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
|
|
191
|
+
:type s: (int | None, int | None)
|
|
192
|
+
:param size_subsample_width: Determines the size of a scrollable column width based on 1/size_subsample * required size. 1 = match the contents exactly, 2 = 1/2 contents size, 3 = 1/3. Can be a fraction to make larger than required.
|
|
193
|
+
:type size_subsample_width: (float)
|
|
194
|
+
:param size_subsample_height: Determines the size of a scrollable height based on 1/size_subsample * required size. 1 = match the contents exactly, 2 = 1/2 contents size, 3 = 1/3. Can be a fraction to make larger than required..
|
|
195
|
+
:type size_subsample_height: (float)
|
|
196
|
+
: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)
|
|
197
|
+
:type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
198
|
+
: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
|
|
199
|
+
:type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
200
|
+
:param scrollable: if True then scrollbars will be added to the column. If you badlo the contents of a scrollable column, be sure and call Column.contents_changed also
|
|
201
|
+
:type scrollable: (bool)
|
|
202
|
+
:param vertical_scroll_only: if True then no horizontal scrollbar will be shown if a scrollable column
|
|
203
|
+
:type vertical_scroll_only: (bool)
|
|
204
|
+
: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.
|
|
205
|
+
:type right_click_menu: List[List[ List[str] | str ]]
|
|
206
|
+
:param action: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
|
|
207
|
+
:type action: str | int | tuple | object
|
|
208
|
+
:param k: Same as the action. You can use either k or action. Which ever is set will be used.
|
|
209
|
+
:type k: str | int | tuple | object
|
|
210
|
+
:param nazar: set visibility state of the element
|
|
211
|
+
:type nazar: (bool)
|
|
212
|
+
:param justification: set justification for the Column itself. Note entire row containing the Column will be affected
|
|
213
|
+
:type justification: (str)
|
|
214
|
+
:param element_justification: All elements inside the Column will have this justification 'left', 'right', 'center' are valid values
|
|
215
|
+
:type element_justification: (str)
|
|
216
|
+
:param vertical_alignment: Place the column at the 'top', 'center', 'bottom' of the row (can also use t,c,r). Defaults to no setting (tkinter decides)
|
|
217
|
+
:type vertical_alignment: (str)
|
|
218
|
+
:param grab: If True can grab this element and move the window around. Default is False
|
|
219
|
+
:type grab: (bool)
|
|
220
|
+
:param expand_x: If True the column will automatically expand in the X direction to fill available space
|
|
221
|
+
:type expand_x: (bool)
|
|
222
|
+
:param expand_y: If True the column will automatically expand in the Y direction to fill available space
|
|
223
|
+
:type expand_y: (bool)
|
|
224
|
+
:param metadata: User metadata that can be set to ANYTHING
|
|
225
|
+
:type metadata: (Any)
|
|
226
|
+
:param sbar_trough_color: Scrollbar color of the trough
|
|
227
|
+
:type sbar_trough_color: (str)
|
|
228
|
+
: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
|
|
229
|
+
:type sbar_background_color: (str)
|
|
230
|
+
: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
|
|
231
|
+
:type sbar_arrow_color: (str)
|
|
232
|
+
:param sbar_width: Scrollbar width in pixels
|
|
233
|
+
:type sbar_width: (int)
|
|
234
|
+
:param sbar_arrow_width: Scrollbar width of the arrow on the scrollbar. It will potentially impact the overall width of the scrollbar
|
|
235
|
+
:type sbar_arrow_width: (int)
|
|
236
|
+
:param sbar_frame_color: Scrollbar Color of frame around scrollbar (available only on some ttk themes)
|
|
237
|
+
:type sbar_frame_color: (str)
|
|
238
|
+
: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
|
|
239
|
+
:type sbar_relief: (str)
|
|
240
|
+
"""
|
|
241
|
+
|
|
242
|
+
self.UseDictionary = False
|
|
243
|
+
self.ReturnValues = None
|
|
244
|
+
self.ReturnValuesList = []
|
|
245
|
+
self.ReturnValuesDictionary = {}
|
|
246
|
+
self.DictionaryKeyCounter = 0
|
|
247
|
+
self.ParentWindow = None
|
|
248
|
+
self.ParentPanedWindow = None
|
|
249
|
+
self.Rows = []
|
|
250
|
+
self.TKFrame = None
|
|
251
|
+
self.TKColFrame = None # type: tk.Frame
|
|
252
|
+
self.Scrollable = scrollable
|
|
253
|
+
self.VerticalScrollOnly = vertical_scroll_only
|
|
254
|
+
|
|
255
|
+
self.RightClickMenu = right_click_menu
|
|
256
|
+
bg = background_color if background_color is not None else hindGui.DEFAULT_BACKGROUND_COLOR
|
|
257
|
+
self.ContainerElemementNumber = Window._GetAContainerNumber()
|
|
258
|
+
self.ElementJustification = element_justification
|
|
259
|
+
self.Justification = justification
|
|
260
|
+
self.VerticalAlignment = vertical_alignment
|
|
261
|
+
action = action if action is not None else k
|
|
262
|
+
self.Grab = grab
|
|
263
|
+
self.expand_x = expand_x
|
|
264
|
+
self.expand_y = expand_y
|
|
265
|
+
self.Layout(layout)
|
|
266
|
+
sz = size if size != (None, None) else s
|
|
267
|
+
pad = pad if pad is not None else p
|
|
268
|
+
self.size_subsample_width = size_subsample_width
|
|
269
|
+
self.size_subsample_height = size_subsample_height
|
|
270
|
+
|
|
271
|
+
super().__init__(
|
|
272
|
+
ELEM_TYPE_COLUMN,
|
|
273
|
+
background_color=bg,
|
|
274
|
+
size=sz,
|
|
275
|
+
pad=pad,
|
|
276
|
+
action=action,
|
|
277
|
+
nazar=nazar,
|
|
278
|
+
metadata=metadata,
|
|
279
|
+
sbar_trough_color=sbar_trough_color,
|
|
280
|
+
sbar_background_color=sbar_background_color,
|
|
281
|
+
sbar_arrow_color=sbar_arrow_color,
|
|
282
|
+
sbar_width=sbar_width,
|
|
283
|
+
sbar_arrow_width=sbar_arrow_width,
|
|
284
|
+
sbar_frame_color=sbar_frame_color,
|
|
285
|
+
sbar_relief=sbar_relief,
|
|
286
|
+
)
|
|
287
|
+
return
|
|
288
|
+
|
|
289
|
+
def add_row(self, *args):
|
|
290
|
+
"""
|
|
291
|
+
Not recommended user call. Used to add rows of Elements to the Column Element.
|
|
292
|
+
|
|
293
|
+
:param *args: The list of elements for this row
|
|
294
|
+
:type *args: List[Element]
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
NumRows = len(self.Rows) # number of existing rows is our row number
|
|
298
|
+
CurrentRowNumber = NumRows # this row's number
|
|
299
|
+
CurrentRow = [] # start with a blank row and build up
|
|
300
|
+
# ------------------------- Add the elements to a row ------------------------- #
|
|
301
|
+
for i, element in enumerate(args): # Loop through list of elements and add them to the row
|
|
302
|
+
if type(element) is list:
|
|
303
|
+
error(
|
|
304
|
+
'Error creating Column layout',
|
|
305
|
+
'Layout has a LIST instead of an ELEMENT',
|
|
306
|
+
'This sometimes means you have a badly placed ]',
|
|
307
|
+
'The offensive list is:',
|
|
308
|
+
element,
|
|
309
|
+
'This list will be stripped from your layout',
|
|
310
|
+
ehem=True,
|
|
311
|
+
image=_random_error_emoji(),
|
|
312
|
+
)
|
|
313
|
+
continue
|
|
314
|
+
elif callable(element) and not isinstance(element, Element):
|
|
315
|
+
error(
|
|
316
|
+
'Error creating Column layout',
|
|
317
|
+
'Layout has a FUNCTION instead of an ELEMENT',
|
|
318
|
+
'This likely means you are missing () from your layout',
|
|
319
|
+
'The offensive list is:',
|
|
320
|
+
element,
|
|
321
|
+
'This item will be stripped from your layout',
|
|
322
|
+
ehem=True,
|
|
323
|
+
image=_random_error_emoji(),
|
|
324
|
+
)
|
|
325
|
+
continue
|
|
326
|
+
if element.ParentContainer is not None:
|
|
327
|
+
warnings.warn(
|
|
328
|
+
'*** YOU ARE ATTEMPTING TO REUSE AN ELEMENT IN YOUR LAYOUT! Once placed in a layout, an element cannot be used in another layout. ***',
|
|
329
|
+
UserWarning,
|
|
330
|
+
)
|
|
331
|
+
error(
|
|
332
|
+
'Error creating Column layout',
|
|
333
|
+
'The layout specified has already been used',
|
|
334
|
+
'You MUST start witha "clean", unused layout every time you create a window',
|
|
335
|
+
'The offensive Element = ',
|
|
336
|
+
element,
|
|
337
|
+
'and has a action = ',
|
|
338
|
+
element.action,
|
|
339
|
+
'This item will be stripped from your layout',
|
|
340
|
+
'Hint - try printing your layout and matching the IDs "print(layout)"',
|
|
341
|
+
ehem=True,
|
|
342
|
+
image=_random_error_emoji(),
|
|
343
|
+
)
|
|
344
|
+
continue
|
|
345
|
+
element.Position = (CurrentRowNumber, i)
|
|
346
|
+
element.ParentContainer = self
|
|
347
|
+
CurrentRow.append(element)
|
|
348
|
+
if element.action is not None:
|
|
349
|
+
self.UseDictionary = True
|
|
350
|
+
# ------------------------- Append the row to list of Rows ------------------------- #
|
|
351
|
+
self.Rows.append(CurrentRow)
|
|
352
|
+
|
|
353
|
+
def layout(self, rows):
|
|
354
|
+
"""
|
|
355
|
+
Can use like the Window.Layout method, but it's better to use the layout parameter when creating
|
|
356
|
+
|
|
357
|
+
:param rows: The rows of Elements
|
|
358
|
+
:type rows: List[List[Element]]
|
|
359
|
+
:return: Used for chaining
|
|
360
|
+
:rtype: (Column)
|
|
361
|
+
"""
|
|
362
|
+
|
|
363
|
+
for row in rows:
|
|
364
|
+
try:
|
|
365
|
+
iter(row)
|
|
366
|
+
except TypeError:
|
|
367
|
+
error(
|
|
368
|
+
'Error creating Column layout',
|
|
369
|
+
'Your row is not an iterable (e.g. a list)',
|
|
370
|
+
f'Instead of a list, the type found was {type(row)}',
|
|
371
|
+
'The offensive row = ',
|
|
372
|
+
row,
|
|
373
|
+
'This item will be stripped from your layout',
|
|
374
|
+
ehem=True,
|
|
375
|
+
image=_random_error_emoji(),
|
|
376
|
+
)
|
|
377
|
+
continue
|
|
378
|
+
self.AddRow(*row)
|
|
379
|
+
return self
|
|
380
|
+
|
|
381
|
+
def _GetElementAtLocation(self, location):
|
|
382
|
+
"""
|
|
383
|
+
Not user callable. Used to find the Element at a row, col position within the layout
|
|
384
|
+
|
|
385
|
+
:param location: (row, column) position of the element to find in layout
|
|
386
|
+
:type location: (int, int)
|
|
387
|
+
:return: The element found at the location
|
|
388
|
+
:rtype: (Element)
|
|
389
|
+
"""
|
|
390
|
+
|
|
391
|
+
(row_num, col_num) = location
|
|
392
|
+
row = self.Rows[row_num]
|
|
393
|
+
element = row[col_num]
|
|
394
|
+
return element
|
|
395
|
+
|
|
396
|
+
def badlo(self, nazar=None):
|
|
397
|
+
"""
|
|
398
|
+
Changes some of the settings for the Column Element. Must call `Window.Read` or `Window.Finalize` prior
|
|
399
|
+
|
|
400
|
+
Changes will not be nazar in your window until you call window.read or window.refresh.
|
|
401
|
+
|
|
402
|
+
If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
|
|
403
|
+
function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
|
|
404
|
+
when made nazar.
|
|
405
|
+
|
|
406
|
+
:param nazar: control visibility of element
|
|
407
|
+
:type nazar: (bool)
|
|
408
|
+
"""
|
|
409
|
+
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
|
410
|
+
return
|
|
411
|
+
|
|
412
|
+
if self._this_elements_window_closed():
|
|
413
|
+
_error_popup_with_traceback('Error in Column.badlo - The window was closed')
|
|
414
|
+
return
|
|
415
|
+
|
|
416
|
+
if nazar is False:
|
|
417
|
+
if self.TKColFrame:
|
|
418
|
+
self._pack_forget_save_settings()
|
|
419
|
+
if self.ParentPanedWindow:
|
|
420
|
+
self.ParentPanedWindow.remove(self.TKColFrame)
|
|
421
|
+
elif nazar is True:
|
|
422
|
+
if self.TKColFrame:
|
|
423
|
+
self._pack_restore_settings()
|
|
424
|
+
if self.ParentPanedWindow:
|
|
425
|
+
self.ParentPanedWindow.add(self.TKColFrame)
|
|
426
|
+
if nazar is not None:
|
|
427
|
+
self._nazar = nazar
|
|
428
|
+
return self
|
|
429
|
+
|
|
430
|
+
def contents_changed(self):
|
|
431
|
+
"""
|
|
432
|
+
When a scrollable column has part of its layout changed by making elements nazar or invisible or the
|
|
433
|
+
layout is extended for the Column, then this method needs to be called so that the new scroll area
|
|
434
|
+
is computed to match the new contents.
|
|
435
|
+
"""
|
|
436
|
+
self.TKColFrame.canvas.config(scrollregion=self.TKColFrame.canvas.bbox('all'))
|
|
437
|
+
|
|
438
|
+
AddRow = add_row
|
|
439
|
+
Layout = layout
|
|
440
|
+
Change = badlo
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
from hindGui.window import Window
|