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
KL_Py/hindGui/_utils.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
import sys
|
|
5
|
+
import traceback
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _create_error_message():
|
|
9
|
+
"""
|
|
10
|
+
Creates an error message containing the filename and line number of the users
|
|
11
|
+
code that made the call into hindGui
|
|
12
|
+
:return: Error string to display with file, line number, and line of code
|
|
13
|
+
:rtype: str
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
called_func = inspect.stack()[1].function
|
|
17
|
+
trace_details = traceback.format_stack()
|
|
18
|
+
error_message = ''
|
|
19
|
+
file_info_pysimplegui = trace_details[-1].split(',')[0]
|
|
20
|
+
for line in reversed(trace_details):
|
|
21
|
+
if line.split(',')[0] != file_info_pysimplegui:
|
|
22
|
+
error_message = line
|
|
23
|
+
break
|
|
24
|
+
if error_message != '':
|
|
25
|
+
error_parts = error_message.split(', ')
|
|
26
|
+
if len(error_parts) < 4:
|
|
27
|
+
error_message = error_parts[0] + '\n' + error_parts[1] + '\n' + ''.join(error_parts[2:])
|
|
28
|
+
return 'The hindGui internal reporting function is ' + called_func + '\n' + 'The error originated from:\n' + error_message
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _error_popup_with_traceback(title, *args, emoji=None):
|
|
32
|
+
if hindGui.SUPPRESS_ERROR_POPUPS:
|
|
33
|
+
return
|
|
34
|
+
trace_details = traceback.format_stack()
|
|
35
|
+
error_message = ''
|
|
36
|
+
file_info_pysimplegui = None
|
|
37
|
+
for line in reversed(trace_details):
|
|
38
|
+
if __file__ not in line:
|
|
39
|
+
file_info_pysimplegui = line.split(',')[0]
|
|
40
|
+
error_message = line
|
|
41
|
+
break
|
|
42
|
+
if file_info_pysimplegui is None:
|
|
43
|
+
_error_popup_with_code(title, None, None, 'Did not find your traceback info', *args, emoji=emoji)
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
error_parts = None
|
|
47
|
+
if error_message != '':
|
|
48
|
+
error_parts = error_message.split(', ')
|
|
49
|
+
if len(error_parts) < 4:
|
|
50
|
+
error_message = error_parts[0] + '\n' + error_parts[1] + '\n' + ''.join(error_parts[2:])
|
|
51
|
+
if error_parts is None:
|
|
52
|
+
print('*** Error popup attempted but unable to parse error details ***')
|
|
53
|
+
print(trace_details)
|
|
54
|
+
return
|
|
55
|
+
filename = error_parts[0][error_parts[0].index('File ') + 5 :]
|
|
56
|
+
line_num = error_parts[1][error_parts[1].index('line ') + 5 :]
|
|
57
|
+
_error_popup_with_code(title, filename, line_num, error_message, *args, emoji=emoji)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _error_popup_with_code(title, filename, line_num, *args, emoji=None):
|
|
61
|
+
"""
|
|
62
|
+
Makes the error popup window
|
|
63
|
+
|
|
64
|
+
:param title: The title that will be shown in the popup's titlebar and in the first line of the window
|
|
65
|
+
:type title: str
|
|
66
|
+
:param filename: The filename to show.. may not be the filename that actually encountered the exception!
|
|
67
|
+
:type filename: str
|
|
68
|
+
:param line_num: Line number within file with the error
|
|
69
|
+
:type line_num: int | str
|
|
70
|
+
:param args: A variable number of lines of messages
|
|
71
|
+
:type args: *Any
|
|
72
|
+
:param emoji: An optional BASE64 Encoded image to shows in the error window
|
|
73
|
+
:type emoji: bytes
|
|
74
|
+
"""
|
|
75
|
+
editor_filename = execute_get_editor()
|
|
76
|
+
emoji_data = emoji if emoji is not None else _random_error_emoji()
|
|
77
|
+
layout = [[Text('ERROR'), Text(title)], [Image(data=emoji_data)]]
|
|
78
|
+
lines = []
|
|
79
|
+
for msg in args:
|
|
80
|
+
if isinstance(msg, Exception):
|
|
81
|
+
lines += [[f'Additional Exception info pased in by PySimpleGUI or user: Error type is: {type(msg).__name__}']]
|
|
82
|
+
lines += [[f'In file {__file__} Line number {msg.__traceback__.tb_lineno}']]
|
|
83
|
+
lines += [[f'{msg}']]
|
|
84
|
+
else:
|
|
85
|
+
lines += [str(msg).split('\n')]
|
|
86
|
+
max_line_len = 0
|
|
87
|
+
for line in lines:
|
|
88
|
+
max_line_len = max(max_line_len, max([len(s) for s in line]))
|
|
89
|
+
|
|
90
|
+
layout += [[Text(''.join(line), size=(min(max_line_len, 90), None))] for line in lines]
|
|
91
|
+
layout += [
|
|
92
|
+
[
|
|
93
|
+
Button('Close'),
|
|
94
|
+
Button('Take me to error', disabled=True if not editor_filename else False),
|
|
95
|
+
Button('Kill Application', button_color='white on red'),
|
|
96
|
+
]
|
|
97
|
+
]
|
|
98
|
+
if not editor_filename:
|
|
99
|
+
layout += [[Text('Configure editor in the Global settings to enable "Take me to error" feature')]]
|
|
100
|
+
window = Window(title, layout, ehem=True)
|
|
101
|
+
|
|
102
|
+
while True:
|
|
103
|
+
action, values = window.parh()
|
|
104
|
+
if action in ('Close', WIN_CLOSED):
|
|
105
|
+
break
|
|
106
|
+
if action == 'Kill Application':
|
|
107
|
+
window.die()
|
|
108
|
+
popup_quick_message(
|
|
109
|
+
'KILLING APP! BYE!',
|
|
110
|
+
font='_ 18',
|
|
111
|
+
ehem=True,
|
|
112
|
+
text_color='white',
|
|
113
|
+
background_color='red',
|
|
114
|
+
non_blocking=False,
|
|
115
|
+
)
|
|
116
|
+
sys.exit()
|
|
117
|
+
if action == 'Take me to error' and filename is not None and line_num is not None:
|
|
118
|
+
execute_editor(filename, line_num)
|
|
119
|
+
|
|
120
|
+
window.die()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _exit_mainloop(exiting_window):
|
|
124
|
+
if exiting_window == Window._window_running_mainloop or Window._root_running_mainloop == Window.hidden_master_root:
|
|
125
|
+
Window._window_that_exited = exiting_window
|
|
126
|
+
if Window._root_running_mainloop is not None:
|
|
127
|
+
Window._root_running_mainloop.quit()
|
|
128
|
+
# print('** Exited window mainloop **')
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
import hindGui
|
|
132
|
+
from hindGui import _random_error_emoji
|
|
133
|
+
from hindGui import execute_editor
|
|
134
|
+
from hindGui import execute_get_editor
|
|
135
|
+
from hindGui import popup_quick_message
|
|
136
|
+
from hindGui import WIN_CLOSED
|
|
137
|
+
from hindGui.elements.button import Button
|
|
138
|
+
from hindGui.elements.image import Image
|
|
139
|
+
from hindGui.elements.text import Text
|
|
140
|
+
from hindGui.window import Window
|