aboutsummaryrefslogtreecommitdiff
path: root/ctec/__main__.py
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-02-27 17:14:38 -0700
committerMelody Horn <melody@boringcactus.com>2021-02-27 17:14:38 -0700
commit1cf5e68c25c0505194f23d4018e29767d3b519dd (patch)
tree63ec483c12e57ccbdea5e94ab82448cbff7b8753 /ctec/__main__.py
parentbcb2b78eed508834192557e93f158f171f51f02d (diff)
downloadctec-1cf5e68c25c0505194f23d4018e29767d3b519dd.tar.gz
ctec-1cf5e68c25c0505194f23d4018e29767d3b519dd.zip
fetch inboxes
Diffstat (limited to 'ctec/__main__.py')
-rw-r--r--ctec/__main__.py20
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)