Skip to content

Commit 5cb8fe1

Browse files
committed
Enable SetGlobalIcon to be a base64 byte string in addition to a filename. Fixed window icon logic to choose correct default
1 parent 91fe043 commit 5cb8fe1

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

PySimpleGUI.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5160,7 +5160,12 @@ def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE
51605160
self.Font = font if font else DEFAULT_FONT
51615161
self.RadioDict = {}
51625162
self.BorderDepth = border_depth
5163-
self.WindowIcon = Window.user_defined_icon if Window.user_defined_icon is not None else icon if icon is not None else DEFAULT_WINDOW_ICON
5163+
if icon:
5164+
self.WindowIcon = icon
5165+
elif Window.user_defined_icon is not None:
5166+
self.WindowIcon = Window.user_defined_icon
5167+
else:
5168+
self.WindowIcon = DEFAULT_WINDOW_ICON
51645169
self.AutoClose = auto_close
51655170
self.NonBlocking = False
51665171
self.TKroot = None
@@ -9385,20 +9390,13 @@ def EasyPrintClose():
93859390
# ===================================================#
93869391
def SetGlobalIcon(icon):
93879392
"""
9393+
Sets the icon which will be used any time a window is created if an icon is not provided when the
9394+
window is created.
93889395

9389-
:param icon:
9390-
9396+
:param icon: Union[bytes, str] Either a Base64 byte string or a filename
93919397
"""
9392-
# global _my_windows
93939398

9394-
try:
9395-
with open(icon, 'r') as icon_file:
9396-
pass
9397-
except:
9398-
raise FileNotFoundError
9399-
# _my_windows.user_defined_icon = icon
94009399
Window.user_defined_icon = icon
9401-
return True
94029400

94039401

94049402
# ============================== SetOptions =========#

0 commit comments

Comments
 (0)