Show a notification popout window :param title: Title shown in the notification :param message: Message shown in the notification :param icon: Icon shown in the notification - defaults to PySimpleGUI icon. Should be a PNG file :param app_name: Application name shown in the noti
(title=None, message=None, icon=sg.DEFAULT_BASE64_ICON, app_name=None)
| 31 | |
| 32 | |
| 33 | def notify_popout(title=None, message=None, icon=sg.DEFAULT_BASE64_ICON, app_name=None): |
| 34 | """ |
| 35 | Show a notification popout window |
| 36 | |
| 37 | :param title: Title shown in the notification |
| 38 | :param message: Message shown in the notification |
| 39 | :param icon: Icon shown in the notification - defaults to PySimpleGUI icon. Should be a PNG file |
| 40 | :param app_name: Application name shown in the notification |
| 41 | """ |
| 42 | if not hasattr(notify_popout, 'temp_files'): |
| 43 | notify_popout.temp_files = [] |
| 44 | |
| 45 | notification = Notify() |
| 46 | notification.title = title |
| 47 | notification.message = message |
| 48 | tmp = None |
| 49 | if isinstance(icon, bytes): |
| 50 | with tempfile.TemporaryFile(suffix='.png', delete=False) as tmp: |
| 51 | tmp.write(base64.b64decode(icon)) |
| 52 | tmp.close() |
| 53 | notification.icon = tmp.name |
| 54 | elif icon is not None: |
| 55 | notification.icon = icon |
| 56 | if app_name is not None: |
| 57 | notification.application_name = app_name |
| 58 | notification.send(block=False) |
| 59 | if tmp is not None: |
| 60 | notify_popout.temp_files.append(tmp.name) |
| 61 | |
| 62 | |
| 63 | def main(): |