Ejemplo n.º 1
0
class NetMonitor(object):
    def __init__(self):
        self.sti = SysTrayIcon(down_icon, hover_text, menu_options, on_quit=self.bye, default_menu_index=1)
        checker = Thread(target=self.loop)
        checker.start()
        self.sti.show()
    
    def bye(self, sysTrayIcon): 
        global RUNNING
        RUNNING = False
    
    def url_up(self, url):
        try:
            conn = urlopen(url)
            conn.close()
            return True
        except:
            return False

    def switch_icon(self, icon, hover_text):
        self.sti.icon = icon
        self.sti.hover_text = hover_text
        self.sti.refresh_icon()

    def run(self):
        if self.url_up("http://www.google.com") or self.url_up("http://www.plus.net"):
            self.switch_icon(ok_icon, "Connection OK")
        else:
            self.switch_icon(down_icon, "Connection down")

    def loop(self):
        time.sleep(5)
        while RUNNING:
            self.run()
            time.sleep(15)
Ejemplo n.º 2
0
def runTray():
    "添加系统托盘"
    global tray
    if utils.getSystem() == utils.System.WINDOWS:
        logging.info("Init system tray for windows.")
        menuOptions = (("显示/隐藏", None, onOptionClicked), ("退出", None, onOptionClicked))
        tray = SysTrayIcon("./icon.ico", "我的热点新闻服务器", onTrayClicked, menuOptions)
        tray.loop()
    elif utils.getSystem() == utils.System.LINUX:
        logging.info("System tray doesn't support linux.")
    elif utils.getSystem() == utils.System.MACOS:
        logging.info("System tray doesn't support macOS.")
    else:
        logging.info("System tray doesn't support this system.")
    return
Ejemplo n.º 3
0
def tray_handler():
	global TRAY_HNWD
	hover_text = "Gesture Mouse Server"
	menu_options = (
# 		('Say Hello', None, kill_server),
# 		('Switch Icon', None, kill_server),
# 		('A sub-menu', None, (
# 			('Say Hello to Simon', None, kill_server),
# 			('Switch Icon', None, kill_server),
# 		))
	)
	TRAY_HNWD = SysTrayIcon("icon.ico", hover_text, menu_options, on_quit=kill_server, default_menu_index=1)
	TRAY_HNWD.show_balloon_tip("Startup", "Gesture mouse is running.")
	TRAY_HNWD.start()
Ejemplo n.º 4
0
 def __init__(self):
     self.sti = SysTrayIcon(down_icon, hover_text, menu_options, on_quit=self.bye, default_menu_index=1)
     checker = Thread(target=self.loop)
     checker.start()
     self.sti.show()
        log.info("enable session lock")

    def left_ckick():
        print(">> left click")
        print("%s" % sys_tray_app.icon)
        if str(sys_tray_app.icon).__contains__('unlock.ico'):
            log.info("unlocked -> locked")
            enable_lock(sys_tray_app)
        else:
            log.info("locked -> unlocked")
            disable_lock(sys_tray_app)
        print("<< left click")

    def bye(sysTrayIcon):
        log.info('Bye, then.')

    menu_options = (
        ('enable session locking', None, enable_lock),
        ('disable session locking', None, disable_lock),
    )

    sys_tray_app = SysTrayIcon(unlock_icon,
                               hover_text,
                               menu_options,
                               left_click_action=left_ckick,
                               on_quit=bye,
                               default_menu_index=1)
    session_unlocking_thd = SessionUnlockingThread(sys_tray_app)
    session_unlocking_thd.start()
    sys_tray_app.start()
Ejemplo n.º 6
0
    def init_gui(self):
        self.root.title(self.title)
        self.root.geometry(self.size)
        if not self.resizable: self.root.resizable(0, 0)
        if os.path.isfile(self.icon): self.root.iconbitmap(self.icon)

        self.sysTrayIcon = SysTrayIcon(self.icon,
                                       self.hover,
                                       on_quit=lambda: self.root.destroy(),
                                       gui=self.root)

        self.lab = Label(self.root, text="初始化...", font='幼圆 -16', fg="brown")

        self.resize_btn = Button(self.root,
                                 text='还原分辨率',
                                 bg='#c0d6e4',
                                 command=self.resize,
                                 font='幼圆 -14')

        self.multi_btn = Button(self.root,
                                text='多开初始化',
                                bg='#c0d6e4',
                                command=self.multi_open,
                                font='幼圆 -14')

        self.hide_btn = Button(self.root,
                               text='隐藏至托盘',
                               bg='#c0d6e4',
                               command=self.minimize,
                               font='幼圆 -14')

        self.radio_0 = Radiobutton(self.root,
                                   text='通用(哪里要点点哪里)',
                                   value=0,
                                   variable=self.mode,
                                   borderwidth=4,
                                   indicatoron=0,
                                   command=self.change_mode,
                                   font='幼圆 -14',
                                   bg='#cccccc',
                                   selectcolor='#87e7bb')

        self.radio_1 = Radiobutton(self.root,
                                   text='组队刷本',
                                   value=1,
                                   variable=self.mode,
                                   borderwidth=4,
                                   indicatoron=0,
                                   command=self.change_mode,
                                   font='幼圆 -14',
                                   bg='#cccccc',
                                   selectcolor='#87e7bb')

        self.radio_2 = Radiobutton(self.root,
                                   text='单刷_探索',
                                   value=2,
                                   variable=self.mode,
                                   borderwidth=4,
                                   indicatoron=0,
                                   command=self.change_mode,
                                   font='幼圆 -14',
                                   bg='#cccccc',
                                   selectcolor='#87e7bb')

        self.radio_3 = Radiobutton(
            self.root,
            text='结界突破',
            value=3,
            variable=self.mode,
            borderwidth=4,  #state = 'disabled',
            indicatoron=0,
            command=self.change_mode,
            font='幼圆 -14',
            bg='#cccccc',
            selectcolor='#87e7bb')

        self.radio_4 = Radiobutton(self.root,
                                   text='妖气封印',
                                   value=4,
                                   variable=self.mode,
                                   borderwidth=4,
                                   indicatoron=0,
                                   command=self.change_mode,
                                   font='幼圆 -14',
                                   bg='#cccccc',
                                   selectcolor='#87e7bb')

        self.radio_255 = Radiobutton(self.root,
                                     text='[暂停]',
                                     value=255,
                                     variable=self.mode,
                                     borderwidth=5,
                                     indicatoron=0,
                                     command=self.change_mode,
                                     font='幼圆 -16',
                                     bg='#cccccc',
                                     selectcolor='#e6b8af')

        self.full_chk = Checkbutton(self.root,
                                    text='等满员',
                                    variable=self.if_full,
                                    borderwidth=2,
                                    indicatoron=0,
                                    command=self.change_fullteam,
                                    font='幼圆 -13',
                                    bg='#c0d6e4',
                                    selectcolor='#ccd7ff')

        self.mob_list = ttk.Combobox(self.root,
                                     textvariable=self.mob,
                                     font='幼圆 -13')
        self.mob_list["values"] = ('日和坊', '海坊主', '鬼使黑', '跳跳哥哥', '小松丸', '二口女',
                                   '以上全部')
        self.mob_list.bind("<<ComboboxSelected>>", self.change_mode)
        self.mob_list["state"] = "readonly"
        self.mob_list.current(0)

        self.shut_time = Entry(self.root,
                               textvariable=self.shut_var,
                               validate='key',
                               vcmd=(self.register_func[0], '%P'))
        self.shut_time.bind('<Return>', self.shutdown)

        self.shut_label = Label(self.root, text="分钟后", font='幼圆 -14')

        self.shut_btn = Button(self.root,
                               text='关机',
                               borderwidth=3,
                               bg='#fdc9d9',
                               command=self.shutdown,
                               font='幼圆 -14')
        self.cacel_btn = Button(self.root,
                                text='取消',
                                borderwidth=3,
                                bg='#cccccc',
                                command=self.cancel_shut,
                                font='幼圆 -14')

        self.author = Label(self.root,
                            text="-- developed by iclosed  ",
                            height=2,
                            width=22,
                            fg="blue")
Ejemplo n.º 7
0
        SPACES = True
        PREFIX_NUMBER = 2

    # Initialize the Word Completer and Keyboard Handler.
    WC = WordCompleter(WC_pkl_file, PREFIX_NUMBER)
    KbH = KeyboardHandler(WC, GUI_Q, SPACES, DCM)

    # SysTrayIcon argument parameters
    hovertext = "Automatic Word Completion"
    icon = os.getcwd() + "/" + "Speech_Bubble_Icon.ico"
    menu_options = (('Options', icon, options), )

    # Threaded class initialization
    SysTray = SysTrayIcon(KbH,
                          icon,
                          hovertext,
                          menu_options,
                          default_menu_index=0)
    WSG = WSGui(BG, GUI_CORNER_PLACEMENT, DCM, FONTSIZE, TXTCOLOR, GUI_Q,
                GUI_HEIGHT, GUI_WIDTH)

    # Start the SysTray and Word Suggester GUI Threads.
    SysTray.start()
    WSG.start()
    '''
    Begin the message loop waiting for keyboard input.
    This should continue until the tray icon tells the handler to shut down.
    '''
    KbH.begin()
    time.sleep(1)  # Let threads clean up.