Advertisement
Guest User

account_balance

a guest
Apr 30th, 2014
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.94 KB | None | 0 0
  1. # coding=utf-8
  2. # Form implementation generated from reading ui file 'account_balance.ui'
  3. #
  4. # Created: Sat Apr 26 07:21:53 2014
  5. #      by: PyQt4 UI code generator 4.10.4
  6. #
  7. # WARNING! All changes made in this file will be lost!
  8. from PyQt4 import QtCore, QtGui
  9. import sys
  10. import pickle
  11. try:
  12.     _fromUtf8 = QtCore.QString.fromUtf8
  13. except AttributeError:
  14.     def _fromUtf8(s):
  15.         return s
  16.  
  17. try:
  18.     _encoding = QtGui.QApplication.UnicodeUTF8
  19.  
  20.     def _translate(context, text, disambig):
  21.         return QtGui.QApplication.translate(context, text, disambig, _encoding)
  22. except AttributeError:
  23.     def _translate(context, text, disambig):
  24.         return QtGui.QApplication.translate(context, text, disambig)
  25.  
  26. ############### ACCOUNT CLASS ###############
  27. class Account():
  28.     """ACCOUNT Instance Class"""
  29.     def __init__(self):
  30.         self.data = pickle.load(open("personal_account.p", "rb"))
  31.  
  32.     def __getitem__(self, item):
  33.         return self.data[item]
  34.  
  35.     def __setitem__(self, item, value):
  36.         self.data[item] = value
  37.  
  38.     def __delitem__(self, key):
  39.         del self.data[key]
  40.  
  41.     def inserItem(self,name, value, date, reason):
  42.         try:
  43.             total = self.data[name][0] + value
  44.             entries = self.data[name][1]
  45.             if date != None:
  46.                 entries.append([value, date, reason])
  47.             self.data.update({name:[total, entries]})
  48.         except:
  49.             self.data.update({name:[value, [[value, date, reason]]]})
  50.         BALANCE.table_send()
  51.  
  52.     def deleteEntry(self,name, id):
  53.         value = self.data[name][1][id][0]
  54.         self.data[name][1].pop(id)
  55.         self.inserItem(name, -value, None, None)
  56.         if len(self.data[name][1]) == 0:
  57.             self.data.pop(name)
  58.             return True
  59.         return False
  60. ############### GRAPHIC USER INTERFACE ###############
  61. class MainFrame(QtGui.QWidget):
  62.     """MainFrame Instance Class"""
  63.     def __init__(self):
  64.         QtGui.QWidget.__init__(self)
  65.         self.setupUi(self)
  66.  
  67.     def setupUi(self, MainFrame):
  68.         MainFrame.resize(533, 435)
  69.         MainFrame.setMaximumSize(QtCore.QSize(533, 435))
  70.         MainFrame.setMinimumSize(QtCore.QSize(533, 435))
  71.         MainFrame.setWindowTitle("ACCOUNT Balance")
  72.         MainFrame.setWindowIcon(QtGui.QIcon(QtGui.QPixmap("sync.ico")))
  73.  
  74.         self.tabsFrame = QtGui.QTabWidget(MainFrame)
  75.         self.tabsFrame.setGeometry(QtCore.QRect(0, 0, 541, 401))
  76.         self.i = 0
  77.         self.tabsFrame.currentChanged.connect(self.hidethings)
  78.  
  79.         self.BalanceTab = QtGui.QWidget()
  80.         self.tabsFrame.addTab(self.BalanceTab, "Balance")
  81.  
  82.         self.LoansTab = QtGui.QWidget()
  83.         self.tabsFrame.addTab(self.LoansTab, "Loans")
  84.  
  85.         self.BorrowsTab = QtGui.QWidget()
  86.         self.tabsFrame.addTab(self.BorrowsTab, "Borrows")
  87.  
  88.         self.tabsFrame.setCurrentIndex(0)
  89.  
  90.         self.label_balance = QtGui.QLabel(MainFrame)
  91.         self.label_balance.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
  92.         font = QtGui.QFont()
  93.         font.setPointSize(10)
  94.         font.setFamily(_fromUtf8("Batang"))
  95.         self.label_balance.setFont(font)
  96.         self.label_balance.setGeometry(QtCore.QRect(0, 410, 61, 16))
  97.         self.label_balance.setText("Balance:")
  98.  
  99.         self.box_balance = QtGui.QLineEdit(MainFrame)
  100.         self.box_balance.setDragEnabled(False)
  101.         self.box_balance.setFocusPolicy(QtCore.Qt.NoFocus)
  102.         self.box_balance.setFont(font)
  103.         self.box_balance.setGeometry(QtCore.QRect(65, 410, 71, 20))
  104.         self.box_balance.setMaximumSize(QtCore.QSize(461, 20))
  105.         self.box_balance.setMaxLength(75)
  106.         self.box_balance.setMinimumSize(QtCore.QSize(50, 20))
  107.         self.box_balance.setReadOnly(True)
  108.  
  109.     def hidethings(self, tab):
  110.         def hideBalance():
  111.             BALANCE.box_name.hide()
  112.             BALANCE.btn_rename.hide()
  113.             BALANCE.table_send2(None)
  114.             BALANCE.label_entrynum.setText("")
  115.             BALANCE.label_balancevalue.setText("")
  116.  
  117.         def hideLoans():
  118.             LOANS.box_name.setText("")
  119.             LOANS.box_date.setDate(QtCore.QDate.currentDate())
  120.             LOANS.box_value.setText("")
  121.             LOANS.box_reason.setText("")
  122.  
  123.         def hideBorrows():
  124.             BORROWS.box_name.setText("")
  125.             BORROWS.box_date.setDate(QtCore.QDate.currentDate())
  126.             BORROWS.box_value.setText("")
  127.             BORROWS.box_reason.setText("")
  128.  
  129.         if self.i != 0:
  130.             BALANCE.table_send()
  131.             if tab == 0:
  132.                 hideLoans()
  133.                 hideBorrows()
  134.             elif tab == 1:
  135.                 hideBalance()
  136.                 hideBorrows()
  137.             elif tab == 2:
  138.                 hideBalance()
  139.                 hideLoans()
  140.         else:
  141.             self.i += 1
  142.  
  143. class BalanceFrame(QtGui.QWidget):
  144.     """BalanceFrame Instance Class"""
  145.     def __init__(self, MainFrame):
  146.         QtGui.QWidget.__init__(self)
  147.         self.setupUi(MainFrame)
  148.  
  149.     def setupUi(self, MainFrame):
  150.         self.box_name = QtGui.QLineEdit(MainFrame.BalanceTab)
  151.         self.box_name.setGeometry(QtCore.QRect(230, 10, 113, 20))
  152.         self.box_name.hide()
  153.         # self.box_name.textChanged.connect(self.rename)
  154.  
  155.  
  156.         self.label_balance = QtGui.QLabel(MainFrame.BalanceTab)
  157.         self.label_balance.setGeometry(QtCore.QRect(180, 50, 46, 13))
  158.         self.label_balance.setText("Balance:")
  159.  
  160.         self.label_balancevalue = QtGui.QLabel(MainFrame.BalanceTab)
  161.         self.label_balancevalue.setGeometry(QtCore.QRect(225, 49, 100, 16))
  162.  
  163.         self.label_entries = QtGui.QLabel(MainFrame.BalanceTab)
  164.         self.label_entries.setGeometry(QtCore.QRect(180, 78, 100, 13))
  165.         self.label_entries.setText("Entries:")
  166.  
  167.         self.label_entrynum = QtGui.QLabel(MainFrame.BalanceTab)
  168.         self.label_entrynum.setGeometry(QtCore.QRect(220, 78, 20, 16))
  169.  
  170.         self.btn_rename = QtGui.QPushButton(MainFrame.BalanceTab)
  171.         self.btn_rename.setGeometry(QtCore.QRect(350, 10, 51, 23))
  172.         self.btn_rename.setText('Rename')
  173.         self.btn_rename.hide()
  174.         self.btn_rename.clicked.connect(self.rename)
  175.  
  176.         font = QtGui.QFont()
  177.         font.setPointSize(11)
  178.         self.label_name = QtGui.QLabel(MainFrame.BalanceTab)
  179.         self.label_name.setFont(font)
  180.         self.label_name.setGeometry(QtCore.QRect(180, 12, 61, 21))
  181.         self.label_name.setText("Name:")
  182.  
  183.         self.line_separator = QtGui.QFrame(MainFrame.BalanceTab)
  184.         self.line_separator.setFrameShadow(QtGui.QFrame.Sunken)
  185.         self.line_separator.setFrameShape(QtGui.QFrame.HLine)
  186.         self.line_separator.setGeometry(QtCore.QRect(160, 30, 371, 16))
  187.  
  188.         self.table_model = QtGui.QStandardItemModel(0,0)
  189.         self.table_name = QtGui.QTableView(MainFrame.BalanceTab)
  190.         self.table_name.horizontalHeader().setDefaultSectionSize(72)
  191.         self.table_name.horizontalHeader().setHighlightSections(False)
  192.         self.table_name.horizontalHeader().setSortIndicatorShown(False)
  193.         self.table_name.horizontalHeader().setStretchLastSection(True)
  194.         self.table_name.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
  195.         self.table_name.setGeometry(QtCore.QRect(10, 10, 151, 361))
  196.         self.table_name.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
  197.         self.table_name.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
  198.         self.table_name.setSortingEnabled(True)
  199.         self.table_name.verticalHeader().setCascadingSectionResizes(False)
  200.         self.table_name.verticalHeader().setDefaultSectionSize(20)
  201.         self.table_name.verticalHeader().setHighlightSections(True)
  202.         self.table_name.verticalHeader().setMinimumSectionSize(20)
  203.         self.table_name.setModel(self.table_model)
  204.         self.table_modelSelection = self.table_name.selectionModel()
  205.         self.table_modelSelection.selectionChanged.connect(self.selection)
  206.  
  207.         self.table_model2 = QtGui.QStandardItemModel(0, 0)
  208.         self.table_entries = QtGui.QTableView(MainFrame.BalanceTab)
  209.         self.table_entries.setGeometry(QtCore.QRect(180, 110, 341, 241))
  210.         self.table_entries.horizontalHeader().setStretchLastSection(True)
  211.         self.table_entries.verticalHeader().setVisible(False)
  212.         self.table_entries.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
  213.         self.table_entries.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
  214.         self.table_entries.setModel(self.table_model2)
  215.         self.table_entries.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
  216.         self.table_modelSelection2 = self.table_entries.selectionModel()
  217.         self.table_modelSelection2.selectionChanged.connect(self.selection2)
  218.  
  219.         self.btn_delentry = QtGui.QPushButton(MainFrame.BalanceTab)
  220.         self.btn_delentry.setGeometry(QtCore.QRect(450, 353, 71, 21))
  221.         self.btn_delentry.setText("Delete Entry")
  222.         self.btn_delentry.clicked.connect(self.delentry)
  223.  
  224.         self.name = None
  225.         self.entry = None
  226.  
  227.         self.table_send()
  228.  
  229.     def rename(self):
  230.         oldname = str(self.name)
  231.         newname = str(self.box_name.text())
  232.         ACCOUNT[newname] = ACCOUNT[oldname]
  233.         del ACCOUNT[oldname]
  234.         self.table_send()
  235.         self.table_send2(newname)
  236.  
  237.     def delentry(self):
  238.         if self.entry != None:
  239.             isEmpty = ACCOUNT.deleteEntry(self.name,self.entry)
  240.             if isEmpty == True:
  241.                 self.box_name.setText("")
  242.                 self.label_balancevalue.setText("")
  243.                 self.label_entrynum.setText("")
  244.                 self.table_send2(None)
  245.                 self.btn_rename.hide()
  246.                 self.box_name.hide()
  247.             else:
  248.                 self.label_balancevalue.setText("R$ %.2f" % ACCOUNT.data[self.name][0])
  249.                 self.label_entrynum.setText(str(len(ACCOUNT.data[self.name][1])))
  250.                 self.box_name.setText(self.name)
  251.                 self.table_send2(self.name)
  252.             self.table_send()
  253.  
  254.     def selection(self, selection):
  255.         self.name = str(selection.indexes()[0].data().toPyObject())
  256.         self.box_name.setText(self.name)
  257.         self.box_name.show()
  258.         def test():
  259.             self.btn_rename.show()
  260.         self.box_name.cursorPositionChanged.connect(test)
  261.         self.label_balancevalue.setText("R$ %.2f" % ACCOUNT.data[self.name][0])
  262.         self.label_entrynum.setText(str(len(ACCOUNT.data[self.name][1])))
  263.         self.table_send2(self.name)
  264.         self.btn_rename.hide()
  265.  
  266.     def selection2(self, selection, deselected):
  267.         self.entry = int(str(selection.indexes()[0].data().toPyObject())[2:])-1
  268.  
  269.     def table_send(self):
  270.         balance = 0
  271.         self.table_model.clear()
  272.         for i, n in enumerate(ACCOUNT.data):
  273.             balance += ACCOUNT.data[n][0]
  274.             self.table_model.insertRow(i,[QtGui.QStandardItem(str(n)),QtGui.QStandardItem("R$ %.2f"%(ACCOUNT.data[n][
  275.                                                                                                       0]))])
  276.             self.table_model.setHeaderData(i, QtCore.Qt.Vertical,str(n))
  277.         MAIN.box_balance.setText("R$ %.2f"%balance)
  278.         self.table_model.setHeaderData(0, QtCore.Qt.Horizontal, "Name")
  279.         self.table_model.setHeaderData(1, QtCore.Qt.Horizontal, "Balance")
  280.         self.table_name.verticalHeader().hide()
  281.  
  282.     def table_send2(self,name):
  283.         self.table_model2.clear()
  284.         if name != None:
  285.             self.table_entries.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
  286.             for i,items in enumerate(ACCOUNT.data[name][1]):
  287.                 entry = [QtGui.QStandardItem("  "+str(i+1))]
  288.                 for item in items:
  289.                     if isinstance(item,float):
  290.                         entry.append(QtGui.QStandardItem("  R$ %.2f  "%item))
  291.                     elif item == ACCOUNT.data[name][1][i][2]:
  292.                         entry.append(QtGui.QStandardItem(str(item) + "  "))
  293.                     else:
  294.                         entry.append(QtGui.QStandardItem("  "+str(item)+"  "))
  295.                 self.table_model2.insertRow(i,entry)
  296.             self.table_model2.setHeaderData(0, QtCore.Qt.Horizontal, "ID")
  297.             self.table_model2.setHeaderData(1, QtCore.Qt.Horizontal, "Value")
  298.             self.table_model2.setHeaderData(2, QtCore.Qt.Horizontal, "Date")
  299.             self.table_model2.setHeaderData(3, QtCore.Qt.Horizontal, "Reason")
  300.             self.table_entries.verticalHeader().hide()
  301.  
  302. class LoansFrame(QtGui.QWidget):
  303.     """LoansFrame Instance Class"""
  304.     def __init__(self, MainFrame):
  305.         QtGui.QWidget.__init__(self)
  306.         self.setupUi(MainFrame)
  307.  
  308.     def setupUi(self, MainFrame):
  309.         self.label_from = QtGui.QLabel(MainFrame.LoansTab)
  310.         self.label_from.setGeometry(QtCore.QRect(80, 110, 46, 13))
  311.         self.label_from.setText("From")
  312.  
  313.         self.box_name = QtGui.QLineEdit(MainFrame.LoansTab)
  314.         self.box_name.setFocusPolicy(QtCore.Qt.ClickFocus)
  315.         self.box_name.setGeometry(QtCore.QRect(130, 110, 113, 20))
  316.         self.box_name.setPlaceholderText("Enter Name...")
  317.  
  318.         self.label_date = QtGui.QLabel(MainFrame.LoansTab)
  319.         self.label_date.setGeometry(QtCore.QRect(80, 150, 46, 13))
  320.         self.label_date.setText("Date")
  321.  
  322.         self.box_date = QtGui.QDateEdit(MainFrame.LoansTab)
  323.         self.box_date.setFocusPolicy(QtCore.Qt.ClickFocus)
  324.         self.box_date.setGeometry(QtCore.QRect(130, 150, 113, 20))
  325.         self.box_date.setDate(QtCore.QDate.currentDate())
  326.         self.box_date.setCalendarPopup(True)
  327.  
  328.         self.label_value = QtGui.QLabel(MainFrame.LoansTab)
  329.         self.label_value.setGeometry(QtCore.QRect(80, 190, 46, 13))
  330.         self.label_value.setText("Value")
  331.  
  332.         self.box_value = QtGui.QLineEdit(MainFrame.LoansTab)
  333.         self.box_value.setGeometry(QtCore.QRect(130, 190, 113, 20))
  334.  
  335.         self.label_reason = QtGui.QLabel(MainFrame.LoansTab)
  336.         self.label_reason.setGeometry(QtCore.QRect(80, 260, 46, 13))
  337.         self.label_reason.setText("Reason")
  338.  
  339.         self.box_reason = QtGui.QLineEdit(MainFrame.LoansTab)
  340.         self.box_reason.setGeometry(QtCore.QRect(130, 260, 113, 20))
  341.  
  342.         self.btn_return = QtGui.QPushButton(MainFrame.LoansTab)
  343.         self.btn_return.setGeometry(QtCore.QRect(270, 130, 91, 23))
  344.         self.btn_return.setText("Register Return")
  345.  
  346.         self.btn_lend = QtGui.QPushButton(MainFrame.LoansTab)
  347.         self.btn_lend.setGeometry(QtCore.QRect(270, 260, 91, 23))
  348.         self.btn_lend.setText("Register Lend")
  349.  
  350. class BorrowsFrame(QtGui.QWidget):
  351.     """BorrowsFrame Instance Class"""
  352.     def __init__(self, MainFrame):
  353.         QtGui.QWidget.__init__(self)
  354.         self.setupUi(MainFrame)
  355.  
  356.     def setupUi(self, MainFrame):
  357.         self.label_from = QtGui.QLabel(MainFrame.BorrowsTab)
  358.         self.label_from.setGeometry(QtCore.QRect(80, 110, 46, 13))
  359.         self.label_from.setText("From")
  360.  
  361.         self.box_name = QtGui.QLineEdit(MainFrame.BorrowsTab)
  362.         self.box_name.setFocusPolicy(QtCore.Qt.ClickFocus)
  363.         self.box_name.setGeometry(QtCore.QRect(130, 110, 113, 20))
  364.         self.box_name.setPlaceholderText("Enter Name...")
  365.  
  366.         self.label_date = QtGui.QLabel(MainFrame.BorrowsTab)
  367.         self.label_date.setGeometry(QtCore.QRect(80, 150, 46, 13))
  368.         self.label_date.setText("Date")
  369.  
  370.         self.box_date = QtGui.QDateEdit(MainFrame.BorrowsTab)
  371.         self.box_date.setFocusPolicy(QtCore.Qt.ClickFocus)
  372.         self.box_date.setGeometry(QtCore.QRect(130, 150, 113, 20))
  373.         self.box_date.setDate(QtCore.QDate.currentDate())
  374.         self.box_date.setCalendarPopup(True)
  375.  
  376.         self.label_value = QtGui.QLabel(MainFrame.BorrowsTab)
  377.         self.label_value.setGeometry(QtCore.QRect(80, 190, 46, 13))
  378.         self.label_value.setText("Value")
  379.  
  380.         self.box_value = QtGui.QLineEdit(MainFrame.BorrowsTab)
  381.         self.box_value.setGeometry(QtCore.QRect(130, 190, 113, 20))
  382.  
  383.         self.label_reason = QtGui.QLabel(MainFrame.BorrowsTab)
  384.         self.label_reason.setGeometry(QtCore.QRect(80, 260, 46, 13))
  385.         self.label_reason.setText("Reason")
  386.  
  387.         self.box_reason = QtGui.QLineEdit(MainFrame.BorrowsTab)
  388.         self.box_reason.setGeometry(QtCore.QRect(130, 260, 113, 20))
  389.  
  390.         self.btn_return = QtGui.QPushButton(MainFrame.BorrowsTab)
  391.         self.btn_return.setGeometry(QtCore.QRect(270, 130, 91, 23))
  392.         self.btn_return.setText("Register Return")
  393.  
  394.         self.btn_borrow = QtGui.QPushButton(MainFrame.BorrowsTab)
  395.         self.btn_borrow.setGeometry(QtCore.QRect(270, 260, 91, 23))
  396.         self.btn_borrow.setText("Register Borrow")
  397.  
  398. class PopUp(QtGui.QWidget):
  399.     """PopUp Instance Class"""
  400.     def __init__(self, MainFrame, BalanceFrame, LoansFrame, BorrowsFrame):
  401.         QtGui.QWidget.__init__(self)
  402.         self.setupUi(MainFrame, BalanceFrame, LoansFrame, BorrowsFrame)
  403.  
  404.     def setupUi(self, MainFrame, BalanceFrame, LoansFrame, BorrowsFrame):
  405.         self.table_names = QtCore.QStringList()
  406.  
  407.         self.createCompleter(LoansFrame, BorrowsFrame)
  408.  
  409.         self.connections(MainFrame, BalanceFrame, LoansFrame, BorrowsFrame)
  410.  
  411.     def createCompleter(self, LoansFrame, BorrowsFrame):
  412.         self.table_names = self.suggestions()
  413.         self.completer = QtGui.QCompleter(self.table_names)
  414.         self.regex = QtCore.QRegExp("^(d\.(?:\d\.)?\d{1,3})|((?:\d\.)?\d{1,3}),\d{2}$")
  415.  
  416.         self.loansvalidator = QtGui.QRegExpValidator(self.regex, LoansFrame.box_value)
  417.         LoansFrame.box_name.setCompleter(self.completer)
  418.         LoansFrame.box_value.setValidator(self.loansvalidator)
  419.  
  420.         self.borrowsvalidator = QtGui.QRegExpValidator(self.regex, BorrowsFrame.box_value)
  421.         BorrowsFrame.box_name.setCompleter(self.completer)
  422.         BorrowsFrame.box_value.setValidator(self.borrowsvalidator)
  423.  
  424.     def connections(self, MainFrame, BalanceFrame, LoansFrame, BorrowsFrame):
  425.         QtCore.QObject.connect(LoansFrame.box_name, QtCore.SIGNAL(("textChanged(QString)")), lambda:self.suggestions(MainFrame, BalanceFrame, LoansFrame, BorrowsFrame))
  426.         QtCore.QObject.connect(BorrowsFrame.box_name, QtCore.SIGNAL(("textEdited(QString)")), lambda:self.suggestions(MainFrame, BalanceFrame, LoansFrame, BorrowsFrame))
  427.  
  428.         LoansFrame.box_value.editingFinished.connect(lambda:LoansFrame.box_value.setText('R$ %s' % (LoansFrame.box_value.text())))
  429.         BorrowsFrame.box_value.editingFinished.connect(lambda:BorrowsFrame.box_value.setText('R$ %s' % (BorrowsFrame.box_value.text())))
  430.  
  431.         LoansFrame.btn_return.clicked.connect(lambda:self.addEntry(LoansFrame, "return"))
  432.         LoansFrame.btn_lend.clicked.connect(lambda:self.addEntry(LoansFrame))
  433.  
  434.         BorrowsFrame.btn_return.clicked.connect(lambda:self.addEntry(BorrowsFrame, "return"))
  435.         BorrowsFrame.btn_borrow.clicked.connect(lambda:self.addEntry(BorrowsFrame))
  436.  
  437.     @staticmethod
  438.     def addEntry(Frame, *returning):
  439.         name = str(Frame.box_name.text())
  440.         date = str(Frame.box_date.text())
  441.         value = float(str(Frame.box_value.text()).strip("R$ ").replace(".", "").replace(",", "."))
  442.         reason = str(Frame.box_reason.text())
  443.         if returning:
  444.             reason = "Return"
  445.             value *= -1
  446.         if str(Frame)[10:].split('Frame')[0] == "Loans":
  447.             ACCOUNT.inserItem(name, value, date, reason)
  448.         else:
  449.             ACCOUNT.inserItem(name, -value, date, reason)
  450.  
  451.     def suggestions(self, *args):
  452.         list = self.table_names
  453.         [list.append(i) for i in ACCOUNT.data]
  454.         return list
  455.  
  456. if __name__ == "__main__":
  457.     app = QtGui.QApplication(sys.argv)
  458.     try:
  459.         acc = pickle.load(open("personal_account.p", "rb"))
  460.         ACCOUNT = Account()
  461.         MAIN = MainFrame()
  462.         BALANCE = BalanceFrame(MAIN)
  463.         LOANS = LoansFrame(MAIN)
  464.         BORROWS = BorrowsFrame(MAIN)
  465.         POPUP = PopUp(MAIN, BALANCE, LOANS, BORROWS)
  466.         MAIN.show()
  467.  
  468.         sys.exit(app.exec_())
  469.     finally:
  470.         pickle.dump(ACCOUNT.data, open("personal_account.p", "wb"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement