def update_menu(categories, comments): tray_menu.clear() for kind, category in categories.items(): if not category.count: continue add_to(tray_menu, make_action(category.text, triggered=lambda category=category: category_click(category)) ) if kind == 'comments': for group, gr_comments in group_comments(comments).items(): if group: add_to(tray_menu, make_action(' {}:'.format(group), triggered=lambda category=category: category_click(category)) ) for comment in gr_comments: add_to(tray_menu, make_action(u' \u2022 {}'.format(comment.text), triggered=lambda comment=comment: comment_click(comment), tool_tip=comment.tooltip) ) add_to(tray_menu, None) if not tray_menu.isEmpty(): add_to(tray_menu, None) add_to(tray_menu, options_menu) qu(tray_icon, context_menu=tray_menu) else: qu(tray_icon, context_menu=options_menu)
try: os.remove(fn) except OSError: pass quit() def quit(): tray_icon.hide() app.quit() options_menu = add_to(QMenu("&Options"), make_action("&Check now", triggered=web.update), None, make_action("&Help...", triggered=information), make_action("&About...", triggered=about), None, make_action("&Log out and quit", triggered=logout), make_action("&Quit", triggered=quit), ) tray_menu = add_to(QMenu(), options_menu) categories = comments = None icon_font = QFont('Helvetica [Arial]', weight=QFont.Bold)