from Tkinter import *
from Pmw import *
from PmwContribD import *
from MCScrolledListBox import *
import AOCore
class AccountOverview:
def __init__(self, parent):
self.accounts = []
self.parent = parent
self.ao = AOCore.AOCore(parent = self.parent)
self.createMenuBar()
self.table = MCScrolledListBox(self.parent, selectioncommand=self.selectioncommand,dblclickcommand=self.dblclickcommand,)
self.createTable()
def createMenuBar(self):
self.menubar = Menu(self.parent)
# create a pulldown menu, and add it to the menu bar
#just a change
self.filemenu = Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label = "Manage accounts", command = self.manageAccounts)
self.importmenu = Menu(self.filemenu,tearoff=0)
self.filemenu.add_cascade(label = "Import", menu = self.importmenu)
for (i,j) in self.ao.getAccounts():
self.accounts.append(i)
self.importmenu.add_command(label = str(j)+" ("+str(i)+")", command = lambda account=str(i):self.ao.importForAccount(account))
self.filemenu.add_command(label = "Export", command = self.exportDatabase)
self.filemenu.add_separator()
self.filemenu.add_command(label = "Exit", command = root.quit)
self.menubar.add_cascade(label = "Database", menu = self.filemenu)
self.graphMenu = Menu(self.menubar, tearoff = 0)
self.graphMenu.add_command(label = "Saldo", command = self.ao.plotGraph)
self.menubar.add_cascade(label = "Graphs", menu = self.graphMenu)
self.parent.config(menu = self.menubar)
def refreshMenuBar(self):
self.createMenuBar()
self.parent.update()
def importRaboFile(self):
self.ao.importFile(type="Rabo")
def importPostFile(self):
self.ao.importFile(type="Post")
def exportDatabase(self):
print "implement export stuff"
def manageAccounts(self):
self.ao.manageAccounts();
self.refreshMenuBar()
def createTable(self):
columns = (('Date', NO, 12), ('Code', NO, 5), ('Counter Account', NO, 15), ('To', NO, 25), ('D/C', NO, 5), ('Description', YES, 45), ('Currency', NO, 10), ('Amount', YES, 8))
for cl, expand, width in columns:
self.table.addColumn(label=cl, expand=expand, width=width)
self.table.pack(side=TOP, expand=YES, fill=BOTH)
data = []
if len(self.accounts) == 1:
data = self.ao.getAllMutations(self.accounts[0])
else:
#ask which account to use
print "help"
self.table.setlists(data)
def selectioncommand(self, *args):
print 'selectioncommand:', args
print '\tselected: '
for rec in self.table.getcurselection():
print '\t', rec
return
def dblclickcommand(self, *args):
print 'dblclickcommand:', args
print '\tselected: '
for rec in self.table.getcurselection():
print '\t', rec
return
if __name__ == '__main__':
root = Tk()
root.title("Account Overview")
accountOverview = AccountOverview(root)
root.mainloop()