Beispiel #1
0
    def CreateOrEdit(self, row_data, checkbox = None):
        'Create or edit an exception for the account.'

        account = row_data
        accountstr = acct_reduce(account)

        # If SAVE is clicked, update this control's exception list.

        # Is there already an exception here?
        if accountstr in self.exceptions:
            diag = StatusDialog.edit(self, self.exceptions[accountstr], is_exception = account,
                                     modal = True)
        else:
            # No, create one.
            diag = StatusDialog.new(self, is_exception = account,
                                    modal = True)

        with diag:
            returncode = diag.ReturnCode
            if returncode == wx.ID_SAVE:
                exception = StatusMessageException(**diag.info())
                self.exceptions[accountstr] = exception
            elif checkbox != None and returncode == wx.ID_CANCEL:
                checkbox.Value = False
                self.OnDelete(row_data)



        self.update_data(self.exceptions)

        self.Refresh()

        return returncode
Beispiel #2
0
    def Exceptions(self):
        'Returns exceptions which are checked.'

        excs = []
        for i, acct in enumerate(self.accounts):
            acctstr = acct_reduce(acct)
            if self.exceptions.get(acctstr, None) is not None:
                excs.append((acctstr, self.exceptions[acctstr]))
        return dict(excs)
Beispiel #3
0
    def update_data(self, exceptions):
        'Given {account: exception}, update the table.'

        for i, account in enumerate(self.accounts):
            row = self.GetRow(i)
            if row is None:
                continue

            exception_msg = exceptions.get(acct_reduce(row.account), None)
            if exception_msg is not None:
                row.status_msg = exception_msg


            row.PopulateControls(account)

        self.Layout()
Beispiel #4
0
 def OnDelete(self, data):
     self.exceptions.pop(acct_reduce(data), None)
     self.update_data(self.exceptions)
     self.Refresh()
Beispiel #5
0
    def __init__(self, parent, data):
        self.account = data
        self.status_msg = parent.exceptions.get(acct_reduce(self.account), None)

        AnyRow.__init__(self, parent = parent, data = data, use_checkbox = True)
        self.text = self.account.name