Ejemplo n.º 1
0
def main():
    menu_options = (
            ('Open Dashboard', None, open_dashboard),
            ('Check for updates', None, check_updates),)
            #('Start Service', None, start_service),)
            #('Stop Service', None, stop_service),
            #('Reset Password', None, reset_password))

    icon = "icons/mycubevaulticon.ico"
    hover_text = 'MyCube Vault'

    st = SysTray(icon, hover_text, menu_options,
            on_quit=quit_services, default_menu_index=1)
    start_service(st)

    import timer
    def callback(timer_id, timer_t):
        try:
            data = urllib2.urlopen("http://%s:%s/check_restart" % (HOST, st.server_port), timeout=2).read()
            if data == "true":
                restart_service(st)
        except Exception:
            pass

    def update_monitor(timer_id, timer_t):
        if need_update():
            if not (hasattr(st, 'displayed') and st.displayed):
                with_update_dialog(st)
            else:
                timer.kill_timer(timer_id)

    def update_on_start(timer_id, timer_t):
        print "startup update"
        timer.kill_timer(timer_id)
        if need_update():
            with_update_dialog(st)

    timer.set_timer(3000, callback)
    timer.set_timer(3600 * 1000, update_monitor)
    timer.set_timer(10 * 1000, update_on_start)
    
    st.run()
Ejemplo n.º 2
0
    all_conf = parse_conf_file(fp)
    if not cmp(conf_item, "all"):
        return all_conf
    elif not cmp(conf_item, "rest"):
        return all_conf[0]
    elif not cmp(conf_item, "todo"):
        return all_conf[1]
    else:
        log("该配置项(%s)还未定义." % conf_item, "warn")
        return None

# Script starts from here

if __name__ == "__main__":
    app = QApplication(sys.argv)
    tray_icon = SysTray()
    tray_icon.show()
    tray_icon.showMessage(u"启动通知", u"Kreminder 已经启动,点击系统托盘图标可以获取帮助.", 1, 15000)

    # scheduler of Reminding rest
    rest_config = get_conf("rest")

    if rest_config:
        try:
            rest_remind_scheduler = BackgroundScheduler()
            rest_remind_scheduler.add_job(tray_icon.showMessage, 'interval', \
                                                                minutes = rest_config["interval"], \
                                                                args = [u"休息提醒", rest_config["message"], 1, 15000], \
                                                                id = "remind_rest")
            rest_remind_scheduler.start()
        except Exception, e:
Ejemplo n.º 3
0
    if not cmp(conf_item, "all"):
        return all_conf
    elif not cmp(conf_item, "rest"):
        return all_conf[0]
    elif not cmp(conf_item, "todo"):
        return all_conf[1]
    else:
        log("该配置项(%s)还未定义." % conf_item, "warn")
        return None


# Script starts from here

if __name__ == "__main__":
    app = QApplication(sys.argv)
    tray_icon = SysTray()
    tray_icon.show()
    tray_icon.showMessage(u"启动通知", u"Kreminder 已经启动,点击系统托盘图标可以获取帮助.", 1, 15000)

    # scheduler of Reminding rest
    rest_config = get_conf("rest")

    if rest_config:
        try:
            rest_remind_scheduler = BackgroundScheduler()
            rest_remind_scheduler.add_job(tray_icon.showMessage, 'interval', \
                                                                minutes = rest_config["interval"], \
                                                                args = [u"休息提醒", rest_config["message"], 1, 15000], \
                                                                id = "remind_rest")
            rest_remind_scheduler.start()
        except Exception, e:
Ejemplo n.º 4
0

class reloadTodoHandler(FileSystemEventHandler):
    def on_created(self, event):
        logging.warning(
            f'event type: {event.event_type} path: {event.src_path}')

    def on_modified(self, event):
        logging.warning(
            f'event type: {event.event_type} path: {event.src_path}')
        reloadTodos(ti)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ti = SysTray()
    setIcon(ti)

    addExitAction(ti)
    addSeparator(ti)
    addEditAction(ti)
    addSeparator(ti)
    # todo的内容
    addTodos(ti)
    ti.show()
    ti.showMessage(u"提示", u"程序启动", 2)

    #    import pdb;pdb.set_trace()

    event_handler = reloadTodoHandler()
    event_handler.ti = ti