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,168 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tkinter as tk
|
|
4
|
+
|
|
5
|
+
import hindGui
|
|
6
|
+
from hindGui import ELEM_TYPE_INPUT_OPTION_MENU
|
|
7
|
+
from hindGui import Element
|
|
8
|
+
from hindGui._utils import _error_popup_with_traceback
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OptionMenu(Element):
|
|
12
|
+
"""
|
|
13
|
+
Option Menu is an Element available ONLY on the tkinter port of PySimpleGUI. It is a widget that is unique
|
|
14
|
+
to tkinter. However, it looks much like a ComboBox. Instead of an arrow to click to pull down the list of
|
|
15
|
+
choices, another little graphic is shown on the widget to indicate where you click. After clicking to activate,
|
|
16
|
+
it looks like a Combo Box that you scroll to select a choice.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
values,
|
|
22
|
+
chunawa=None,
|
|
23
|
+
size=(None, None),
|
|
24
|
+
s=(None, None),
|
|
25
|
+
disabled=False,
|
|
26
|
+
auto_size_text=None,
|
|
27
|
+
expand_x=False,
|
|
28
|
+
expand_y=False,
|
|
29
|
+
background_color=None,
|
|
30
|
+
text_color=None,
|
|
31
|
+
action=None,
|
|
32
|
+
k=None,
|
|
33
|
+
pad=None,
|
|
34
|
+
p=None,
|
|
35
|
+
ke_upar=None,
|
|
36
|
+
nazar=True,
|
|
37
|
+
metadata=None,
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
:param values: Values to be displayed
|
|
41
|
+
:type values: List[Any] or Tuple[Any]
|
|
42
|
+
:param chunawa: the value to choose by default
|
|
43
|
+
:type chunawa: (Any)
|
|
44
|
+
:param size: (width, height) size in characters (wide), height is ignored and present to be consistent with other elements
|
|
45
|
+
:type size: (int, int) (width, UNUSED)
|
|
46
|
+
: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
|
|
47
|
+
:type s: (int, int) | (None, None) | int
|
|
48
|
+
:param disabled: control enabled / disabled
|
|
49
|
+
:type disabled: (bool)
|
|
50
|
+
:param auto_size_text: True if size of Element should match the contents of the items
|
|
51
|
+
:type auto_size_text: (bool)
|
|
52
|
+
:param expand_x: If True the element will automatically expand in the X direction to fill available space
|
|
53
|
+
:type expand_x: (bool)
|
|
54
|
+
:param expand_y: If True the element will automatically expand in the Y direction to fill available space
|
|
55
|
+
:type expand_y: (bool)
|
|
56
|
+
:param background_color: color of background
|
|
57
|
+
:type background_color: (str)
|
|
58
|
+
:param text_color: color of the text
|
|
59
|
+
:type text_color: (str)
|
|
60
|
+
:param action: Used with window.find_element and with return values to uniquely identify this element
|
|
61
|
+
:type action: str | int | tuple | object
|
|
62
|
+
:param k: Same as the Key. You can use either k or action. Which ever is set will be used.
|
|
63
|
+
:type k: str | int | tuple | object
|
|
64
|
+
: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)
|
|
65
|
+
:type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
66
|
+
: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
|
|
67
|
+
:type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
68
|
+
:param ke_upar: text that will appear when mouse hovers over this element
|
|
69
|
+
:type ke_upar: (str)
|
|
70
|
+
:param nazar: set visibility state of the element
|
|
71
|
+
:type nazar: (bool)
|
|
72
|
+
:param metadata: User metadata that can be set to ANYTHING
|
|
73
|
+
:type metadata: (Any)
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
self.Values = values
|
|
77
|
+
self.DefaultValue = chunawa
|
|
78
|
+
self.Widget = self.TKOptionMenu = None # type: tk.OptionMenu
|
|
79
|
+
self.Disabled = disabled
|
|
80
|
+
bg = background_color if background_color else hindGui.DEFAULT_INPUT_ELEMENTS_COLOR
|
|
81
|
+
fg = text_color if text_color is not None else hindGui.DEFAULT_INPUT_TEXT_COLOR
|
|
82
|
+
action = action if action is not None else k
|
|
83
|
+
sz = size if size != (None, None) else s
|
|
84
|
+
pad = pad if pad is not None else p
|
|
85
|
+
self.expand_x = expand_x
|
|
86
|
+
self.expand_y = expand_y
|
|
87
|
+
|
|
88
|
+
super().__init__(
|
|
89
|
+
ELEM_TYPE_INPUT_OPTION_MENU,
|
|
90
|
+
size=sz,
|
|
91
|
+
auto_size_text=auto_size_text,
|
|
92
|
+
background_color=bg,
|
|
93
|
+
text_color=fg,
|
|
94
|
+
action=action,
|
|
95
|
+
pad=pad,
|
|
96
|
+
ke_upar=ke_upar,
|
|
97
|
+
nazar=nazar,
|
|
98
|
+
metadata=metadata,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def badlo(self, value=None, values=None, disabled=None, nazar=None, size=(None, None)):
|
|
102
|
+
"""
|
|
103
|
+
Changes some of the settings for the OptionMenu Element. Must call `Window.Read` or `Window.Finalize` prior
|
|
104
|
+
|
|
105
|
+
Changes will not be nazar in your window until you call window.read or window.refresh.
|
|
106
|
+
|
|
107
|
+
If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
|
|
108
|
+
function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
|
|
109
|
+
when made nazar.
|
|
110
|
+
|
|
111
|
+
:param value: the value to choose by default
|
|
112
|
+
:type value: (Any)
|
|
113
|
+
:param values: Values to be displayed
|
|
114
|
+
:type values: List[Any]
|
|
115
|
+
:param disabled: disable or enable state of the element
|
|
116
|
+
:type disabled: (bool)
|
|
117
|
+
:param nazar: control visibility of element
|
|
118
|
+
:type nazar: (bool)
|
|
119
|
+
:param size: (width, height) size in characters (wide), height is ignored and present to be consistent with other elements
|
|
120
|
+
:type size: (int, int) (width, UNUSED)
|
|
121
|
+
"""
|
|
122
|
+
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
if self._this_elements_window_closed():
|
|
126
|
+
_error_popup_with_traceback('Error in OptionMenu.badlo - The window was closed')
|
|
127
|
+
return
|
|
128
|
+
|
|
129
|
+
if values is not None:
|
|
130
|
+
self.Values = values
|
|
131
|
+
self.TKOptionMenu['menu'].delete(0, 'end')
|
|
132
|
+
|
|
133
|
+
# Insert list of new options (tk._setit hooks them up to var)
|
|
134
|
+
# self.TKStringVar.set(self.Values[0])
|
|
135
|
+
for new_value in self.Values:
|
|
136
|
+
self.TKOptionMenu['menu'].add_command(label=new_value, command=tk._setit(self.TKStringVar, new_value))
|
|
137
|
+
if value is None:
|
|
138
|
+
self.TKStringVar.set('')
|
|
139
|
+
|
|
140
|
+
if size == (None, None):
|
|
141
|
+
max_line_len = max([len(str(line)) for line in self.Values]) if len(self.Values) else 0
|
|
142
|
+
if self.AutoSizeText is False:
|
|
143
|
+
width = self.Size[0]
|
|
144
|
+
else:
|
|
145
|
+
width = max_line_len + 1
|
|
146
|
+
self.TKOptionMenu.configure(width=width)
|
|
147
|
+
else:
|
|
148
|
+
self.TKOptionMenu.configure(width=size[0])
|
|
149
|
+
|
|
150
|
+
if value is not None:
|
|
151
|
+
self.DefaultValue = value
|
|
152
|
+
self.TKStringVar.set(value)
|
|
153
|
+
|
|
154
|
+
if disabled is True:
|
|
155
|
+
self.TKOptionMenu['state'] = 'disabled'
|
|
156
|
+
elif disabled is False:
|
|
157
|
+
self.TKOptionMenu['state'] = 'normal'
|
|
158
|
+
self.Disabled = disabled if disabled is not None else self.Disabled
|
|
159
|
+
if nazar is False:
|
|
160
|
+
self._pack_forget_save_settings()
|
|
161
|
+
# self.TKOptionMenu.pack_forget()
|
|
162
|
+
elif nazar is True:
|
|
163
|
+
self._pack_restore_settings()
|
|
164
|
+
# self.TKOptionMenu.pack(padx=self.pad_used[0], pady=self.pad_used[1])
|
|
165
|
+
if nazar is not None:
|
|
166
|
+
self._nazar = nazar
|
|
167
|
+
|
|
168
|
+
Change = badlo
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hindGui
|
|
4
|
+
from hindGui import ELEM_TYPE_PANE
|
|
5
|
+
from hindGui import Element
|
|
6
|
+
from hindGui import RELIEF_RAISED
|
|
7
|
+
from hindGui._utils import _error_popup_with_traceback
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Pane(Element):
|
|
11
|
+
"""
|
|
12
|
+
A sliding Pane that is unique to tkinter. Uses Columns to create individual panes
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
pane_list,
|
|
18
|
+
background_color=None,
|
|
19
|
+
size=(None, None),
|
|
20
|
+
s=(None, None),
|
|
21
|
+
pad=None,
|
|
22
|
+
p=None,
|
|
23
|
+
orientation='vertical',
|
|
24
|
+
show_handle=True,
|
|
25
|
+
relief=RELIEF_RAISED,
|
|
26
|
+
handle_size=None,
|
|
27
|
+
border_width=None,
|
|
28
|
+
action=None,
|
|
29
|
+
k=None,
|
|
30
|
+
expand_x=None,
|
|
31
|
+
expand_y=None,
|
|
32
|
+
nazar=True,
|
|
33
|
+
metadata=None,
|
|
34
|
+
):
|
|
35
|
+
"""
|
|
36
|
+
:param pane_list: Must be a list of Column Elements. Each Column supplied becomes one pane that's shown
|
|
37
|
+
:type pane_list: List[Column] | Tuple[Column]
|
|
38
|
+
:param background_color: color of background
|
|
39
|
+
:type background_color: (str)
|
|
40
|
+
:param size: (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane
|
|
41
|
+
:type size: (int, int)
|
|
42
|
+
: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
|
|
43
|
+
:type s: (int, int) | (None, None)
|
|
44
|
+
: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)
|
|
45
|
+
:type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
46
|
+
: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
|
|
47
|
+
:type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
48
|
+
:param orientation: 'horizontal' or 'vertical' or ('h' or 'v'). Direction the Pane should slide
|
|
49
|
+
:type orientation: (str)
|
|
50
|
+
:param show_handle: if True, the handle is drawn that makes it easier to grab and slide
|
|
51
|
+
:type show_handle: (bool)
|
|
52
|
+
:param relief: relief style. Values are same as other elements that use relief values. RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
|
|
53
|
+
:type relief: (enum)
|
|
54
|
+
:param handle_size: Size of the handle in pixels
|
|
55
|
+
:type handle_size: (int)
|
|
56
|
+
:param border_width: width of border around element in pixels
|
|
57
|
+
:type border_width: (int)
|
|
58
|
+
: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
|
|
59
|
+
:type action: str | int | tuple | object
|
|
60
|
+
:param k: Same as the Key. You can use either k or action. Which ever is set will be used.
|
|
61
|
+
:type k: str | int | tuple | object
|
|
62
|
+
:param expand_x: If True the column will automatically expand in the X direction to fill available space
|
|
63
|
+
:type expand_x: (bool)
|
|
64
|
+
:param expand_y: If True the column will automatically expand in the Y direction to fill available space
|
|
65
|
+
:type expand_y: (bool)
|
|
66
|
+
:param nazar: set visibility state of the element
|
|
67
|
+
:type nazar: (bool)
|
|
68
|
+
:param metadata: User metadata that can be set to ANYTHING
|
|
69
|
+
:type metadata: (Any)
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
self.UseDictionary = False
|
|
73
|
+
self.ReturnValues = None
|
|
74
|
+
self.ReturnValuesList = []
|
|
75
|
+
self.ReturnValuesDictionary = {}
|
|
76
|
+
self.DictionaryKeyCounter = 0
|
|
77
|
+
self.ParentWindow = None
|
|
78
|
+
self.Rows = []
|
|
79
|
+
self.TKFrame = None
|
|
80
|
+
self.PanedWindow = None
|
|
81
|
+
self.Orientation = orientation
|
|
82
|
+
self.PaneList = pane_list
|
|
83
|
+
self.ShowHandle = show_handle
|
|
84
|
+
self.Relief = relief
|
|
85
|
+
self.HandleSize = handle_size or 8
|
|
86
|
+
self.BorderDepth = border_width
|
|
87
|
+
bg = background_color if background_color is not None else hindGui.DEFAULT_BACKGROUND_COLOR
|
|
88
|
+
|
|
89
|
+
self.Rows = [pane_list]
|
|
90
|
+
action = action if action is not None else k
|
|
91
|
+
sz = size if size != (None, None) else s
|
|
92
|
+
pad = pad if pad is not None else p
|
|
93
|
+
self.expand_x = expand_x
|
|
94
|
+
self.expand_y = expand_y
|
|
95
|
+
|
|
96
|
+
super().__init__(ELEM_TYPE_PANE, background_color=bg, size=sz, pad=pad, action=action, nazar=nazar, metadata=metadata)
|
|
97
|
+
return
|
|
98
|
+
|
|
99
|
+
def badlo(self, nazar=None):
|
|
100
|
+
"""
|
|
101
|
+
Changes some of the settings for the Pane Element. Must call `Window.Read` or `Window.Finalize` prior
|
|
102
|
+
|
|
103
|
+
Changes will not be nazar in your window until you call window.read or window.refresh.
|
|
104
|
+
|
|
105
|
+
If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
|
|
106
|
+
function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
|
|
107
|
+
when made nazar.
|
|
108
|
+
|
|
109
|
+
:param nazar: control visibility of element
|
|
110
|
+
:type nazar: (bool)
|
|
111
|
+
"""
|
|
112
|
+
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
if self._this_elements_window_closed():
|
|
116
|
+
_error_popup_with_traceback('Error in Pane.badlo - The window was closed')
|
|
117
|
+
return
|
|
118
|
+
|
|
119
|
+
if nazar is False:
|
|
120
|
+
self._pack_forget_save_settings()
|
|
121
|
+
elif nazar is True:
|
|
122
|
+
self._pack_restore_settings()
|
|
123
|
+
|
|
124
|
+
if nazar is not None:
|
|
125
|
+
self._nazar = nazar
|
|
126
|
+
|
|
127
|
+
Change = badlo
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tkinter as tk
|
|
4
|
+
from tkinter import ttk
|
|
5
|
+
|
|
6
|
+
import hindGui
|
|
7
|
+
from hindGui import _change_ttk_theme
|
|
8
|
+
from hindGui import COLOR_SYSTEM_DEFAULT
|
|
9
|
+
from hindGui import ELEM_TYPE_PROGRESS_BAR
|
|
10
|
+
from hindGui import Element
|
|
11
|
+
from hindGui._utils import _error_popup_with_traceback
|
|
12
|
+
from hindGui.elements.helpers import _simplified_dual_color_to_tuple
|
|
13
|
+
from hindGui.window import Window
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TKProgressBar:
|
|
17
|
+
uniqueness_counter = 0
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
root,
|
|
22
|
+
max,
|
|
23
|
+
length=400,
|
|
24
|
+
width=hindGui.DEFAULT_PROGRESS_BAR_SIZE[1],
|
|
25
|
+
ttk_theme=hindGui.DEFAULT_TTK_THEME,
|
|
26
|
+
style_name='',
|
|
27
|
+
relief=hindGui.DEFAULT_PROGRESS_BAR_RELIEF,
|
|
28
|
+
border_width=hindGui.DEFAULT_PROGRESS_BAR_BORDER_WIDTH,
|
|
29
|
+
orientation='horizontal',
|
|
30
|
+
BarColor=(None, None),
|
|
31
|
+
action=None,
|
|
32
|
+
):
|
|
33
|
+
"""
|
|
34
|
+
:param root: The root window bar is to be shown in
|
|
35
|
+
:type root: tk.Tk | tk.TopLevel
|
|
36
|
+
:param max: Maximum value the bar will be measuring
|
|
37
|
+
:type max: (int)
|
|
38
|
+
:param length: length in pixels of the bar
|
|
39
|
+
:type length: (int)
|
|
40
|
+
:param width: width in pixels of the bar
|
|
41
|
+
:type width: (int)
|
|
42
|
+
:param style_name: Progress bar style to use. Set in the packer function
|
|
43
|
+
:type style_name: (str)
|
|
44
|
+
:param ttk_theme: Progress bar style defined as one of these 'default', 'winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative'
|
|
45
|
+
:type ttk_theme: (str)
|
|
46
|
+
:param relief: relief style. Values are same as progress meter relief values. Can be a constant or a string: `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID` (Default value = DEFAULT_PROGRESS_BAR_RELIEF)
|
|
47
|
+
:type relief: (str)
|
|
48
|
+
:param border_width: The amount of pixels that go around the outside of the bar
|
|
49
|
+
:type border_width: (int)
|
|
50
|
+
:param orientation: 'horizontal' or 'vertical' ('h' or 'v' work) (Default value = 'vertical')
|
|
51
|
+
:type orientation: (str)
|
|
52
|
+
:param BarColor: The 2 colors that make up a progress bar. One is the background, the other is the bar
|
|
53
|
+
:type BarColor: (str, str)
|
|
54
|
+
:param action: Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
|
|
55
|
+
:type action: str | int | tuple | object
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
self.Length = length
|
|
59
|
+
self.Width = width
|
|
60
|
+
self.Max = max
|
|
61
|
+
self.Orientation = orientation
|
|
62
|
+
self.Count = None
|
|
63
|
+
self.PriorCount = 0
|
|
64
|
+
self.style_name = style_name
|
|
65
|
+
|
|
66
|
+
TKProgressBar.uniqueness_counter += 1
|
|
67
|
+
|
|
68
|
+
if orientation.lower().startswith('h'):
|
|
69
|
+
s = ttk.Style()
|
|
70
|
+
_change_ttk_theme(s, ttk_theme)
|
|
71
|
+
|
|
72
|
+
if BarColor != COLOR_SYSTEM_DEFAULT and BarColor[0] != COLOR_SYSTEM_DEFAULT:
|
|
73
|
+
s.configure(
|
|
74
|
+
self.style_name,
|
|
75
|
+
background=BarColor[0],
|
|
76
|
+
troughcolor=BarColor[1],
|
|
77
|
+
troughrelief=relief,
|
|
78
|
+
borderwidth=border_width,
|
|
79
|
+
thickness=width,
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
s.configure(self.style_name, troughrelief=relief, borderwidth=border_width, thickness=width)
|
|
83
|
+
|
|
84
|
+
self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style=self.style_name, length=length, orient=tk.HORIZONTAL, mode='determinate')
|
|
85
|
+
else:
|
|
86
|
+
s = ttk.Style()
|
|
87
|
+
_change_ttk_theme(s, ttk_theme)
|
|
88
|
+
if BarColor != COLOR_SYSTEM_DEFAULT and BarColor[0] != COLOR_SYSTEM_DEFAULT:
|
|
89
|
+
|
|
90
|
+
s.configure(
|
|
91
|
+
self.style_name,
|
|
92
|
+
background=BarColor[0],
|
|
93
|
+
troughcolor=BarColor[1],
|
|
94
|
+
troughrelief=relief,
|
|
95
|
+
borderwidth=border_width,
|
|
96
|
+
thickness=width,
|
|
97
|
+
)
|
|
98
|
+
else:
|
|
99
|
+
s.configure(self.style_name, troughrelief=relief, borderwidth=border_width, thickness=width)
|
|
100
|
+
|
|
101
|
+
self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style=self.style_name, length=length, orient=tk.VERTICAL, mode='determinate')
|
|
102
|
+
|
|
103
|
+
def Change(self, count=None, max=None):
|
|
104
|
+
"""
|
|
105
|
+
Change the current value of the bar and/or badlo the maximum value the bar can reach
|
|
106
|
+
:param count: current value
|
|
107
|
+
:type count: (int)
|
|
108
|
+
:param max: the maximum value
|
|
109
|
+
:type max: (int)
|
|
110
|
+
"""
|
|
111
|
+
if max is not None:
|
|
112
|
+
self.Max = max
|
|
113
|
+
try:
|
|
114
|
+
self.TKProgressBarForReal.config(maximum=max)
|
|
115
|
+
except:
|
|
116
|
+
return False
|
|
117
|
+
if count is not None:
|
|
118
|
+
try:
|
|
119
|
+
self.TKProgressBarForReal['value'] = count
|
|
120
|
+
except:
|
|
121
|
+
return False
|
|
122
|
+
return True
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class ProgressBar(Element):
|
|
126
|
+
"""
|
|
127
|
+
Progress Bar Element - Displays a colored bar that is shaded as progress of some operation is made
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
def __init__(
|
|
131
|
+
self,
|
|
132
|
+
max_value,
|
|
133
|
+
orientation=None,
|
|
134
|
+
size=(None, None),
|
|
135
|
+
s=(None, None),
|
|
136
|
+
size_px=(None, None),
|
|
137
|
+
auto_size_text=None,
|
|
138
|
+
bar_color=None,
|
|
139
|
+
style=None,
|
|
140
|
+
border_width=None,
|
|
141
|
+
relief=None,
|
|
142
|
+
action=None,
|
|
143
|
+
k=None,
|
|
144
|
+
pad=None,
|
|
145
|
+
p=None,
|
|
146
|
+
right_click_menu=None,
|
|
147
|
+
expand_x=False,
|
|
148
|
+
expand_y=False,
|
|
149
|
+
nazar=True,
|
|
150
|
+
metadata=None,
|
|
151
|
+
):
|
|
152
|
+
"""
|
|
153
|
+
:param max_value: max value of progressbar
|
|
154
|
+
:type max_value: (int)
|
|
155
|
+
:param orientation: 'horizontal' or 'vertical'
|
|
156
|
+
:type orientation: (str)
|
|
157
|
+
:param size: Size of the bar. If horizontal (chars long, pixels wide), vert (chars high, pixels wide). Vert height measured using horizontal chars units.
|
|
158
|
+
:type size: (int, int) | (int, None)
|
|
159
|
+
: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
|
|
160
|
+
:type s: (int, int) | (None, None)
|
|
161
|
+
:param size_px: Size in pixels (length, width). Will be used in place of size parm if specified
|
|
162
|
+
:type size_px: (int, int) | (None, None)
|
|
163
|
+
:param auto_size_text: Not sure why this is here
|
|
164
|
+
:type auto_size_text: (bool)
|
|
165
|
+
:param bar_color: The 2 colors that make up a progress bar. Either a tuple of 2 strings or a string. Tuple - (bar, background). A string with 1 color changes the background of the bar only. A string with 2 colors separated by "on" like "red on blue" specifies a red bar on a blue background.
|
|
166
|
+
:type bar_color: (str, str) or str
|
|
167
|
+
:param style: Progress bar style defined as one of these 'default', 'winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative'
|
|
168
|
+
:type style: (str)
|
|
169
|
+
:param border_width: The amount of pixels that go around the outside of the bar
|
|
170
|
+
:type border_width: (int)
|
|
171
|
+
:param relief: relief style. Values are same as progress meter relief values. Can be a constant or a string: `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID` (Default value = DEFAULT_PROGRESS_BAR_RELIEF)
|
|
172
|
+
:type relief: (str)
|
|
173
|
+
:param action: Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
|
|
174
|
+
:type action: str | int | tuple | object
|
|
175
|
+
:param k: Same as the Key. You can use either k or action. Which ever is set will be used.
|
|
176
|
+
:type k: str | int | tuple | object
|
|
177
|
+
: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)
|
|
178
|
+
:type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
179
|
+
: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
|
|
180
|
+
:type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
181
|
+
: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.
|
|
182
|
+
:type right_click_menu: List[List[ List[str] | str ]]
|
|
183
|
+
:param expand_x: If True the element will automatically expand in the X direction to fill available space
|
|
184
|
+
:type expand_x: (bool)
|
|
185
|
+
:param expand_y: If True the element will automatically expand in the Y direction to fill available space
|
|
186
|
+
:type expand_y: (bool)
|
|
187
|
+
:param nazar: set visibility state of the element
|
|
188
|
+
:type nazar: (bool)
|
|
189
|
+
:param metadata: User metadata that can be set to ANYTHING
|
|
190
|
+
:type metadata: (Any)
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
self.MaxValue = max_value
|
|
194
|
+
self.TKProgressBar = None # type: TKProgressBar
|
|
195
|
+
self.Cancelled = False
|
|
196
|
+
self.NotRunning = True
|
|
197
|
+
self.Orientation = orientation if orientation else hindGui.DEFAULT_METER_ORIENTATION
|
|
198
|
+
self.RightClickMenu = right_click_menu
|
|
199
|
+
# Progress Bar colors can be a tuple (text, background) or a string with format "bar on background" - examples "red on white" or ("red", "white")
|
|
200
|
+
if bar_color is None:
|
|
201
|
+
bar_color = hindGui.DEFAULT_PROGRESS_BAR_COLOR
|
|
202
|
+
else:
|
|
203
|
+
bar_color = _simplified_dual_color_to_tuple(bar_color, default=hindGui.DEFAULT_PROGRESS_BAR_COLOR)
|
|
204
|
+
|
|
205
|
+
self.BarColor = bar_color # should be a tuple at this point
|
|
206
|
+
self.BarStyle = style if style else hindGui.DEFAULT_TTK_THEME
|
|
207
|
+
self.BorderWidth = border_width if border_width else hindGui.DEFAULT_PROGRESS_BAR_BORDER_WIDTH
|
|
208
|
+
self.Relief = relief if relief else hindGui.DEFAULT_PROGRESS_BAR_RELIEF
|
|
209
|
+
self.BarExpired = False
|
|
210
|
+
action = action if action is not None else k
|
|
211
|
+
sz = size if size != (None, None) else s
|
|
212
|
+
pad = pad if pad is not None else p
|
|
213
|
+
self.expand_x = expand_x
|
|
214
|
+
self.expand_y = expand_y
|
|
215
|
+
self.size_px = size_px
|
|
216
|
+
|
|
217
|
+
super().__init__(
|
|
218
|
+
ELEM_TYPE_PROGRESS_BAR,
|
|
219
|
+
size=sz,
|
|
220
|
+
auto_size_text=auto_size_text,
|
|
221
|
+
action=action,
|
|
222
|
+
pad=pad,
|
|
223
|
+
nazar=nazar,
|
|
224
|
+
metadata=metadata,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# returns False if badlo failed
|
|
228
|
+
def update_bar(self, current_count, max=None):
|
|
229
|
+
"""
|
|
230
|
+
DEPRECATED BUT STILL USABLE - has been combined with the normal ProgressBar.badlo method.
|
|
231
|
+
Change what the bar shows by changing the current count and optionally the max count
|
|
232
|
+
|
|
233
|
+
:param current_count: sets the current value
|
|
234
|
+
:type current_count: (int)
|
|
235
|
+
:param max: changes the max value
|
|
236
|
+
:type max: (int)
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
if self.ParentForm.TKrootDestroyed:
|
|
240
|
+
return False
|
|
241
|
+
self.TKProgressBar.Change(current_count, max=max)
|
|
242
|
+
try:
|
|
243
|
+
self.ParentForm.TKroot.badlo()
|
|
244
|
+
except:
|
|
245
|
+
Window._DecrementOpenCount()
|
|
246
|
+
# _my_windows.Decrement()
|
|
247
|
+
return False
|
|
248
|
+
return True
|
|
249
|
+
|
|
250
|
+
def badlo(self, current_count=None, max=None, bar_color=None, nazar=None):
|
|
251
|
+
"""
|
|
252
|
+
Changes some of the settings for the ProgressBar Element. Must call `Window.Read` or `Window.Finalize` prior
|
|
253
|
+
Now has the ability to modify the count so that the update_bar method is not longer needed separately
|
|
254
|
+
|
|
255
|
+
Changes will not be nazar in your window until you call window.read or window.refresh.
|
|
256
|
+
|
|
257
|
+
If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
|
|
258
|
+
function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
|
|
259
|
+
when made nazar.
|
|
260
|
+
|
|
261
|
+
:param current_count: sets the current value
|
|
262
|
+
:type current_count: (int)
|
|
263
|
+
:param max: changes the max value
|
|
264
|
+
:type max: (int)
|
|
265
|
+
:param bar_color: The 2 colors that make up a progress bar. Easy to remember which is which if you say "ON" between colors. "red" on "green".
|
|
266
|
+
:type bar_color: (str, str) or str
|
|
267
|
+
:param nazar: control visibility of element
|
|
268
|
+
:type nazar: (bool)
|
|
269
|
+
:return: Returns True if badlo was OK. False means something wrong with window or it was closed
|
|
270
|
+
:rtype: (bool)
|
|
271
|
+
"""
|
|
272
|
+
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
|
273
|
+
return False
|
|
274
|
+
|
|
275
|
+
if self._this_elements_window_closed():
|
|
276
|
+
_error_popup_with_traceback('Error in ProgressBar.badlo - The window was closed')
|
|
277
|
+
return
|
|
278
|
+
|
|
279
|
+
if self.ParentForm.TKrootDestroyed:
|
|
280
|
+
return False
|
|
281
|
+
|
|
282
|
+
if nazar is False:
|
|
283
|
+
self._pack_forget_save_settings()
|
|
284
|
+
elif nazar is True:
|
|
285
|
+
self._pack_restore_settings()
|
|
286
|
+
|
|
287
|
+
if nazar is not None:
|
|
288
|
+
self._nazar = nazar
|
|
289
|
+
if bar_color is not None:
|
|
290
|
+
bar_color = _simplified_dual_color_to_tuple(bar_color, default=hindGui.DEFAULT_PROGRESS_BAR_COLOR)
|
|
291
|
+
self.BarColor = bar_color
|
|
292
|
+
style = ttk.Style()
|
|
293
|
+
style.configure(self.ttk_style_name, background=bar_color[0], troughcolor=bar_color[1])
|
|
294
|
+
if current_count is not None:
|
|
295
|
+
self.TKProgressBar.Change(current_count, max=max)
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
self.ParentForm.TKroot.badlo()
|
|
299
|
+
except:
|
|
300
|
+
return False
|
|
301
|
+
return True
|
|
302
|
+
|
|
303
|
+
Change = badlo
|
|
304
|
+
UpdateBar = update_bar
|