Skip to content

Commit

Permalink
More exception handling around screen capture
Browse files Browse the repository at this point in the history
  • Loading branch information
PySimpleGUI committed Apr 10, 2022
1 parent 846af28 commit a0e468b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions PySimpleGUI.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3

version = __version__ = "4.59.0.6 Released 5-Apr-2022"
version = __version__ = "4.59.0.7 Released 5-Apr-2022"

_change_log = """
Changelog since 4.59.0 released to PyPI on 5-Apr-2022
Expand Down Expand Up @@ -28,6 +28,8 @@
Fixed the font and sizing of the "Editor Settings" section
4.59.0.6
Added exception handing to the bind methods
4.59.0.7
More exception handling

"""

Expand Down Expand Up @@ -22820,6 +22822,7 @@ def save_window_to_disk(window):
pil_imported = False
pil_import_attempted = True
print('FAILED TO IMPORT PIL!')
return
try:
# Get location of window to save
pos = window.current_location()
Expand All @@ -22837,7 +22840,10 @@ def save_window_to_disk(window):
grab = ImageGrab.grab(bbox=rect)
# Save the grabbed image to disk
except Exception as e:
print(e)
# print(e)
popup_error_with_traceback('Screen capture failure', 'Error happened while trying to save screencapture', e)

return
# return grab


Expand Down Expand Up @@ -23635,7 +23641,7 @@ def main_global_get_screen_snapshot_symcode():
for i in range(4):
keysym = settings.get(json.dumps(('-snapshot keysym-', i)), '')
if keysym:
screenshot_keysym += f"<{keysym}>"
screenshot_keysym += "<{}>".format(keysym)

screenshot_keysym_manual = settings.get('-snapshot keysym manual-', '')

Expand Down Expand Up @@ -23769,7 +23775,7 @@ def main_global_pysimplegui_settings():
for i in range(4):
pysimplegui_user_settings.set(json.dumps(('-snapshot keysym-',i)), values[('-SNAPSHOT KEYSYM-', i)])
if values[('-SNAPSHOT KEYSYM-', i)]:
screenshot_keysym += f"<{values[('-SNAPSHOT KEYSYM-', i)]}>"
screenshot_keysym += "<{}>".format(values[('-SNAPSHOT KEYSYM-', i)])
if screenshot_keysym_manual:
DEFAULT_WINDOW_SNAPSHOT_KEY_CODE = screenshot_keysym_manual
elif screenshot_keysym:
Expand Down
4 changes: 2 additions & 2 deletions PySimpleGUIWx/PySimpleGUIWx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7917,14 +7917,14 @@ def PopupGetText(message, title=None, default_text='', password_char='', size=(N
:return: Text entered or None if window was closed
"""

layout = [[Text(message, auto_size_text=True, text_color=text_color, background_color=background_color, font=font)],
layout = [[Text(message, auto_size_text=True, text_color=text_color, background_color=background_color)],
[InputText(default_text=default_text, size=size, key='_INPUT_', password_char=password_char)],
[CloseButton('Ok', size=(60, 20), bind_return_key=True), CloseButton('Cancel', size=(60, 20))]]

_title = title if title is not None else message

window = Window(title=_title, layout=layout, icon=icon, auto_size_text=True, button_color=button_color, no_titlebar=no_titlebar,
background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, font=font,
location=location)

button, values = window.Read()
Expand Down

0 comments on commit a0e468b

Please sign in to comment.