Exemple #1
0
    def __init__(self):
        self.__main_gui = None
        self.__notifier = sh.Command("/usr/bin/notify-send")
        self.__running = True
        self.__updater = threading.Thread(target=self.__update_loop)
        self.__scheduler = sched.scheduler(time.time, time.sleep)

        self.__config = config.AppConfig('dnfdragora')
        self.__updateInterval = 180

        if self.__config.systemSettings:
            settings = {}
            if 'settings' in self.__config.systemSettings.keys():
                settings = self.__config.systemSettings['settings']
                if 'update_interval' in settings.keys():
                    self.__updateInterval = int(settings['update_interval'])

        if self.__config.userPreferences:
            if 'settings' in self.__config.userPreferences.keys():
                settings = self.__config.userPreferences['settings']
                if 'interval for checking updates' in settings.keys():
                    self.__updateInterval = int(
                        settings['interval for checking updates'])

        icon_path = '/usr/share/icons/hicolor/128x128/apps/dnfdragora.png'

        try:
            self.__backend = dnfdaemon.client.Client()
        except dnfdaemon.client.DaemonError as error:
            print(_('Error starting dnfdaemon service: [%s]'), str(error))
            sys.exit(1)

        try:
            from gi.repository import Gtk
            icon_theme = Gtk.IconTheme.get_default()
            icon_path = icon_theme.lookup_icon("dnfdragora", 128,
                                               0).get_filename()
        except:
            pass

        self.__icon = Image.open(icon_path)
        self.__menu = Menu(
            MenuItem(_('Update'), self.__run_update),
            MenuItem(_('Open dnfdragora dialog'), self.__run_dnfdragora),
            MenuItem(_('Check for updates'), self.__get_updates_forced),
            MenuItem(_('Exit'), self.__shutdown))
        self.__name = 'dnfdragora-updater'
        self.__tray = Tray(self.__name, self.__icon, self.__name, self.__menu)
 def generateProfilesMenu(self):
     result = [
         MenuItem(_('New Profile'), self._redirectTo(self._newProfile))
     ]
     for profile in ProxyTrayConfig.getProfiles():
         result.append(
             MenuItem(
                 profile['name'],
                 Menu(lambda: (MenuItem(
                     _('Apply'),
                     self._redirectTo(self._applyProfile, profile['name'])),
                               MenuItem(
                                   _('Edit'),
                                   self._redirectTo(self._modifyProfile,
                                                    profile['name']))))))
     return result
Exemple #3
0
    def run(self):
        # not supported on mac
        if config.operating_system == 'Darwin':
            log('Systray is not supported on mac yet')
            return

        options_map = {
            'Show': self.show_main_window,
            'Minimize to Systray': self.minimize_to_systray,
            'Quit': self.quit
        }

        # make our own Gtk statusIcon, since pystray failed to run icon properly on Gtk 3.0 from a thread
        if config.operating_system == 'Linux':
            try:
                import gi
                gi.require_version('Gtk', '3.0')
                from gi.repository import Gtk
                self.Gtk = Gtk

                def icon_right_click(icon, button, time):
                    menu = Gtk.Menu()

                    for option, callback in options_map.items():
                        item = Gtk.MenuItem(label=option)
                        item.connect('activate', callback)
                        menu.append(item)

                    menu.show_all()
                    menu.popup(None, None, None, icon, button, time)

                icon = Gtk.StatusIcon()
                icon.set_from_file(self.tray_icon_path)
                icon.connect("popup-menu", icon_right_click)
                icon.connect('activate', self.show_main_window)

                self.active = True
                Gtk.main()
                return
            except:
                self.active = False

        # let pystray decide which icon to run
        try:
            from pystray import Icon, Menu, MenuItem
            items = []
            for option, callback in options_map.items():
                items.append(
                    MenuItem(option,
                             callback,
                             default=True if option == 'Show' else False))

            menu = Menu(*items)
            self.icon = Icon('PyIDM', self.tray_icon, menu=menu)
            self.active = True
            self.icon.run()
        except Exception as e:
            log('systray: - run() - ', e)
            self.active = False
Exemple #4
0
 def init_icon(self):
     self.withdraw()
     menu = []
     for name, lst in engine.tray_buttons.items():
         menu.append(MenuItem(name, partial(lst[0], self), **lst[1]))
     self.tray_icon = pystray.Icon("AutoClicker", self.tray_ico,
                                   "AutoClicker", pystray.Menu(*menu))
     self.tray_icon.run()
Exemple #5
0
def init_icon():
    icon = pystray.Icon('Status')
    icon.menu = Menu(
        MenuItem('Available', lambda: ButtonClickAvail(User)),
        MenuItem('Webex', lambda: ButtonClickWebex(User)),
        MenuItem('Logs/ESRS', lambda: ButtonClickLogs(User)),
        MenuItem('No Bandwidth', lambda: ButtonClickNoBW(User)),
        MenuItem('Away', lambda: ButtonClickAway(User)),
        MenuItem('In Call', lambda: ButtonClickIncall(User)),
        MenuItem('Out of office', lambda: ButtonClickOOO(User)),
    )
    icon.icon = Image.open(resource_path('./images/icon.png'))
    icon.title = 'Status Update'

    def setup(icon):
        icon.visible = True
        app = IsilonStatus()

        app.mainloop()

        # while icon.visible==True:
        #     flags, hcursor, (prevx,prevy) = win32gui.GetCursorInfo()
        #     self.after(1000 * 10, self.inactive(prevx, prevy))

    icon.run(setup)

    return icon
Exemple #6
0
def main():
    logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', level=logging.INFO)
    logging.info('URL Trimmer boot!')

    global thread
    thread = ClipboardThread(WindowsTextClipboard(), DEFAULT_FILTERS)

    logging.info('Starting clipboard thread')
    thread.start()

    image = Image.open('icon.png')
    icon = Icon('URL Trimmer', icon=image, menu=Menu(
        MenuItem('Settings', lambda icon, item: None),
        MenuItem('Exit', close_app)
    ))

    logging.info('Starting system tray icon')
    icon.run()
Exemple #7
0
 def add(self, text: str, selected: bool = False):
     index: int = len(self.items)
     if selected: RadioButtonGroup.state = index
     btn: MenuItem = MenuItem(text=text,
                              action=RadioButtonGroup.set_state(index),
                              checked=RadioButtonGroup.get_state(index),
                              radio=True)
     self.items.append(btn)
     return btn
Exemple #8
0
def init_icon():
    icon = pystray.Icon('Network downtime detector')

    icon.menu = Menu(MenuItem('Exit', lambda: exit_action(icon)))

    icon.icon = create_image(down, "Start", 12, white)

    icon.title = 'Network downtime detector'

    icon.run(setup)
Exemple #9
0
    def __init__(self):
        self.cs = CapSwitch()

        #Run CapSwitch when it is opened
        self.init_thread(target=self.cs.start_listener)

        # *** Attributes ***
        self.icon_path = "icon.png"

        # *** Setup Menu ***
        self.menu_items = [
            MenuItem(self.check_status, self.toggle),
            MenuItem("Exit", self.exit),
        ]
        self.menu = Menu(*self.menu_items)

        # *** Create System Tray Icon ***
        self.icon = Icon("CapSwitch", menu=self.menu)
        self.icon.icon = Image.open(self.icon_path)
        self.icon.run()
Exemple #10
0
    def start(self):
        def on_clicked(icon, _):
            logging.info('[APP] Closing. Source: TrayIcon')
            states.running = False
            icon.stop()

        def clicked_display(_, item):
            states.displayed = item.checked

        tray_icon = Icon('chesscord',
                         title='chesscord',
                         icon=Image.open(RESOURCES_DIR / 'logo.png'))
        tray_icon.menu = Menu(
            MenuItem('update config', utils.open_webpage),
            MenuItem('hide',
                     clicked_display,
                     checked=lambda item: not states.displayed),
            MenuItem('Exit', on_clicked))

        tray_icon.run()
Exemple #11
0
    def run(self):
        def get_wrapper(command):
            def wrapper():
                self.r_queue.put((command, None))
            return wrapper

        def die():
            self.icon_stop()

        menu_items = [
            MenuItem("Show Console", get_wrapper("show_console")),
            MenuItem("Application Menu", get_wrapper("open_player_menu")),
            MenuItem("Open Config Folder", get_wrapper("open_config_brs")),
            MenuItem("Quit", die)
        ]

        icon = Icon(APP_NAME, menu=Menu(*menu_items))
        icon.icon = Image.open(icon_file)
        self.icon_stop = icon.stop
        icon.run()
        self.r_queue.put(("die", None))
Exemple #12
0
 def add_button(
         self,
         text: str,
         action: Callable,
         args=None,
         default: bool = False,
         checked: Callable[[Any], bool] = lambda icon: False) -> MenuItem:
     self.add(btn := MenuItem(text=text,
                              action=lambda: action(*(args or ())),
                              default=default,
                              checked=checked))
     return btn
    def __init__(self, config):
        self.config = config
        self.proxySettings = config.proxySettings
        self.proxySettings.onChangedMode(self._changedProxyMode)

        self.iconNoProxy = Image.open(
            os.path.abspath(self.config.path + '/icons/no_proxy.png'))
        self.iconProxyMan = Image.open(
            os.path.abspath(self.config.path + '/icons/proxy_man.png'))
        self.iconProxyAuto = Image.open(
            os.path.abspath(self.config.path + '/icons/proxy_auto.png'))

        self.menu = Menu(lambda: (
            MenuItem(self.modeLabel, None, enabled=False), Menu.SEPARATOR,
            MenuItem(_('Deactivate Proxy'),
                     self._redirectTo(self._noProxy),
                     enabled=not self.mode.isNone()),
            MenuItem(_('Activate Manual Proxy'),
                     self._redirectTo(self._proxyMan),
                     enabled=not self.mode.isManual()),
            MenuItem(_('Activate Automatic Proxy'),
                     self._redirectTo(self._proxyAuto),
                     enabled=not self.mode.isAuto()), Menu.SEPARATOR,
            MenuItem(_('Proxy Profiles'),
                     Menu(lambda: self.generateProfilesMenu())), Menu.
            SEPARATOR, MenuItem(_('Exit Tray'), self._redirectTo(self.quit))))

        self.profileEditor = ProfileEditor(self.config)
        self.profileEditor.onSaveCallback(self.update_menu)
        self.profileEditor.onDeleteCallback(self.update_menu)

        self.pystray = Icon('ProxyTray', self.iconProxyMan, menu=self.menu)
        self._refreshProxyMode()

        self.pystray.run()
Exemple #14
0
    def __init__(self, icon, menu=[], exit=None, schedule=None):
        self.icon = pystray.Icon("mon")
        self.icon.title = "Tooltip"
        self.icon.icon = Image.open(icon)
        self.schedule = schedule
        menu.append(("Exit", lambda: self.exit()))

        menu_items = []
        for name, action in menu:
            menu_items.append(MenuItem(name, action))
        self.icon.menu = Menu(*menu_items)

        if exit:
            self.exit = exit
Exemple #15
0
def create_commands(commands_dict):
    def create_callable(command):
        def run(*_):
            # you probably want to replace this with
            # the subprocess module later:
            os.system(command)

        return run

    commands = [
        MenuItem(text, create_callable(command), default=default)
        for text, command, default in COMMANDS
    ]
    return commands
Exemple #16
0
def tray():
    global icon, thread
    icon = None
    thread = None

    name = 'ED - Autopilot'
    icon = Icon(name=name, title=name)
    logo = Image.open(resource_path('src/logo.png'))
    icon.icon = logo

    icon.menu = Menu(MenuItem('Exit', lambda: exit_action()), )

    keyboard.add_hotkey('home', start_action)
    keyboard.add_hotkey('end', stop_action)

    icon.run(setup)
Exemple #17
0
def configure_systray():
    def setup(icon):
        icon.visible = True

    def exit_action(icon):
        icon.visible = False
        icon.stop()
        os._exit(1)

    image = Image.open(os.path.join("images", "snappy_systray.png"))

    icon = Icon("snappy", icon=image, title="snappy")

    menu = Menu(MenuItem("exit", lambda: exit_action(icon)))
    icon.menu = menu

    icon.run(setup)
Exemple #18
0
    def add_menu_item(
        self,
        text: str = None,
        action: Callable = None,
        menu_item: 'MenuItem' = None,
        index: int = None,
        **kwargs,
    ):
        """
        Add a menu item byt passing its text and function, or pass a created MenuItem. Force position by sending index
        """
        if not any(v for v in (menu_item, text)):
            raise ValueError(f"Either 'text' or 'menu_item' are required")

        menu_item = menu_item or MenuItem(text=text, action=action, **kwargs)
        if index is not None:
            self.menu_items.insert(index, menu_item)
        else:
            self.menu_items.append(menu_item)
Exemple #19
0
    def run(self):
        # not supported on mac
        if config.operating_system == 'Darwin':
            log('Systray is not supported on mac yet')
            return

        options_map = {'Show': self.show_main_window,
                       'Minimize to Systray': self.minimize_to_systray,
                       'Quit': self.quit}

        # make our own Gtk statusIcon, since pystray failed to run icon properly on Gtk 3.0 from a thread
        if config.operating_system == 'Linux':
            try:
                import gi
                gi.require_version('Gtk', '3.0')
                from gi.repository import Gtk
                self.Gtk = Gtk

                # delete previous icon file (it might contains an icon file for old firedm versions)
                delete_file(self.tray_icon_path)

                # save file to settings folder
                self.tray_icon.save(self.tray_icon_path, format='png')

                # creating menu
                menu = Gtk.Menu()
                for option, callback in options_map.items():
                    item = Gtk.MenuItem(label=option)
                    item.connect('activate', callback)
                    menu.append(item)
                menu.show_all()

                APPINDICATOR_ID = config.APP_NAME

                # setup notify system, will be used in self.notify()
                gi.require_version('Notify', '0.7')
                from gi.repository import Notify as notify
                self.Gtk_notify = notify  # get reference for later deinitialize when quit systray
                self.Gtk_notify.init(APPINDICATOR_ID)  # initialize first

                # try appindicator
                try:
                    gi.require_version('AppIndicator3', '0.1')
                    from gi.repository import AppIndicator3 as appindicator

                    indicator = appindicator.Indicator.new(APPINDICATOR_ID, self.tray_icon_path, appindicator.IndicatorCategory.APPLICATION_STATUS)
                    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
                    indicator.set_menu(menu)

                    # use .set_name to prevent error, Gdk-CRITICAL **: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
                    indicator.set_name = APPINDICATOR_ID

                    # can set label beside systray icon
                    # indicator.set_label('1.2 MB/s', '')

                    self.active = True
                    log('Systray active backend: Gtk.AppIndicator')
                    Gtk.main()
                    return
                except:
                    pass

                # try GTK StatusIcon
                def icon_right_click(icon, button, time):
                    menu.popup(None, None, None, icon, button, time)

                icon = Gtk.StatusIcon()
                icon.set_from_file(self.tray_icon_path)  # DeprecationWarning: Gtk.StatusIcon.set_from_file is deprecated
                icon.connect("popup-menu", icon_right_click)  # right click
                icon.connect('activate', self.show_main_window)  # left click
                icon.set_name = APPINDICATOR_ID

                self.active = True
                log('Systray active backend: Gtk.StatusIcon')
                Gtk.main()
                return
            except Exception as e:
                log('Systray Gtk 3.0:', e, log_level=2)
                self.active = False
        else:
            # let pystray run for other platforms, basically windows
            try:
                from pystray import Icon, Menu, MenuItem
                items = []
                for option, callback in options_map.items():
                    items.append(MenuItem(option, callback, default=True if option == 'Show' else False))

                menu = Menu(*items)
                self.icon = Icon(config.APP_NAME, self.tray_icon, menu=menu)
                self.active = True
                self.icon.run()
            except Exception as e:
                log('systray: - run() - ', e)
                self.active = False
Exemple #20
0

def on_launch_app(icon, item):
    print("LAUNCHING APP FROM : ", config.get('path', f'app_{sys.platform}'))
    subprocess.Popen(config.get('path', f'app_{sys.platform}'))



icon = Icon(
        'Mist ERP',
        Image.open(resource_path(f'assets{os.sep}icons{os.sep}favicon.ico')),
        menu=Menu(
            MenuItem(
                "Launch APP",
                on_launch_app,
                default=True,
                enabled=True,
                visible=True
            )
        )
    )


def run_systray_app():
    logging.debug('initialize icon')
    global icon
    icon.run()


@atexit.register
def stop_app_process():
Exemple #21
0
    def __init__(self, worker: Worker):
        # save worker reference
        self._worker = worker

        # create the icon
        self._icon = Icon("Mover")

        # set the image
        self._icon.icon = MOVER_ICON
        # set actions
        #   - set source
        #   - set destination
        #   - number of backlogs
        #   - start/stop
        #   - exit
        self._start_stop = MenuItem("Start", self.on_start_stop,
                                    enabled=False)  # initial state
        self._set_source = MenuItem("Set Source", self.on_set_source)
        self._set_destination = MenuItem("Set Destination",
                                         self.on_set_destination)
        self._number_of_backlogs = MenuItem(
            "Number of Backlogs",
            Menu(
                MenuItem("Immediate",
                         partial(self.on_number_of_backlogs_changed, 0)),
                MenuItem("5", partial(self.on_number_of_backlogs_changed, 5)),
                MenuItem("10", partial(self.on_number_of_backlogs_changed,
                                       10)),
                MenuItem("25", partial(self.on_number_of_backlogs_changed,
                                       25)),
            ),
        )
        self._timeout = MenuItem(
            'Timeout',
            Menu(MenuItem('Never', partial(self.on_timeout_changed, 0)),
                 MenuItem('30 s', partial(self.on_timeout_changed, 30))))
        self._exit = MenuItem("Exit", self.on_exit)
        self._icon.menu = Menu(
            self._start_stop,
            Menu.SEPARATOR,
            self._set_source,
            self._set_destination,
            self._number_of_backlogs,
            Menu.SEPARATOR,
            self._exit,
        )
Exemple #22
0
def item_checkable():
    return MenuItem(
        'Checkable',
        on_clicked,
        checked=lambda item: state
    )
Exemple #23
0
    info('Ответ!')
    signal.signal(signal.SIGKILL, signal.SIG_DFL)


# Создаем инстанс приложения
from os.path import join, abspath
from os import getcwd

app = Icon('Quantify',
           Image.open(
               join(
                   getcwd() if system() == 'Windows' else
                   abspath(__file__).replace(join('uis', 'universal.py'), ''),
                   'assets', 'toolbar_icon.png')),
           menu=Menu(
               MenuItem(text='Мышь',
                        action=on_clicked,
                        checked=lambda x: config.get_value('mouse')),
               MenuItem(text='Клавиатура',
                        action=on_clicked,
                        checked=lambda x: config.get_value('keyboard')
                        if system() != 'Darwin' else False,
                        enabled=system() != 'Darwin'),
               MenuItem(text='Процессы',
                        action=on_clicked,
                        checked=lambda x: config.get_value('processes')),
               MenuItem(text='Другое',
                        action=Menu(
                            MenuItem(text='Получить код 2FA',
                                     action=get_auth_code)))))
def setup(icon: Icon):
    icon.visible = True
    is_up_to_date = True

    while True:
        output = []
        wrong_output = []

        # TODO: Please do it better...
        repos, wrong_paths = utils.get_repos_and_wrong_paths(args.file)

        if wrong_paths:
            wrong_output.extend(["", "Those directories does not exist:"])
            for path in wrong_paths:
                wrong_output.append(f"-  {path}")

        for repo in repos:
            if repo_is_up_to_date(repo):
                continue
            text = f"- {repo.path} ({repo.branch})"
            repo.can_ff = can_do_fast_forward(repo)
            if repo.can_ff:
                text += " [FF]"
            output.append(text)

        was_up_to_date = is_up_to_date
        is_up_to_date = not bool(output)

        if is_up_to_date:
            _icon = icon_ok
            _items = [
                MenuItem("All existing repositories are up to date",
                         action=void)
            ]
        else:
            _icon = icon_fail
            _items = [MenuItem(f"{MESSAGE}:", action=void)] + [
                MenuItem(f"{text}", action=void) for text in output
            ]

            if any(repo.can_ff for repo in repos):
                _items.extend([
                    MenuItem("", action=void),
                    MenuItem(
                        text=
                        "Pull changes for fast forwardable repositories marked with [FF]",
                        action=pull_changes_for_list_of_repos(repos),
                    ),
                ])
            if was_up_to_date:
                n = Notifier()

                n.send_notification(output + wrong_output)

        if wrong_paths:
            _items.extend(
                [MenuItem(f"{text}", action=void) for text in wrong_output])

        _menu = Menu(*_items)

        icon.icon = _icon
        icon.menu = _menu

        time.sleep(args.delay)
                _items.extend([
                    MenuItem("", action=void),
                    MenuItem(
                        text=
                        "Pull changes for fast forwardable repositories marked with [FF]",
                        action=pull_changes_for_list_of_repos(repos),
                    ),
                ])
            if was_up_to_date:
                n = Notifier()

                n.send_notification(output + wrong_output)

        if wrong_paths:
            _items.extend(
                [MenuItem(f"{text}", action=void) for text in wrong_output])

        _menu = Menu(*_items)

        icon.icon = _icon
        icon.menu = _menu

        time.sleep(args.delay)


menu = Menu(MenuItem(text="Checking repositories...", action=void))

icon = Icon(name=MESSAGE, icon=icon_loading, menu=menu)

icon.run(setup)
Exemple #26
0
image = Image.new('RGB', (width, height))
dc = ImageDraw.Draw(image)
dc.ellipse((0, 0, 120, 120), fill='red')
dc.ellipse((20, 20, 100, 100), fill='blue')
dc.ellipse((40, 40, 80, 80), fill='green')


def turnOnOrOff(icon, item):
    global ambientOn
    ambientOn = not item.checked
    if ambientOn:
        ambientOnEvent.set()
    else:
        ambientOnEvent.clear()


icon = Icon(
    "Ambient RGB Light", image, "Ambient RGB Light",
    Menu(
        MenuItem('Ambient On',
                 action=turnOnOrOff,
                 checked=lambda item: ambientOn)))


def iconCallback(icon):
    icon.visible = True
    main()


icon.run(iconCallback)
Exemple #27
0
    # Called after icon is set up due to threading issues.
    spotify_helper = SpotifyHelper()

    def run_spotify_helper(icon_callback):
        try:
            icon_callback.visible = True
            spotify_helper.run()
        except Exception as e:
            logging.error('{}:{}'.format(e, traceback.format_exc()))
            traceback.print_exc()

    def stop_program(icon_callback):
        icon_callback.stop()
        spotify_helper.stop()

    icon_image = Image.open(
        os.path.join(os.path.dirname(__file__), 'resources/spo.png'))
    icon = Icon('spotify-helper',
                icon_image,
                menu=Menu(
                    MenuItem(text='Edit bindings', action=open_bindings_file),
                    Menu.SEPARATOR,
                    MenuItem(text='Quit', action=lambda: stop_program(icon)),
                ))

    # After icon starts running, we start the keyboard listener thread (together with the main
    # Spotify Helper code), since on macOS pystray won't work if pynput runs first, as the latter seems
    # to call a Mac _MainThread function which pystray then tries to call again but is not allowed - running
    # pystray first seems to be ok though.
    icon.run(setup=run_spotify_helper)
Exemple #28
0
def update_menu():
	global icon
	try:

		icon.menu = Menu(
			MenuItem('Messages(s) : '+str(nb_of_msgs_to_read), lambda : display_browser('https://www.koreus.com/modules/mpmanager/msgbox.php')),
			MenuItem('Notification(s) : '+str(nb_of_notifs), lambda : display_browser('https://www.koreus.com/notifs.php')),
			MenuItem('Article(s) : '+str(new_art), lambda : display_browser('https://www.koreus.com/modules/news/')),
			Menu.SEPARATOR,
			MenuItem('Paramètre', Menu(	MenuItem('Paramètres avancés', lambda : threading.Thread(target=parametrer_wnd).start()),
										Menu.SEPARATOR,		
										MenuItem('%s'%("Ne plus afficher les notifications" if show else "Réafficher les notifications"), able_notif),
										MenuItem('%s'%("Ne plus afficher les erreurs" if show_wrong else "Réafficher les erreurs"), show_error),	
										Menu.SEPARATOR,
										MenuItem( 'Activer la connexion Test non-sécurisée %s'%("(En cours)" if parameters[0] else ""), lambda:mod_parameters(1,0,0), enabled=1-parameters[0]),
										MenuItem( 'Activer la connexion Firefox sécurisée %s'%("(En cours)" if parameters[1] else ""), lambda:mod_parameters(0,1,0), enabled=1-parameters[1]),
										MenuItem( 'Activer la connexion Chrome sécurisée %s'%("(En cours)" if parameters[2] else ""), lambda:mod_parameters(0,0,1), enabled=1-parameters[2]))),
			MenuItem('%s'%("Déconnexion" if pwd else "Connexion"), lambda : redeconnexion()),							
			MenuItem('Quitter', lambda : exit_action(icon)),
		)

	except:
		traceback.print_exc()
Exemple #29
0
def item_quit():
    return MenuItem(
        'Quit',
        on_quit
    )
Exemple #30
0
def run_webview():
    window = webview.create_window('Webview',
                                   'https://pywebview.flowrl.com/hello')
    webview.start()


if __name__ == '__main__':

    def start_webview_process():
        global webview_process
        webview_process = Process(target=run_webview)
        webview_process.start()

    def on_open(icon, item):
        global webview_process
        if not webview_process.is_alive():
            start_webview_process()

    def on_exit(icon, item):
        icon.stop()

    start_webview_process()

    image = Image.open('logo/logo.png')
    menu = Menu(MenuItem('Open', on_open), MenuItem('Exit', on_exit))
    icon = Icon('Pystray', image, menu=menu)
    icon.run()

    webview_process.terminate()