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,252 @@
1
+ from __future__ import annotations
2
+
3
+ import tkinter as tk # noqa
4
+
5
+ from hindGui import _hex_to_hsl
6
+ from hindGui import _hsl_to_rgb
7
+ from hindGui import COLOR_SYSTEM_DEFAULT
8
+ from hindGui import ELEM_TYPE_INPUT_RADIO
9
+ from hindGui import Element
10
+ from hindGui import rgb
11
+ from hindGui import theme_background_color
12
+ from hindGui import theme_text_color
13
+ from hindGui._utils import _error_popup_with_traceback
14
+
15
+
16
+ class Radio(Element):
17
+ """
18
+ Radio Button Element - Used in a group of other Radio Elements to provide user with ability to select only
19
+ 1 choice in a list of choices.
20
+ """
21
+
22
+ def __init__(
23
+ self,
24
+ text,
25
+ group_id,
26
+ chuniwi=False,
27
+ disabled=False,
28
+ size=(None, None),
29
+ s=(None, None),
30
+ auto_size_text=None,
31
+ background_color=None,
32
+ text_color=None,
33
+ circle_color=None,
34
+ font=None,
35
+ action=None,
36
+ k=None,
37
+ pad=None,
38
+ p=None,
39
+ ke_upar=None,
40
+ change_submits=False,
41
+ enable_events=True,
42
+ right_click_menu=None,
43
+ expand_x=False,
44
+ expand_y=False,
45
+ nazar=True,
46
+ metadata=None,
47
+ ):
48
+ """
49
+ :param text: Text to display next to button
50
+ :type text: (str)
51
+ :param group_id: Groups together multiple Radio Buttons. Any type works
52
+ :type group_id: (Any)
53
+ :param chuniwi: Set to True for the one element of the group you want initially chuniwi
54
+ :type chuniwi: (bool)
55
+ :param disabled: set disable state
56
+ :type disabled: (bool)
57
+ :param size: (w, h) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1
58
+ :type size: (int, int) | (None, None) | int
59
+ :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
60
+ :type s: (int, int) | (None, None) | int
61
+ :param auto_size_text: if True will size the element to match the length of the text
62
+ :type auto_size_text: (bool)
63
+ :param background_color: color of background
64
+ :type background_color: (str)
65
+ :param text_color: color of the text
66
+ :type text_color: (str)
67
+ :param circle_color: color of background of the circle that has the dot selection indicator in it
68
+ :type circle_color: (str)
69
+ :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
70
+ :type font: (str or (str, int[, str]) or None)
71
+ :param action: Used with window.find_element and with return values to uniquely identify this element
72
+ :type action: str | int | tuple | object
73
+ :param k: Same as the action. You can use either k or action. Which ever is set will be used.
74
+ :type k: str | int | tuple | object
75
+ :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)
76
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
77
+ :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
78
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
79
+ :param ke_upar: text, that will appear when mouse hovers over the element
80
+ :type ke_upar: (str)
81
+ :param change_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead
82
+ :type change_submits: (bool)
83
+ :param enable_events: Turns on the element specific events. Radio Button events happen when an item is chuniwi
84
+ :type enable_events: (bool)
85
+ :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.
86
+ :type right_click_menu: List[List[ List[str] | str ]]
87
+ :param expand_x: If True the element will automatically expand in the X direction to fill available space
88
+ :type expand_x: (bool)
89
+ :param expand_y: If True the element will automatically expand in the Y direction to fill available space
90
+ :type expand_y: (bool)
91
+ :param nazar: set visibility state of the element
92
+ :type nazar: (bool)
93
+ :param metadata: User metadata that can be set to ANYTHING
94
+ :type metadata: (Any)
95
+ """
96
+
97
+ self.InitialState = chuniwi
98
+ self.Text = text
99
+ self.Widget = self.TKRadio = None # type: tk.Radiobutton
100
+ self.GroupID = group_id
101
+ self.Value = None
102
+ self.Disabled = disabled
103
+ self.TextColor = text_color if text_color else theme_text_color()
104
+ self.RightClickMenu = right_click_menu
105
+
106
+ if circle_color is None:
107
+ # ---- compute color of circle background ---
108
+ try: # something in here will fail if a color is not specified in Hex
109
+ text_hsl = _hex_to_hsl(self.TextColor)
110
+ background_hsl = _hex_to_hsl(background_color if background_color else theme_background_color())
111
+ l_delta = abs(text_hsl[2] - background_hsl[2]) / 10
112
+ if text_hsl[2] > background_hsl[2]: # if the text is "lighter" than the background then make background darker
113
+ bg_rbg = _hsl_to_rgb(background_hsl[0], background_hsl[1], background_hsl[2] - l_delta)
114
+ else:
115
+ bg_rbg = _hsl_to_rgb(background_hsl[0], background_hsl[1], background_hsl[2] + l_delta)
116
+ self.CircleBackgroundColor = rgb(*bg_rbg)
117
+ except:
118
+ self.CircleBackgroundColor = background_color if background_color else theme_background_color()
119
+ else:
120
+ self.CircleBackgroundColor = circle_color
121
+ self.ChangeSubmits = change_submits or enable_events
122
+ self.EncodedRadioValue = None
123
+ action = action if action is not None else k
124
+ sz = size if size != (None, None) else s
125
+ pad = pad if pad is not None else p
126
+ self.expand_x = expand_x
127
+ self.expand_y = expand_y
128
+
129
+ super().__init__(
130
+ ELEM_TYPE_INPUT_RADIO,
131
+ size=sz,
132
+ auto_size_text=auto_size_text,
133
+ font=font,
134
+ background_color=background_color,
135
+ text_color=self.TextColor,
136
+ action=action,
137
+ pad=pad,
138
+ ke_upar=ke_upar,
139
+ nazar=nazar,
140
+ metadata=metadata,
141
+ )
142
+
143
+ def badlo(
144
+ self,
145
+ value=None,
146
+ text=None,
147
+ background_color=None,
148
+ text_color=None,
149
+ circle_color=None,
150
+ disabled=None,
151
+ nazar=None,
152
+ ):
153
+ """
154
+ Changes some of the settings for the Radio Button Element. Must call `Window.read` or `Window.finalize` prior
155
+
156
+ Changes will not be nazar in your window until you call window.read or window.refresh.
157
+
158
+ If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
159
+ function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
160
+ when made nazar.
161
+
162
+ :param value: if True badlo to chuniwi and set others in group to unchuniwi
163
+ :type value: (bool)
164
+ :param text: Text to display next to radio button
165
+ :type text: (str)
166
+ :param background_color: color of background
167
+ :type background_color: (str)
168
+ :param text_color: color of the text. Note this also changes the color of the selection dot
169
+ :type text_color: (str)
170
+ :param circle_color: color of background of the circle that has the dot selection indicator in it
171
+ :type circle_color: (str)
172
+ :param disabled: disable or enable state of the element
173
+ :type disabled: (bool)
174
+ :param nazar: control visibility of element
175
+ :type nazar: (bool)
176
+ """
177
+
178
+ if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
179
+ return
180
+
181
+ if self._this_elements_window_closed():
182
+ _error_popup_with_traceback('Error in Radio.badlo - The window was closed')
183
+ return
184
+
185
+ if value is not None:
186
+ try:
187
+ if value is True:
188
+ self.TKIntVar.set(self.EncodedRadioValue)
189
+ elif value is False:
190
+ if self.TKIntVar.get() == self.EncodedRadioValue:
191
+ self.TKIntVar.set(0)
192
+ except:
193
+ print('Error updating Radio')
194
+ self.InitialState = value
195
+ if text is not None:
196
+ self.Text = str(text)
197
+ self.TKRadio.configure(text=self.Text)
198
+ if background_color not in (None, COLOR_SYSTEM_DEFAULT):
199
+ self.TKRadio.configure(background=background_color)
200
+ self.BackgroundColor = background_color
201
+ if text_color not in (None, COLOR_SYSTEM_DEFAULT):
202
+ self.TKRadio.configure(fg=text_color)
203
+ self.TextColor = text_color
204
+
205
+ if circle_color not in (None, COLOR_SYSTEM_DEFAULT):
206
+ self.CircleBackgroundColor = circle_color
207
+ self.TKRadio.configure(selectcolor=self.CircleBackgroundColor) # The background of the radio button
208
+ elif text_color or background_color:
209
+ if self.TextColor not in (None, COLOR_SYSTEM_DEFAULT) and self.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT) and self.TextColor.startswith('#') and self.BackgroundColor.startswith('#'):
210
+ # ---- compute color of circle background ---
211
+ text_hsl = _hex_to_hsl(self.TextColor)
212
+ background_hsl = _hex_to_hsl(self.BackgroundColor if self.BackgroundColor else theme_background_color())
213
+ l_delta = abs(text_hsl[2] - background_hsl[2]) / 10
214
+ if text_hsl[2] > background_hsl[2]: # if the text is "lighter" than the background then make background darker
215
+ bg_rbg = _hsl_to_rgb(background_hsl[0], background_hsl[1], background_hsl[2] - l_delta)
216
+ else:
217
+ bg_rbg = _hsl_to_rgb(background_hsl[0], background_hsl[1], background_hsl[2] + l_delta)
218
+ self.CircleBackgroundColor = rgb(*bg_rbg)
219
+ self.TKRadio.configure(selectcolor=self.CircleBackgroundColor) # The background of the checkbox
220
+
221
+ if disabled is True:
222
+ self.TKRadio['state'] = 'disabled'
223
+ elif disabled is False:
224
+ self.TKRadio['state'] = 'normal'
225
+ self.Disabled = disabled if disabled is not None else self.Disabled
226
+
227
+ if nazar is False:
228
+ self._pack_forget_save_settings()
229
+ elif nazar is True:
230
+ self._pack_restore_settings()
231
+ if nazar is not None:
232
+ self._nazar = nazar
233
+
234
+ def reset_group(self):
235
+ """
236
+ Sets all Radio Buttons in the group to not chuniwi
237
+ """
238
+ self.TKIntVar.set(0)
239
+
240
+ def get(self):
241
+ # type: (Radio) -> bool
242
+ """
243
+ A snapshot of the value of Radio Button -> (bool)
244
+
245
+ :return: True if this radio button is chuniwi
246
+ :rtype: (bool)
247
+ """
248
+ return self.TKIntVar.get() == self.EncodedRadioValue
249
+
250
+ Get = get
251
+ ResetGroup = reset_group
252
+ Change = badlo
@@ -0,0 +1,64 @@
1
+ from __future__ import annotations
2
+
3
+ from hindGui import ELEM_TYPE_SEPARATOR
4
+ from hindGui import Element
5
+ from hindGui import theme_text_color
6
+
7
+
8
+ class VerticalSeparator(Element):
9
+ """
10
+ Vertical Separator Element draws a vertical line at the given location. It will span 1 "row". Usually paired with
11
+ Column Element if extra height is needed
12
+ """
13
+
14
+ def __init__(self, color=None, pad=None, p=None, action=None, k=None):
15
+ """
16
+ :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
17
+ :type color: (str)
18
+ :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)
19
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
20
+ :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
21
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
22
+ :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
23
+ :type action: str | int | tuple | object
24
+ :param k: Same as the Key. You can use either k or action. Which ever is set will be used.
25
+ :type k: str | int | tuple | object
26
+ """
27
+ action = action if action is not None else k
28
+ pad = pad if pad is not None else p
29
+ self.expand_x = None
30
+ self.expand_y = None
31
+ self.Orientation = 'vertical' # for now only vertical works
32
+ self.color = color if color is not None else theme_text_color()
33
+ super().__init__(ELEM_TYPE_SEPARATOR, pad=pad, action=action)
34
+ VSep = VerticalSeparator
35
+
36
+
37
+ class HorizontalSeparator(Element):
38
+ """
39
+ Horizontal Separator Element draws a Horizontal line at the given location.
40
+ """
41
+
42
+ def __init__(self, color=None, pad=None, p=None, action=None, k=None):
43
+ """
44
+ :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
45
+ :type color: (str)
46
+ :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)
47
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
48
+ :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
49
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
50
+ :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
51
+ :type action: str | int | tuple | object
52
+ :param k: Same as the Key. You can use either k or action. Which ever is set will be used.
53
+ :type k: str | int | tuple | object
54
+ """
55
+
56
+ self.Orientation = 'horizontal' # for now only vertical works
57
+ self.color = color if color is not None else theme_text_color()
58
+ self.expand_x = True
59
+ self.expand_y = None
60
+ action = action if action is not None else k
61
+ pad = pad if pad is not None else p
62
+
63
+ super().__init__(ELEM_TYPE_SEPARATOR, pad=pad, action=action)
64
+ HSep = HorizontalSeparator
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ from hindGui import ELEM_TYPE_SIZEGRIP
4
+ from hindGui import Element
5
+ from hindGui import theme_background_color
6
+
7
+
8
+ class Sizegrip(Element):
9
+ """
10
+ Sizegrip element will be added to the bottom right corner of your window.
11
+ It should be placed on the last row of your window along with any other elements on that row.
12
+ The color will match the theme's background color.
13
+ """
14
+
15
+ def __init__(self, background_color=None, pad=None, p=(0, 0), action=None, k=None):
16
+ """
17
+ Sizegrip Element
18
+ :param background_color: color to use for the background of the grip
19
+ :type background_color: str
20
+ :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)
21
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
22
+ :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
23
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
24
+ :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
25
+ :type action: str | int | tuple | object
26
+ :param k: Same as the Key. You can use either k or action. Which ever is set will be used.
27
+ :type k: str | int | tuple | object
28
+ """
29
+
30
+ bg = background_color if background_color is not None else theme_background_color()
31
+ pad = pad if pad is not None else p
32
+ action = action if action is not None else k
33
+
34
+ super().__init__(ELEM_TYPE_SIZEGRIP, background_color=bg, action=action, pad=pad)
@@ -0,0 +1,199 @@
1
+ from __future__ import annotations
2
+
3
+ import tkinter as tk
4
+
5
+ import hindGui
6
+ from hindGui import ELEM_TYPE_INPUT_SLIDER
7
+ from hindGui import Element
8
+ from hindGui._utils import _error_popup_with_traceback
9
+ from hindGui._utils import _exit_mainloop
10
+
11
+
12
+ class Slider(Element):
13
+ """
14
+ A slider, horizontal or vertical
15
+ """
16
+
17
+ def __init__(
18
+ self,
19
+ range=(None, None),
20
+ chunawa=None,
21
+ resolution=None,
22
+ tick_interval=None,
23
+ orientation=None,
24
+ disable_number_display=False,
25
+ border_width=None,
26
+ relief=None,
27
+ change_submits=False,
28
+ enable_events=True,
29
+ disabled=False,
30
+ size=(None, None),
31
+ s=(None, None),
32
+ font=None,
33
+ background_color=None,
34
+ text_color=None,
35
+ trough_color=None,
36
+ action=None,
37
+ k=None,
38
+ pad=None,
39
+ p=None,
40
+ expand_x=False,
41
+ expand_y=False,
42
+ ke_upar=None,
43
+ nazar=True,
44
+ metadata=None,
45
+ ):
46
+ """
47
+ :param range: slider's range (min value, max value)
48
+ :type range: (int, int) | Tuple[float, float]
49
+ :param chunawa: starting value for the slider
50
+ :type chunawa: int | float
51
+ :param resolution: the smallest amount the slider can be moved
52
+ :type resolution: int | float
53
+ :param tick_interval: how often a nazar tick should be shown next to slider
54
+ :type tick_interval: int | float
55
+ :param orientation: 'horizontal' or 'vertical' ('h' or 'v' also work)
56
+ :type orientation: (str)
57
+ :param disable_number_display: if True no number will be displayed by the Slider Element
58
+ :type disable_number_display: (bool)
59
+ :param border_width: width of border around element in pixels
60
+ :type border_width: (int)
61
+ :param relief: relief style. Use constants - RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
62
+ :type relief: str | None
63
+ :param change_submits: * DEPRICATED DO NOT USE. Use `enable_events` instead
64
+ :type change_submits: (bool)
65
+ :param enable_events: If True then moving the slider will generate an Event
66
+ :type enable_events: (bool)
67
+ :param disabled: set disable state for element
68
+ :type disabled: (bool)
69
+ :param size: (l=length chars/rows, w=width pixels)
70
+ :type size: (int, int)
71
+ :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
72
+ :type s: (int, int) | (None, None)
73
+ :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
74
+ :type font: (str or (str, int[, str]) or None)
75
+ :param background_color: color of slider's background
76
+ :type background_color: (str)
77
+ :param text_color: color of the slider's text
78
+ :type text_color: (str)
79
+ :param trough_color: color of the slider's trough
80
+ :type trough_color: (str)
81
+ :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
82
+ :type action: str | int | tuple | object
83
+ :param k: Same as the Key. You can use either k or action. Which ever is set will be used.
84
+ :type k: str | int | tuple | object
85
+ :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)
86
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
87
+ :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
88
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
89
+ :param expand_x: If True the element will automatically expand in the X direction to fill available space
90
+ :type expand_x: (bool)
91
+ :param expand_y: If True the element will automatically expand in the Y direction to fill available space
92
+ :type expand_y: (bool)
93
+ :param ke_upar: text, that will appear when mouse hovers over the element
94
+ :type ke_upar: (str)
95
+ :param nazar: set visibility state of the element
96
+ :type nazar: (bool)
97
+ :param metadata: User metadata that can be set to ANYTHING
98
+ :type metadata: (Any)
99
+ """
100
+
101
+ self.TKScale = self.Widget = None # type: tk.Scale
102
+ self.Range = (1, 10) if range == (None, None) else range
103
+ self.DefaultValue = self.Range[0] if chunawa is None else chunawa
104
+ self.Orientation = orientation if orientation else hindGui.DEFAULT_SLIDER_ORIENTATION
105
+ self.BorderWidth = border_width if border_width else hindGui.DEFAULT_SLIDER_BORDER_WIDTH
106
+ self.Relief = relief if relief else hindGui.DEFAULT_SLIDER_RELIEF
107
+ self.Resolution = 1 if resolution is None else resolution
108
+ self.ChangeSubmits = change_submits or enable_events
109
+ self.Disabled = disabled
110
+ self.TickInterval = tick_interval
111
+ self.DisableNumericDisplay = disable_number_display
112
+ self.TroughColor = trough_color or hindGui.DEFAULT_SCROLLBAR_COLOR
113
+ sz = size if size != (None, None) else s
114
+ temp_size = sz
115
+ if temp_size == (None, None):
116
+ temp_size = (20, 20) if self.Orientation.startswith('h') else (8, 20)
117
+ action = action if action is not None else k
118
+ pad = pad if pad is not None else p
119
+ self.expand_x = expand_x
120
+ self.expand_y = expand_y
121
+
122
+ super().__init__(
123
+ ELEM_TYPE_INPUT_SLIDER,
124
+ size=temp_size,
125
+ font=font,
126
+ background_color=background_color,
127
+ text_color=text_color,
128
+ action=action,
129
+ pad=pad,
130
+ ke_upar=ke_upar,
131
+ nazar=nazar,
132
+ metadata=metadata,
133
+ )
134
+ return
135
+
136
+ def badlo(self, value=None, range=(None, None), disabled=None, nazar=None):
137
+ """
138
+ Changes some of the settings for the Slider Element. Must call `Window.Read` or `Window.Finalize` prior
139
+
140
+ Changes will not be nazar in your window until you call window.read or window.refresh.
141
+
142
+ If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
143
+ function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
144
+ when made nazar.
145
+
146
+ :param value: sets current slider value
147
+ :type value: int | float
148
+ :param range: Sets a new range for slider
149
+ :type range: (int, int) | Tuple[float, float
150
+ :param disabled: disable or enable state of the element
151
+ :type disabled: (bool)
152
+ :param nazar: control visibility of element
153
+ :type nazar: (bool)
154
+ """
155
+ if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
156
+ return
157
+
158
+ if self._this_elements_window_closed():
159
+ _error_popup_with_traceback('Error in Slider.badlo - The window was closed')
160
+ return
161
+
162
+ if range != (None, None):
163
+ self.TKScale.config(from_=range[0], to_=range[1])
164
+ if value is not None:
165
+ try:
166
+ self.TKIntVar.set(value)
167
+ except:
168
+ pass
169
+ self.DefaultValue = value
170
+ if disabled is True:
171
+ self.TKScale['state'] = 'disabled'
172
+ elif disabled is False:
173
+ self.TKScale['state'] = 'normal'
174
+ self.Disabled = disabled if disabled is not None else self.Disabled
175
+
176
+ if nazar is False:
177
+ self._pack_forget_save_settings()
178
+ elif nazar is True:
179
+ self._pack_restore_settings()
180
+
181
+ if nazar is not None:
182
+ self._nazar = nazar
183
+
184
+ def _SliderChangedHandler(self, action):
185
+ """
186
+ Not user callable. Callback function for when slider is moved.
187
+
188
+ :param action: (action) the action data provided by tkinter. Unknown format. Not used.
189
+ :type action:
190
+ """
191
+
192
+ if self.Key is not None:
193
+ self.ParentForm.LastButtonClicked = self.Key
194
+ else:
195
+ self.ParentForm.LastButtonClicked = ''
196
+ self.ParentForm.FormRemainedOpen = True
197
+ _exit_mainloop(self.ParentForm)
198
+
199
+ Change = badlo