Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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))
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,
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())))
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)
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())))
'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())))