How to use the pystray.Icon function in pystray

To help you get started, we’ve selected a few pystray examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github typeworld / guiapp / wxPython / daemon_2.py View on Github external
image = win32.LoadImage(
					None,
					os.path.join(os.path.dirname(__file__), 'icon', 'TaskbarIcon.ico'),
					win32.IMAGE_ICON,
					0,
					0,
					win32.LR_DEFAULTSIZE | win32.LR_LOADFROMFILE)
			image_notification = win32.LoadImage(
					None,
					os.path.join(os.path.dirname(__file__), 'icon', 'TaskbarIcon_Notification.ico'),
					win32.IMAGE_ICON,
					0,
					0,
					win32.LR_DEFAULTSIZE | win32.LR_LOADFROMFILE)

		icon = pystray.Icon("Type.World", image, "Type.World", menu)


		if MAC:
			class Delegate(NSObject):
				def applicationDidFinishLaunching_(self, aNotification):
					icon.run()

			NSUserNotificationCenterDelegate = objc.protocolNamed('NSUserNotificationCenterDelegate')
			class NotificationDelegate(NSObject, protocols=[NSUserNotificationCenterDelegate]):

				def userNotificationCenter_didActivateNotification_(self, center, aNotification):
					openApp()

			app = NSApplication.sharedApplication()
			delegate = Delegate.alloc().init()
			app.setDelegate_(delegate)
github typeworld / guiapp / wxPython / daemon.py View on Github external
image = win32.LoadImage(
					None,
					os.path.join(os.path.dirname(__file__), 'icon', 'TaskbarIcon.ico'),
					win32.IMAGE_ICON,
					0,
					0,
					win32.LR_DEFAULTSIZE | win32.LR_LOADFROMFILE)
			image_notification = win32.LoadImage(
					None,
					os.path.join(os.path.dirname(__file__), 'icon', 'TaskbarIcon_Notification.ico'),
					win32.IMAGE_ICON,
					0,
					0,
					win32.LR_DEFAULTSIZE | win32.LR_LOADFROMFILE)

		icon = pystray.Icon("Type.World", image, "Type.World", menu)


		if MAC:
			class Delegate(NSObject):
				def applicationDidFinishLaunching_(self, aNotification):
					icon.run()

			NSUserNotificationCenterDelegate = objc.protocolNamed('NSUserNotificationCenterDelegate')
			class NotificationDelegate(NSObject, protocols=[NSUserNotificationCenterDelegate]):

				def userNotificationCenter_didActivateNotification_(self, center, aNotification):
					intercomApp.open()

			nsApp = NSApplication.sharedApplication()
			delegate = Delegate.alloc().init()
			nsApp.setDelegate_(delegate)
github simonlindholm / decomp-permuter / src / server_main.py View on Github external
def run_with_systray(
    server: Server,
    output_queue: "queue.Queue[IoActivity]",
    loop: Callable[[SystrayState], None],
) -> None:
    menu_items: List[pystray.MenuItem] = []

    icon = pystray.Icon(
        name="permuter@home",
        title="permuter@home",
        icon=Image.open(os.path.join(os.path.dirname(__file__), "..", "icon.png")),
        menu=pystray.Menu(lambda: menu_items),
    )

    def update_menu(items: List[pystray.MenuItem], flush: bool) -> None:
        nonlocal menu_items
        menu_items = items
        if flush:
            icon.update_menu()

    systray = RealSystrayState(server, output_queue, update_menu)
    systray.initial_update()

    def inner(icon: pystray.Icon) -> None:
github moses-palmer / virtual-touchpad / lib / virtualtouchpad / trayicon.py View on Github external
def create(configuration):
    """Creates the system tray icon.
    """
    def href(path):
        def inner(*args, **kwargs):
            webbrowser.open(urllib.parse.urljoin(
                configuration.SERVER_URL, path))
        return inner

    def access_token_toggle(*args):
        configuration.ACCESS_TOKEN = (
            None if configuration.ACCESS_TOKEN is not None
            else generate_access_token())

    return pystray.Icon(
        __name__,
        title='Virtual Touchpad - {}'.format(
            configuration.SERVER_URL),
        icon=PIL.Image.open(
            resource.open_stream(
                {
                    'darwin': 'icon-dark.png',
                    'linux': 'icon-light.png',
                    'win32': 'icon-light.png'}[sys.platform])),
        menu=menu(
            item(
                _('Connect mobile device...'),
                href('qr')),
            item(
                _('Require access code to connect'),
                access_token_toggle,
github edouardpoitras / eva / clients / desktop.py View on Github external
menu_item = pystray.MenuItem('Listen', clicked)
    return pystray.Menu(menu_item)

def clicked(icon):
    if icon.menu.items[0].text == 'Listen':
        icon.icon = get_active_icon()
        icon.menu = get_active_menu()
    else:
        icon.icon = get_passive_icon()
        icon.menu = get_passive_menu()

def setup(icon):
    icon.visible = True

if __name__ == '__main__':
    icon = pystray.Icon(name='Eva', icon=get_passive_icon(), title='Eva', menu=get_passive_menu())
    icon.run(setup)
github srevinsaju / guiscrcpy / guiscrcpy / __main__.py View on Github external
"RGBA", (128, 128), (255, 255, 255, 255))
                    # loop this block --->
                    var1 = notif.stdout.readlines()

                    # <----
                    print("LOG: var1: ", var1)
                    if len(var1) > len(var2):
                        d = ImageDraw.Draw(image)
                        d.rectangle([0, 255, 128, 128], fill="green")
                        icon.icon = img
                        time.sleep(600)
                        var2 = var1

            image = Image.new("RGBA", (128, 128), (255, 255, 255, 255))

            icon = pystray.Icon("Test Icon 1", image)

            icon.visible = True
            icon.run(setup=callback)
            # End notif auditor