How to use the pystray.MenuItem 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 simonlindholm / decomp-permuter / src / server_main.py View on Github external
for handle, client in self._clients.items():
            fn_names = ", ".join(client.fn_names)
            items.append(
                pystray.MenuItem(
                    f"{fn_names} ({client.nickname})",
                    pystray.Menu(
                        pystray.MenuItem(
                            f"Iterations: {client.iterations}", None, enabled=False
                        ),
                        pystray.MenuItem(
                            f"Improvements found: {client.improvements}",
                            None,
                            enabled=False,
                        ),
                        pystray.MenuItem("Stop", partial(self._remove_client, handle)),
                    ),
                ),
            )

        items.append(pystray.MenuItem("Quit", self._quit))

        self._update_menu(items, flush)
github simonlindholm / decomp-permuter / src / server_main.py View on Github external
def _update(self, flush: bool = True) -> None:
        title = "Currently permuting:" if self._clients else ""
        items: List[pystray.MenuItem] = [
            pystray.MenuItem(title, None, enabled=False),
        ]

        for handle, client in self._clients.items():
            fn_names = ", ".join(client.fn_names)
            items.append(
                pystray.MenuItem(
                    f"{fn_names} ({client.nickname})",
                    pystray.Menu(
                        pystray.MenuItem(
                            f"Iterations: {client.iterations}", None, enabled=False
                        ),
                        pystray.MenuItem(
                            f"Improvements found: {client.improvements}",
                            None,
                            enabled=False,
                        ),
                        pystray.MenuItem("Stop", partial(self._remove_client, handle)),
                    ),
                ),
            )

        items.append(pystray.MenuItem("Quit", self._quit))
github typeworld / guiapp / wxPython / daemon.py View on Github external
def quitIcon():

			closeListenerThread = Thread(target=closeListener)
			closeListenerThread.start()

			time.sleep(1)

			t.stop()
			t.join()


			icon.stop()


		menu = (
			item(localize('Open Type.World App'), openApp, default=True),
			item(localize('Check for font updates now'), checkForUpdates),
		)#, pystray.Menu.SEPARATOR, item('Quit', quitIcon))

		if MAC:
			image = NSImage.alloc().initWithContentsOfFile_(NSBundle.mainBundle().pathForResource_ofType_('MacSystemTrayIcon', 'pdf'))
			image.setTemplate_(True)
			image_notification = NSImage.alloc().initWithContentsOfFile_(NSBundle.mainBundle().pathForResource_ofType_('MacSystemTrayIcon_Notification', 'pdf'))
			image_notification.setTemplate_(True)
		if WIN:

			image = win32.LoadImage(
					None,
					os.path.join(os.path.dirname(__file__), 'icon', 'TaskbarIcon.ico'),
					win32.IMAGE_ICON,
					0,
					0,
github moses-palmer / virtual-touchpad / lib / virtualtouchpad / trayicon.py View on Github external
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,
                checked=lambda i: bool(configuration.ACCESS_TOKEN)),
            menu.SEPARATOR,
            item(
                _('Help'),
                href('help')),
            menu.SEPARATOR,
            item(
                _('Exit'),
                lambda icon: icon.server.stop())))
github simonlindholm / decomp-permuter / src / server_main.py View on Github external
f"{fn_names} ({client.nickname})",
                    pystray.Menu(
                        pystray.MenuItem(
                            f"Iterations: {client.iterations}", None, enabled=False
                        ),
                        pystray.MenuItem(
                            f"Improvements found: {client.improvements}",
                            None,
                            enabled=False,
                        ),
                        pystray.MenuItem("Stop", partial(self._remove_client, handle)),
                    ),
                ),
            )

        items.append(pystray.MenuItem("Quit", self._quit))

        self._update_menu(items, flush)
github moses-palmer / virtual-touchpad / lib / virtualtouchpad / trayicon.py View on Github external
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,
                checked=lambda i: bool(configuration.ACCESS_TOKEN)),
            menu.SEPARATOR,
            item(
                _('Help'),
                href('help')),
            menu.SEPARATOR,
            item(
                _('Exit'),
                lambda icon: icon.server.stop())))
github moses-palmer / virtual-touchpad / lib / virtualtouchpad / trayicon.py View on Github external
'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,
                checked=lambda i: bool(configuration.ACCESS_TOKEN)),
            menu.SEPARATOR,
            item(
                _('Help'),
                href('help')),
            menu.SEPARATOR,
            item(
                _('Exit'),
                lambda icon: icon.server.stop())))