diff options
Diffstat (limited to 'ctec/__main__.py')
-rw-r--r-- | ctec/__main__.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ctec/__main__.py b/ctec/__main__.py index eff6138..8d01960 100644 --- a/ctec/__main__.py +++ b/ctec/__main__.py @@ -1,8 +1,11 @@ +import threading from tkinter import * from tkinter import messagebox from tkinter import ttk from . import VERSION +from .config import get_config +from .logic import Account class CtecFrame: def __init__(self, root: Tk): @@ -14,6 +17,23 @@ class CtecFrame: root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) + config = get_config() + self.accounts = [Account(address=section, info=config[section]) for section in config.sections() if '@' in section] + self.accounts_tree = ttk.Treeview(mainframe, columns=('unread', 'all')) + self.accounts_tree.column('unread', width=50, anchor=E) + self.accounts_tree.heading('unread', text='Unread') + self.accounts_tree.column('all', width=50, anchor=E) + self.accounts_tree.heading('all', text='All') + self.accounts_tree.grid(column=0, row=0, sticky=(N, W, E, S)) + self.accounts_tree.insert('', 'end', 'all', text='All Accounts') + for account in self.accounts: + unread_count = sum(1 for message in account.inbox() if 'S' not in message.get_flags()) + all_count = sum(1 for message in account.inbox()) + self.accounts_tree.insert('', 'end', account.address, text=account.address, values=(unread_count, all_count)) + threading.Thread(target=lambda: account.fetch_inbox()).start() + + # self.messages = + # create a menu bar self.make_menu_bar(root) |