From b4608f8449805aa794fe31659b07845bcd6d9c42 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 25 Dec 2018 15:31:13 -0500 Subject: [PATCH 1/2] Moved PySimpleGUIWx.py location --- .../PySimpleGUIWx.py | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) rename PySimpleGUIWx.py => PySimpleGUIWx/PySimpleGUIWx.py (99%) diff --git a/PySimpleGUIWx.py b/PySimpleGUIWx/PySimpleGUIWx.py similarity index 99% rename from PySimpleGUIWx.py rename to PySimpleGUIWx/PySimpleGUIWx.py index 51de881b..8845198d 100644 --- a/PySimpleGUIWx.py +++ b/PySimpleGUIWx/PySimpleGUIWx.py @@ -2527,7 +2527,7 @@ class SystemTray: self.App = wx.App(False) frame = wx.Frame(None, title='Tray icon frame') - self.TaskBarIcon = SystemTray.CustomTaskBarIcon(frame, self.App, self.Menu, filename=self.Filename, tooltip=tooltip) + self.TaskBarIcon = SystemTray.CustomTaskBarIcon(frame, self.App, self.Menu, filename=self.Filename, data_base64=data_base64, tooltip=tooltip) # self.App.MainLoop() @@ -2540,20 +2540,21 @@ class SystemTray: self.menu_item_chosen = None self.menu = menu self.id_to_text = {} + self.filename = filename + self.data_base64 = data_base64 + self.tooltip = tooltip or wx.EmptyString + if filename: - icon = wx.Icon(filename, wx.BITMAP_TYPE_ICO) - if tooltip is not None: - self.SetIcon(icon, tooltip=tooltip) - else: - self.SetIcon(icon) + self.icon = wx.Icon(filename, wx.BITMAP_TYPE_ICO) + self.SetIcon(self.icon, tooltip=self.tooltip) elif data_base64: ico1 = base64.b64decode(data_base64) fout = open("zzztemp_icon.ico", "wb") fout.write(ico1) fout.close() - icon = wx.Icon('zzztemp_icon.ico', wx.BITMAP_TYPE_ICO) - self.TrayIcon.SetIcon(icon, tooltip=tooltip) - # os.remove("zzztemp_icon.ico") + self.icon = wx.Icon('zzztemp_icon.ico', wx.BITMAP_TYPE_ICO) + self.SetIcon(self.icon, tooltip=self.tooltip) + os.remove("zzztemp_icon.ico") self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick) self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarLeftDoubleClick) self.Bind(wx.adv.EVT_TASKBAR_RIGHT_DOWN, self.OnTaskBarRightClick) @@ -2657,11 +2658,11 @@ class SystemTray: def Hide(self): - self.TrayIcon.hide() + self.TaskBarIcon.RemoveIcon() def UnHide(self): - self.TrayIcon.show() + self.TaskBarIcon.SetIcon(icon=self.TaskBarIcon.icon, tooltip=self.TaskBarIcon.tooltip) def ShowMessage(self, title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000): @@ -5053,7 +5054,12 @@ def StartupTK(window): frame.Bind(wx.EVT_CLOSE, window.OnClose) - frame.SetIcon(wx.Icon(window.WindowIcon)) + try: + with open(window.WindowIcon, 'r') as icon_file: + pass + frame.SetIcon(wx.Icon(window.WindowIcon)) + except: + pass if window.BackgroundColor is not None and window.BackgroundColor != COLOR_SYSTEM_DEFAULT: panel.SetBackgroundColour(window.BackgroundColor) From cc2d7afc1b6762c38007cfa54169192996cecc98 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 25 Dec 2018 15:31:44 -0500 Subject: [PATCH 2/2] removed f-strings, included .ico files --- DemoPrograms/Demo_Base64_Image_Encoder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DemoPrograms/Demo_Base64_Image_Encoder.py b/DemoPrograms/Demo_Base64_Image_Encoder.py index 96fd4517..ad6705f3 100644 --- a/DemoPrograms/Demo_Base64_Image_Encoder.py +++ b/DemoPrograms/Demo_Base64_Image_Encoder.py @@ -19,7 +19,7 @@ def main(): sg.PopupCancel('Cancelled - No valid folder entered') return try: - namesonly = [f for f in os.listdir(folder) if f.endswith('.png')] + namesonly = [f for f in os.listdir(folder) if f.endswith('.png') or f.endswith('.ico')] except: sg.PopupCancel('Cancelled - No valid folder entered') return @@ -29,11 +29,11 @@ def main(): for i, file in enumerate(namesonly): contents = open(os.path.join(folder, file), 'rb').read() encoded = base64.b64encode(contents) - outfile.write(f'{file[:file.index(".")]} = {encoded}\n') + outfile.write('\n{} = {}\n\n'.format(file[:file.index(".")], encoded)) sg.OneLineProgressMeter('Base64 Encoding', i+1, len(namesonly),key='_METER_') outfile.close() - sg.Popup('Completed!', 'Encoded %s files'% i) + sg.Popup('Completed!', 'Encoded %s files'%(i+1)) if __name__ == '__main__':