Displays a "notification window", usually in the bottom right corner of your display. Has an icon, a title, and a message. It is more like a "toaster" window than the normal popups. The window will slowly fade in and out if desired. Clicking on the window will cause it to move through t
(*args, title='', icon=SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, display_duration_in_ms=SYSTEM_TRAY_MESSAGE_DISPLAY_DURATION_IN_MILLISECONDS,
fade_in_duration=SYSTEM_TRAY_MESSAGE_FADE_IN_DURATION, alpha=0.9, location=None)
| 21977 | |
| 21978 | # Popup Notify |
| 21979 | def popup_notify(*args, title='', icon=SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, display_duration_in_ms=SYSTEM_TRAY_MESSAGE_DISPLAY_DURATION_IN_MILLISECONDS, |
| 21980 | fade_in_duration=SYSTEM_TRAY_MESSAGE_FADE_IN_DURATION, alpha=0.9, location=None): |
| 21981 | """ |
| 21982 | Displays a "notification window", usually in the bottom right corner of your display. Has an icon, a title, and a message. It is more like a "toaster" window than the normal popups. |
| 21983 | |
| 21984 | The window will slowly fade in and out if desired. Clicking on the window will cause it to move through the end the current "phase". For example, if the window was fading in and it was clicked, then it would immediately stop fading in and instead be fully visible. It's a way for the user to quickly dismiss the window. |
| 21985 | |
| 21986 | The return code specifies why the call is returning (e.g. did the user click the message to dismiss it) |
| 21987 | |
| 21988 | :param title: Text to be shown at the top of the window in a larger font |
| 21989 | :type title: (str) |
| 21990 | :param message: Text message that makes up the majority of the window |
| 21991 | :type message: (str) |
| 21992 | :param icon: A base64 encoded PNG/GIF image or PNG/GIF filename that will be displayed in the window |
| 21993 | :type icon: bytes | str |
| 21994 | :param display_duration_in_ms: Number of milliseconds to show the window |
| 21995 | :type display_duration_in_ms: (int) |
| 21996 | :param fade_in_duration: Number of milliseconds to fade window in and out |
| 21997 | :type fade_in_duration: (int) |
| 21998 | :param alpha: Alpha channel. 0 - invisible 1 - fully visible |
| 21999 | :type alpha: (float) |
| 22000 | :param location: Location on the screen to display the window |
| 22001 | :type location: (int, int) |
| 22002 | :return: reason for returning |
| 22003 | :rtype: (int) |
| 22004 | """ |
| 22005 | |
| 22006 | if not args: |
| 22007 | args_to_print = [''] |
| 22008 | else: |
| 22009 | args_to_print = args |
| 22010 | output = '' |
| 22011 | max_line_total, total_lines, local_line_width = 0, 0, SYSTEM_TRAY_MESSAGE_MAX_LINE_LENGTH |
| 22012 | for message in args_to_print: |
| 22013 | # fancy code to check if string and convert if not is not need. Just always convert to string :-) |
| 22014 | # if not isinstance(message, str): message = str(message) |
| 22015 | message = str(message) |
| 22016 | if message.count('\n'): |
| 22017 | message_wrapped = message |
| 22018 | else: |
| 22019 | message_wrapped = textwrap.fill(message, local_line_width) |
| 22020 | message_wrapped_lines = message_wrapped.count('\n') + 1 |
| 22021 | longest_line_len = max([len(l) for l in message.split('\n')]) |
| 22022 | width_used = min(longest_line_len, local_line_width) |
| 22023 | max_line_total = max(max_line_total, width_used) |
| 22024 | # height = _GetNumLinesNeeded(message, width_used) |
| 22025 | height = message_wrapped_lines |
| 22026 | output += message_wrapped + '\n' |
| 22027 | total_lines += height |
| 22028 | |
| 22029 | message = output |
| 22030 | |
| 22031 | # def __init__(self, menu=None, filename=None, data=None, data_base64=None, tooltip=None, metadata=None): |
| 22032 | return SystemTray.notify(title=title, message=message, icon=icon, display_duration_in_ms=display_duration_in_ms, fade_in_duration=fade_in_duration, |
| 22033 | alpha=alpha, location=location) |
| 22034 | |
| 22035 | |
| 22036 | def popup_menu(window, element, menu_def, title=None, location=(None, None)): |