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,413 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tkinter.font
|
|
4
|
+
|
|
5
|
+
import hindGui
|
|
6
|
+
from hindGui import _get_hidden_master_root
|
|
7
|
+
from hindGui import COLOR_SYSTEM_DEFAULT
|
|
8
|
+
from hindGui import ELEM_TYPE_TEXT
|
|
9
|
+
from hindGui._utils import _error_popup_with_traceback
|
|
10
|
+
from hindGui.elements.base import Element
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Text(Element):
|
|
14
|
+
"""
|
|
15
|
+
Text - Display some text in the window. Usually this means a single line of text. However, the text can also be multiple lines. If multi-lined there are no scroll bars.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
text='',
|
|
21
|
+
size=(None, None),
|
|
22
|
+
s=(None, None),
|
|
23
|
+
auto_size_text=None,
|
|
24
|
+
click_submits=False,
|
|
25
|
+
enable_events=True,
|
|
26
|
+
relief=None,
|
|
27
|
+
font=None,
|
|
28
|
+
text_color=None,
|
|
29
|
+
background_color=None,
|
|
30
|
+
border_width=None,
|
|
31
|
+
justification=None,
|
|
32
|
+
pad=None,
|
|
33
|
+
p=None,
|
|
34
|
+
action=None,
|
|
35
|
+
k=None,
|
|
36
|
+
right_click_menu=None,
|
|
37
|
+
expand_x=False,
|
|
38
|
+
expand_y=False,
|
|
39
|
+
grab=None,
|
|
40
|
+
ke_upar=None,
|
|
41
|
+
nazar=True,
|
|
42
|
+
metadata=None,
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
:param text: The text to display. Can include /n to achieve multiple lines. Will convert (optional) parameter into a string
|
|
46
|
+
:type text: Any
|
|
47
|
+
: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
|
|
48
|
+
:type size: (int, int) | (int, None) | (None, None) | (int, ) | int
|
|
49
|
+
: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
|
|
50
|
+
:type s: (int, int) | (int, None) | (None, None) | (int, ) | int
|
|
51
|
+
:param auto_size_text: if True size of the Text Element will be sized to fit the string provided in 'text' parm
|
|
52
|
+
:type auto_size_text: (bool)
|
|
53
|
+
:param click_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead
|
|
54
|
+
:type click_submits: (bool)
|
|
55
|
+
:param enable_events: Turns on the element specific events. Text events happen when the text is clicked
|
|
56
|
+
:type enable_events: (bool)
|
|
57
|
+
:param relief: relief style around the text. Values are same as progress meter relief values. Should be a constant that is defined at starting with RELIEF - RELIEF_RAISED, RELIEF_SUNKEN, RELIEF_FLAT, RELIEF_RIDGE, RELIEF_GROOVE, RELIEF_SOLID
|
|
58
|
+
:type relief: (str)
|
|
59
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
|
|
60
|
+
:type font: (str or (str, int[, str]) or None)
|
|
61
|
+
:param text_color: color of the text
|
|
62
|
+
:type text_color: (str)
|
|
63
|
+
:param background_color: color of background
|
|
64
|
+
:type background_color: (str)
|
|
65
|
+
:param border_width: number of pixels for the border (if using a relief)
|
|
66
|
+
:type border_width: (int)
|
|
67
|
+
:param justification: how string should be aligned within space provided by size. Valid choices = `left`, `right`, `center`
|
|
68
|
+
:type justification: (str)
|
|
69
|
+
: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)
|
|
70
|
+
:type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
71
|
+
: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
|
|
72
|
+
:type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
|
|
73
|
+
:param action: Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
|
|
74
|
+
:type action: str or int or tuple or object
|
|
75
|
+
:param k: Same as the Event. You can use either k or action. Which ever is set will be used.
|
|
76
|
+
:type k: str | int | tuple | object
|
|
77
|
+
: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.
|
|
78
|
+
:type right_click_menu: List[List[ List[str] | str ]]
|
|
79
|
+
:param expand_x: If True the element will automatically expand in the X direction to fill available space
|
|
80
|
+
:type expand_x: (bool)
|
|
81
|
+
:param expand_y: If True the element will automatically expand in the Y direction to fill available space
|
|
82
|
+
:type expand_y: (bool)
|
|
83
|
+
:param grab: If True can grab this element and move the window around. Default is False
|
|
84
|
+
:type grab: (bool)
|
|
85
|
+
:param ke_upar: text, that will appear when mouse hovers over the element
|
|
86
|
+
:type ke_upar: (str)
|
|
87
|
+
:param nazar: set visibility state of the element
|
|
88
|
+
:type nazar: (bool)
|
|
89
|
+
:param metadata: User metadata that can be set to ANYTHING
|
|
90
|
+
:type metadata: (Any)
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
self.DisplayText = str(text)
|
|
94
|
+
self.TextColor = text_color if text_color else hindGui.DEFAULT_TEXT_COLOR
|
|
95
|
+
self.Justification = justification
|
|
96
|
+
self.Relief = relief
|
|
97
|
+
self.ClickSubmits = click_submits or enable_events
|
|
98
|
+
if background_color is None:
|
|
99
|
+
bg = hindGui.DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR
|
|
100
|
+
else:
|
|
101
|
+
bg = background_color
|
|
102
|
+
self.RightClickMenu = right_click_menu
|
|
103
|
+
self.TKRightClickMenu = None
|
|
104
|
+
self.BorderWidth = border_width
|
|
105
|
+
self.Grab = grab
|
|
106
|
+
action = action if action is not None else k
|
|
107
|
+
sz = size if size != (None, None) else s
|
|
108
|
+
pad = pad if pad is not None else p
|
|
109
|
+
self.expand_x = expand_x
|
|
110
|
+
self.expand_y = expand_y
|
|
111
|
+
|
|
112
|
+
super().__init__(
|
|
113
|
+
ELEM_TYPE_TEXT,
|
|
114
|
+
auto_size_text=auto_size_text,
|
|
115
|
+
size=sz,
|
|
116
|
+
background_color=bg,
|
|
117
|
+
font=font if font else hindGui.DEFAULT_FONT,
|
|
118
|
+
text_color=self.TextColor,
|
|
119
|
+
pad=pad,
|
|
120
|
+
action=action,
|
|
121
|
+
ke_upar=ke_upar,
|
|
122
|
+
nazar=nazar,
|
|
123
|
+
metadata=metadata,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def badlo(self, value=None, background_color=None, text_color=None, font=None, nazar=None):
|
|
127
|
+
"""
|
|
128
|
+
Changes some of the settings for the Text Element. Must call `Window.Read` or `Window.Finalize` prior
|
|
129
|
+
|
|
130
|
+
Changes will not be nazar in your window until you call window.read or window.refresh.
|
|
131
|
+
|
|
132
|
+
If you badlo visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
|
|
133
|
+
function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
|
|
134
|
+
when made nazar.
|
|
135
|
+
|
|
136
|
+
:param value: new text to show
|
|
137
|
+
:type value: (Any)
|
|
138
|
+
:param background_color: color of background
|
|
139
|
+
:type background_color: (str)
|
|
140
|
+
:param text_color: color of the text
|
|
141
|
+
:type text_color: (str)
|
|
142
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
|
|
143
|
+
:type font: (str or (str, int[, str]) or None)
|
|
144
|
+
:param nazar: set visibility state of the element
|
|
145
|
+
:type nazar: (bool)
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
|
149
|
+
return
|
|
150
|
+
|
|
151
|
+
if self._this_elements_window_closed():
|
|
152
|
+
_error_popup_with_traceback('Error in Text.badlo - The window was closed')
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
if value is not None:
|
|
156
|
+
self.DisplayText = str(value)
|
|
157
|
+
self.TKStringVar.set(str(value))
|
|
158
|
+
if background_color not in (None, COLOR_SYSTEM_DEFAULT):
|
|
159
|
+
self.TKText.configure(background=background_color)
|
|
160
|
+
if text_color not in (None, COLOR_SYSTEM_DEFAULT):
|
|
161
|
+
self.TKText.configure(fg=text_color)
|
|
162
|
+
if font is not None:
|
|
163
|
+
self.TKText.configure(font=font)
|
|
164
|
+
if nazar is False:
|
|
165
|
+
self._pack_forget_save_settings()
|
|
166
|
+
elif nazar is True:
|
|
167
|
+
self._pack_restore_settings()
|
|
168
|
+
if nazar is not None:
|
|
169
|
+
self._nazar = nazar
|
|
170
|
+
|
|
171
|
+
def get(self):
|
|
172
|
+
"""
|
|
173
|
+
Gets the current value of the displayed text
|
|
174
|
+
|
|
175
|
+
:return: The current value
|
|
176
|
+
:rtype: (str)
|
|
177
|
+
"""
|
|
178
|
+
try:
|
|
179
|
+
text = self.TKStringVar.get()
|
|
180
|
+
except:
|
|
181
|
+
text = ''
|
|
182
|
+
return text
|
|
183
|
+
|
|
184
|
+
@classmethod
|
|
185
|
+
def fonts_installed_list(cls):
|
|
186
|
+
"""
|
|
187
|
+
Returns a list of strings that tkinter reports as the installed fonts
|
|
188
|
+
|
|
189
|
+
:return: List of the installed font names
|
|
190
|
+
:rtype: List[str]
|
|
191
|
+
"""
|
|
192
|
+
# A window must exist before can perform this operation. Create the hidden master root if it doesn't exist
|
|
193
|
+
_get_hidden_master_root()
|
|
194
|
+
|
|
195
|
+
fonts = list(tkinter.font.families())
|
|
196
|
+
fonts.sort()
|
|
197
|
+
|
|
198
|
+
return fonts
|
|
199
|
+
|
|
200
|
+
@classmethod
|
|
201
|
+
def char_width_in_pixels(cls, font, character='W'):
|
|
202
|
+
"""
|
|
203
|
+
Get the with of the character "W" in pixels for the font being passed in or
|
|
204
|
+
the character of your choosing if "W" is not a good representative character.
|
|
205
|
+
Cannot be used until a window has been created.
|
|
206
|
+
If an error occurs, 0 will be returned
|
|
207
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike, to be measured
|
|
208
|
+
:type font: (str or (str, int[, str]) or None)
|
|
209
|
+
:param character: specifies a SINGLE CHARACTER character to measure
|
|
210
|
+
:type character: (str)
|
|
211
|
+
:return: Width in pixels of "A"
|
|
212
|
+
:rtype: (int)
|
|
213
|
+
"""
|
|
214
|
+
# A window must exist before can perform this operation. Create the hidden master root if it doesn't exist
|
|
215
|
+
_get_hidden_master_root()
|
|
216
|
+
|
|
217
|
+
size = 0
|
|
218
|
+
try:
|
|
219
|
+
size = tkinter.font.Font(font=font).measure(character) # single character width
|
|
220
|
+
except Exception as e:
|
|
221
|
+
_error_popup_with_traceback('Exception retrieving char width in pixels', e)
|
|
222
|
+
|
|
223
|
+
return size
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
def char_height_in_pixels(cls, font):
|
|
227
|
+
"""
|
|
228
|
+
Get the height of a string if using the supplied font in pixels.
|
|
229
|
+
Cannot be used until a window has been created.
|
|
230
|
+
If an error occurs, 0 will be returned
|
|
231
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike, to be measured
|
|
232
|
+
:type font: (str or (str, int[, str]) or None)
|
|
233
|
+
:return: Height in pixels of "A"
|
|
234
|
+
:rtype: (int)
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
# A window must exist before can perform this operation. Create the hidden master root if it doesn't exist
|
|
238
|
+
_get_hidden_master_root()
|
|
239
|
+
|
|
240
|
+
size = 0
|
|
241
|
+
try:
|
|
242
|
+
size = tkinter.font.Font(font=font).metrics('linespace')
|
|
243
|
+
except Exception as e:
|
|
244
|
+
_error_popup_with_traceback('Exception retrieving char height in pixels', e)
|
|
245
|
+
|
|
246
|
+
return size
|
|
247
|
+
|
|
248
|
+
@classmethod
|
|
249
|
+
def string_width_in_pixels(cls, font, string):
|
|
250
|
+
"""
|
|
251
|
+
Get the with of the supplied string in pixels for the font being passed in.
|
|
252
|
+
If an error occurs, 0 will be returned
|
|
253
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike, to be measured
|
|
254
|
+
:type font: (str or (str, int[, str]) or None)
|
|
255
|
+
:param string: the string to measure
|
|
256
|
+
:type string: str
|
|
257
|
+
:return: Width in pixels of string
|
|
258
|
+
:rtype: (int)
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
# A window must exist before can perform this operation. Create the hidden master root if it doesn't exist
|
|
262
|
+
_get_hidden_master_root()
|
|
263
|
+
|
|
264
|
+
size = 0
|
|
265
|
+
try:
|
|
266
|
+
size = tkinter.font.Font(font=font).measure(string) # string's width
|
|
267
|
+
except Exception as e:
|
|
268
|
+
_error_popup_with_traceback('Exception retrieving string width in pixels', e)
|
|
269
|
+
|
|
270
|
+
return size
|
|
271
|
+
|
|
272
|
+
def _print_to_element(
|
|
273
|
+
self,
|
|
274
|
+
*args,
|
|
275
|
+
end=None,
|
|
276
|
+
sep=None,
|
|
277
|
+
text_color=None,
|
|
278
|
+
background_color=None,
|
|
279
|
+
autoscroll=None,
|
|
280
|
+
justification=None,
|
|
281
|
+
font=None,
|
|
282
|
+
append=None,
|
|
283
|
+
):
|
|
284
|
+
"""
|
|
285
|
+
Print like Python normally prints except route the output to a multiline element and also add colors if desired
|
|
286
|
+
|
|
287
|
+
:param multiline_element: The multiline element to be output to
|
|
288
|
+
:type multiline_element: (Multiline)
|
|
289
|
+
:param args: The arguments to print
|
|
290
|
+
:type args: List[Any]
|
|
291
|
+
:param end: The end char to use just like print uses
|
|
292
|
+
:type end: (str)
|
|
293
|
+
:param sep: The separation character like print uses
|
|
294
|
+
:type sep: (str)
|
|
295
|
+
:param text_color: color of the text
|
|
296
|
+
:type text_color: (str)
|
|
297
|
+
:param background_color: The background color of the line
|
|
298
|
+
:type background_color: (str)
|
|
299
|
+
:param autoscroll: If True (the default), the element will scroll to bottom after updating
|
|
300
|
+
:type autoscroll: (bool)
|
|
301
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the value being updated
|
|
302
|
+
:type font: str | (str, int)
|
|
303
|
+
"""
|
|
304
|
+
end_str = str(end) if end is not None else '\n'
|
|
305
|
+
sep_str = str(sep) if sep is not None else ' '
|
|
306
|
+
|
|
307
|
+
outstring = ''
|
|
308
|
+
num_args = len(args)
|
|
309
|
+
for i, arg in enumerate(args):
|
|
310
|
+
outstring += str(arg)
|
|
311
|
+
if i != num_args - 1:
|
|
312
|
+
outstring += sep_str
|
|
313
|
+
outstring += end_str
|
|
314
|
+
if append:
|
|
315
|
+
outstring = self.get() + outstring
|
|
316
|
+
|
|
317
|
+
self.badlo(outstring, text_color=text_color, background_color=background_color, font=font)
|
|
318
|
+
|
|
319
|
+
try: # if the element is set to autorefresh, then refresh the parent window
|
|
320
|
+
if self.AutoRefresh:
|
|
321
|
+
self.ParentForm.refresh()
|
|
322
|
+
except:
|
|
323
|
+
pass
|
|
324
|
+
|
|
325
|
+
def print(
|
|
326
|
+
self,
|
|
327
|
+
*args,
|
|
328
|
+
end=None,
|
|
329
|
+
sep=None,
|
|
330
|
+
text_color=None,
|
|
331
|
+
background_color=None,
|
|
332
|
+
justification=None,
|
|
333
|
+
font=None,
|
|
334
|
+
colors=None,
|
|
335
|
+
t=None,
|
|
336
|
+
b=None,
|
|
337
|
+
c=None,
|
|
338
|
+
autoscroll=True,
|
|
339
|
+
append=True,
|
|
340
|
+
):
|
|
341
|
+
"""
|
|
342
|
+
Print like Python normally prints except route the output to a multiline element and also add colors if desired
|
|
343
|
+
|
|
344
|
+
colors -(str, str) or str. A combined text/background color definition in a single parameter
|
|
345
|
+
|
|
346
|
+
There are also "aliases" for text_color, background_color and colors (t, b, c)
|
|
347
|
+
t - An alias for color of the text (makes for shorter calls)
|
|
348
|
+
b - An alias for the background_color parameter
|
|
349
|
+
c - (str, str) - "shorthand" way of specifying color. (foreground, backgrouned)
|
|
350
|
+
c - str - can also be a string of the format "foreground on background" ("white on red")
|
|
351
|
+
|
|
352
|
+
With the aliases it's possible to write the same print but in more compact ways:
|
|
353
|
+
cprint('This will print white text on red background', c=('white', 'red'))
|
|
354
|
+
cprint('This will print white text on red background', c='white on red')
|
|
355
|
+
cprint('This will print white text on red background', text_color='white', background_color='red')
|
|
356
|
+
cprint('This will print white text on red background', t='white', b='red')
|
|
357
|
+
|
|
358
|
+
:param args: The arguments to print
|
|
359
|
+
:type args: (Any)
|
|
360
|
+
:param end: The end char to use just like print uses
|
|
361
|
+
:type end: (str)
|
|
362
|
+
:param sep: The separation character like print uses
|
|
363
|
+
:type sep: (str)
|
|
364
|
+
:param text_color: The color of the text
|
|
365
|
+
:type text_color: (str)
|
|
366
|
+
:param background_color: The background color of the line
|
|
367
|
+
:type background_color: (str)
|
|
368
|
+
:param justification: text justification. left, right, center. Can use single characters l, r, c. Sets only for this value, not entire element
|
|
369
|
+
:type justification: (str)
|
|
370
|
+
:param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the args being printed
|
|
371
|
+
:type font: (str or (str, int[, str]) or None)
|
|
372
|
+
:param colors: Either a tuple or a string that has both the text and background colors. Or just the text color
|
|
373
|
+
:type colors: (str) or (str, str)
|
|
374
|
+
:param t: Color of the text
|
|
375
|
+
:type t: (str)
|
|
376
|
+
:param b: The background color of the line
|
|
377
|
+
:type b: (str)
|
|
378
|
+
:param c: Either a tuple or a string that has both the text and background colors or just tex color (same as the color parm)
|
|
379
|
+
:type c: (str) or (str, str)
|
|
380
|
+
:param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
|
|
381
|
+
:type autoscroll: (bool)
|
|
382
|
+
"""
|
|
383
|
+
|
|
384
|
+
kw_text_color = text_color or t
|
|
385
|
+
kw_background_color = background_color or b
|
|
386
|
+
dual_color = colors or c
|
|
387
|
+
try:
|
|
388
|
+
if isinstance(dual_color, tuple):
|
|
389
|
+
kw_text_color = dual_color[0]
|
|
390
|
+
kw_background_color = dual_color[1]
|
|
391
|
+
elif isinstance(dual_color, str):
|
|
392
|
+
if ' on ' in dual_color: # if has "on" in the string, then have both text and background
|
|
393
|
+
kw_text_color = dual_color.split(' on ')[0]
|
|
394
|
+
kw_background_color = dual_color.split(' on ')[1]
|
|
395
|
+
else: # if no "on" then assume the color string is just the text color
|
|
396
|
+
kw_text_color = dual_color
|
|
397
|
+
except Exception as e:
|
|
398
|
+
print('* multiline print warning * you messed up with color formatting', e)
|
|
399
|
+
|
|
400
|
+
self._print_to_element(
|
|
401
|
+
*args,
|
|
402
|
+
end=end,
|
|
403
|
+
sep=sep,
|
|
404
|
+
text_color=kw_text_color,
|
|
405
|
+
background_color=kw_background_color,
|
|
406
|
+
justification=justification,
|
|
407
|
+
autoscroll=autoscroll,
|
|
408
|
+
font=font,
|
|
409
|
+
append=append,
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
Get = get
|
|
413
|
+
Change = badlo
|