Merge pull request #3092 from PySimpleGUI/Dev-latest
image parameter added to popup, popup_error. New base64 image constan…
This commit is contained in:
commit
a6619711e3
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
version = __version__ = "4.22.0.7 Unreleased\n Added a bunch of warnings for windows operations to check for root being None, fix for table and tree colors due to tkinter bug in version 8.6.9, don't call overrideredirect if running on Mac, new shortcut parm k added to all elements (use interachgably with key), moved when 8.6.9 patch is applied, any_key_closes parameter added to popup"
|
||||
version = __version__ = "4.22.0.8 Unreleased\n Added a bunch of warnings for windows operations to check for root being None, fix for table and tree colors due to tkinter bug in version 8.6.9, don't call overrideredirect if running on Mac, new shortcut parm k added to all elements (use interachgably with key), moved when 8.6.9 patch is applied, any_key_closes parameter added to popup, image parameter added to popup & popup_error"
|
||||
|
||||
port = 'PySimpleGUI'
|
||||
|
||||
|
@ -246,6 +246,9 @@ DEFAULT_BASE64_LOADING_GIF = b'R0lGODlhQABAAKUAAAQCBJyenERCRNTS1CQiJGRmZLS2tPTy9
|
|||
|
||||
PSG_DEBUGGER_LOGO = b'R0lGODlhMgAtAPcAAAAAADD/2akK/4yz0pSxyZWyy5u3zZ24zpW30pG52J250J+60aC60KS90aDC3a3E163F2K3F2bPI2bvO3rzP3qvJ4LHN4rnR5P/zuf/zuv/0vP/0vsDS38XZ6cnb6f/xw//zwv/yxf/1w//zyP/1yf/2zP/3z//30wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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5uDd6+Pi7eXj8ejl9Ozp9/Lw+wAAAAAAAAAAAAAAAErQjXwAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAHU0lEQVRYR5WWf1gbZx3A8bw2y7nJVq00ZM9Eq63t0o3QFNKkrLbjoRjXsWFHCI+T0gNNe2nWm4Ndm9xFTLmj1UFONsUU1s2aZRRxdP7otNZN1Omc1inTdbad06danzlkVoR2/hG/7w8gNG/Y9iE/uPf9vp/7vt/37r0UZPLx34nxiYmJNybp4VuSxzQ9MXn5zempqelLlybfpotteu31ifFzfzp7/sL45PT09MS/aPOCME1jZ8+fGxs9Njw0fGLswuT01D/+SjsWgmU6fnJs7IUTx7410N8/MDx64eKlqV++DRXD9M2BkZOnfjicTvV0d/f0Hx09f/HNf//iL7QzP7mmn0XN9BMjR9PpfhOpkkdHz0z97+9PT9DuvOSa7gvHus2vYEzT6E4MDP10/PKlM0/T7rzkmoLBeyORWMwwzf6UaZowvydPX7z8nzPP0v585JhO7pIkWZbvVXUzlUomzYNmcui7L49fvPDs6zQiDzmmr9UHg7vDu8MRVTcOHESq5KEjz7z8yitnfkwj8pBr2njHNjEo7ZbliGFAQsk+eB155vTpc6f/RkPY5JiOr7i1uh5UYUVROw4ehEolk1193zj2k9+NLpxUbsWXrt5YfdfnpDAUS9UgLaCrq2/g6JETT9IINrmmJStWb9wUCKK6K0h1wDCMDs1IHjr8Tk23F63aeOsdooSXUNU6O7QOTdM7937x0NAbNIRJrumrS4tWb64OiFKrJEshWdnXqWr7QqGO/fuHztIQJrmmzKKiFauc9aLYIkp7xHvkfXtCLSG5Y+TU1w8foRFMGKat7y1asbLaH/CLkNeO5h2trZJk/Oq3I/uHh/9IQ1gwTD+4qnBpkbPK5xf9zTua/c1+fyT1WLLnvi+8MPwoDWHBMEWDjuuFpc5P+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5esJ3UBqLQrAGYHg531CGV5ENtuAEDuSDWVKCMvN5Kb6X7s9R0O8poZvZ4FB0n2MrqGhr8vjLSij5JnYnMDSpIqbLS66amZbOiOSB9PNzmqdtSVVhL2rAcXtCHTeVIVQl4yfQKrs0WoWuNDKLp2dZ5eCvVzkGSmlWRpMCEhtORxIqj8TEBH88ja4IoKfxrqAC2wbmxUG0O7id6NAM+no+9GMuo6hZs+gxZKQQaRTPMFjFMUCuaFlo/Mr2CJkgJReNPfIFfmRM+ZIBVFfhS+BLOCZWb3C7kPofLEkM0CNqQy4zKuwGZ7iTRWIURIPW3mt0MMyo0vYL7s64luCt4Hu6ZeR4EHcgAuaBYcJ0XZPATAC0ampyAJ0fHz0IGZTPXiFTgQiYyJwAnh+pNd4QsZrcjgDYB5Bir7BvAhB5vKCvUZ+F4vMQ4cB54EP0/C2ik9/TDBZmnyG6BGqHuWJR9XvqdD2yCXcq+Dna6JtpIYJ15QWB+5W6v+1P/B0gPXHqaGwimAAAAAElFTkSuQmCC'
|
||||
|
||||
DEFAULT_WINDOW_ICON = DEFAULT_BASE64_ICON
|
||||
|
||||
DEFAULT_ELEMENT_SIZE = (45, 1) # In CHARACTERS
|
||||
|
@ -1003,6 +1006,8 @@ class Element():
|
|||
else:
|
||||
return
|
||||
|
||||
if not self._widget_was_created():
|
||||
return
|
||||
self.Widget.pack(expand=True, fill=fill)
|
||||
self.ParentRowFrame.pack(expand=expand_row, fill=fill)
|
||||
|
||||
|
@ -1032,6 +1037,21 @@ class Element():
|
|||
print(e)
|
||||
|
||||
|
||||
def _widget_was_created(self):
|
||||
"""
|
||||
Determines if a Widget was created for this element.
|
||||
|
||||
:return: True if a Widget has been created previously (Widget is not None)
|
||||
:rtype: (bool)
|
||||
"""
|
||||
if self.Widget is not None:
|
||||
return True
|
||||
else:
|
||||
popup_error('You cannot perform operations on an Element until Window is read or finalized.',
|
||||
'Adding a "finalize=True" parameter to your Window creation will likely fix this.', image=FACE_PALM)
|
||||
return False
|
||||
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
"""
|
||||
Makes it possible to "call" an already existing element. When you do make the "call", it actually calls
|
||||
|
@ -8097,13 +8117,14 @@ class Window:
|
|||
warnings.warn('You cannot perform operations on a Window until it is read or finalized. Adding a "finalize=True" parameter to your Window creation will fix this', UserWarning)
|
||||
popup_error('You cannot perform operations on a Window until it is read or finalized.',
|
||||
'Yea, I know, it\'s a weird thing, but just fix it and keep going.... ',
|
||||
'Adding a "finalize=True" parameter to your Window creation will likely fix this')
|
||||
'Adding a "finalize=True" parameter to your Window creation will likely fix this', image=FACE_PALM)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_row = AddRow
|
||||
add_rows = AddRows
|
||||
alpha_channel = AlphaChannel
|
||||
|
@ -13994,7 +14015,7 @@ def ObjToString(obj, extra=' '):
|
|||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# ----------------------------------- The mighty Popup! ------------------------------------------------------------ #
|
||||
|
||||
def Popup(*args, title=None, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK, auto_close=False, auto_close_duration=None, custom_text=(None, None), non_blocking=False, icon=None, line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None), any_key_closes=False):
|
||||
def Popup(*args, title=None, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK, auto_close=False, auto_close_duration=None, custom_text=(None, None), non_blocking=False, icon=None, line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None), any_key_closes=False, image=None):
|
||||
"""
|
||||
Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
|
||||
"print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
|
||||
|
@ -14035,6 +14056,8 @@ def Popup(*args, title=None, button_color=None, background_color=None, text_colo
|
|||
:type keep_on_top: (bool)
|
||||
:param any_key_closes: If True then will turn on return_keyboard_events for the window which will cause window to close as soon as any key is pressed. Normally the return key only will close the window. Default is false.
|
||||
:type any_key_closes: (bool)
|
||||
:param image: Image to include at the top of the popup window
|
||||
:type image: (str) or (bytes)
|
||||
:return: Returns text of the button that was pressed. None will be returned if user closed window with X
|
||||
:rtype: Union[str, None]
|
||||
"""
|
||||
|
@ -14052,6 +14075,11 @@ def Popup(*args, title=None, button_color=None, background_color=None, text_colo
|
|||
auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font,
|
||||
no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, return_keyboard_events=any_key_closes)
|
||||
max_line_total, total_lines = 0, 0
|
||||
if image is not None:
|
||||
if isinstance(image, str):
|
||||
window.add_row(Image(filename=image))
|
||||
else:
|
||||
window.add_row(Image(data=image))
|
||||
for message in args_to_print:
|
||||
# fancy code to check if string and convert if not is not need. Just always convert to string :-)
|
||||
# if not isinstance(message, str): message = str(message)
|
||||
|
@ -14528,7 +14556,7 @@ PopupTimed = PopupAutoClose
|
|||
# --------------------------- PopupError ---------------------------
|
||||
def PopupError(*args, title=None, button_color=(None, None), background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None), image=None):
|
||||
"""
|
||||
Popup with colored button and 'Error' as button text
|
||||
|
||||
|
@ -14562,6 +14590,8 @@ def PopupError(*args, title=None, button_color=(None, None), background_color=No
|
|||
:type keep_on_top: (bool)
|
||||
:param location: Location of upper left corner of the window
|
||||
:type location: Tuple[int, int]
|
||||
:param image: Image to include at the top of the popup window
|
||||
:type image: (str) or (bytes)
|
||||
:return: Returns text of the button that was pressed. None will be returned if user closed window with X
|
||||
:rtype: Union[str, None, TIMEOUT_KEY]
|
||||
"""
|
||||
|
@ -14570,7 +14600,7 @@ def PopupError(*args, title=None, button_color=(None, None), background_color=No
|
|||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=tbutton_color,
|
||||
auto_close=auto_close,
|
||||
auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
|
||||
keep_on_top=keep_on_top, location=location)
|
||||
keep_on_top=keep_on_top, location=location, image=image)
|
||||
|
||||
|
||||
# --------------------------- PopupCancel ---------------------------
|
||||
|
|
Loading…
Reference in New Issue