def print_history(self): width = [20, 40, 14, 14] delta = (80 - sum(width) - 4) / 3 format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%" \ + "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s" messages = [] for item in self.wallet.get_history(): tx_hash, height, conf, timestamp, delta, balance = item if conf: try: time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3] except Exception: time_str = "unknown" else: time_str = 'unconfirmed' label = self.wallet.get_label(tx_hash) messages.append( format_str % (time_str, label, format_satoshis(delta, whitespaces=True), format_satoshis(balance, whitespaces=True))) self.print_list( messages[::-1], format_str % (_("Date"), _("Description"), _("Amount"), _("Balance")))
def data(self, index, role=Qt.DisplayRole): data = None if not index.isValid(): return QVariant(data) if role not in [ Qt.DisplayRole, Qt.EditRole, Qt.ToolTipRole, Qt.FontRole, Qt.BackgroundRole ]: return None rw = self.smartrewards[index.row()] i = index.column() if i == self.LABEL: data = rw.label elif i == self.ADDRRESS: data = rw.address elif i == self.AMOUNT: data = '{} SMART'.format( self.manager.add_thousands_spaces(format_satoshis(rw.amount))) elif i == self.ELIGIBLE_AMOUNT: data = '{} SMART'.format(rw.eligible_amount) elif i == self.ESTIMATED_REWARD: data = '{} SMART'.format(rw.estimated_reward) return QVariant(data)
def update_history(self): width = [20, 40, 14, 14] delta = (self.maxx - sum(width) - 4)/3 format_str = "%"+"%d"%width[0]+"s"+"%"+"%d"%(width[1]+delta)+"s"+"%"+"%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s" b = 0 self.history = [] for item in self.wallet.get_history(): tx_hash, height, conf, timestamp, value, balance = item if conf: try: time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] except Exception: time_str = "------" else: time_str = 'unconfirmed' label = self.wallet.get_label(tx_hash) if len(label) > 40: label = label[0:37] + '...' self.history.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) )
def format_amount(self, x, is_diff=False, whitespaces=False): return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces)