def qr_input(self): from electrum_doged import qrscanner, get_config try: data = qrscanner.scan_qr(get_config()) except BaseException, e: QMessageBox.warning(self, _('Error'), _(e), _('OK')) return ""
def before_send(self): ''' Change URL to address before making a send. IMPORTANT: return False to continue execution of the send return True to stop execution of the send ''' if self.win.payto_e.is_multiline( ): # only supports single line entries atm return False if self.win.payto_e.is_pr: return payto_e = str(self.win.payto_e.toPlainText()) regex = re.compile(r'^([^\s]+) <([A-Za-z0-9]+)>' ) # only do that for converted addresses try: (url, address) = regex.search(payto_e).groups() except AttributeError: return False if not self.validated: msgBox = QMessageBox() msgBox.setText( _('WARNING: the address ' + address + ' could not be validated via an additional security check, DNSSEC, and thus may not be correct.' )) msgBox.setInformativeText(_('Do you wish to continue?')) msgBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) msgBox.setDefaultButton(QMessageBox.Cancel) reply = msgBox.exec_() if reply != QMessageBox.Ok: return True return False
def before_send(self): ''' Change URL to address before making a send. IMPORTANT: return False to continue execution of the send return True to stop execution of the send ''' if self.win.payto_e.is_multiline(): # only supports single line entries atm return False if self.win.payto_e.is_pr: return payto_e = str(self.win.payto_e.toPlainText()) regex = re.compile(r'^([^\s]+) <([A-Za-z0-9]+)>') # only do that for converted addresses try: (url, address) = regex.search(payto_e).groups() except AttributeError: return False if not self.validated: msgBox = QMessageBox() msgBox.setText(_('WARNING: the address ' + address + ' could not be validated via an additional security check, DNSSEC, and thus may not be correct.')) msgBox.setInformativeText(_('Do you wish to continue?')) msgBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) msgBox.setDefaultButton(QMessageBox.Cancel) reply = msgBox.exec_() if reply != QMessageBox.Ok: return True return False
def __init__(self, address, parent): self.address = address self.parent = parent self.config = parent.config self.wallet = parent.wallet self.app = parent.app self.saved = True QDialog.__init__(self) self.setMinimumWidth(700) self.setWindowTitle(_("Address")) self.setModal(1) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Address:"))) self.addr_e = ButtonsLineEdit(self.address) self.addr_e.addCopyButton(self.app) self.addr_e.addButton(":icons/qrcode.png", self.show_qr, _("Show QR Code")) self.addr_e.setReadOnly(True) vbox.addWidget(self.addr_e) vbox.addWidget(QLabel(_("History"))) self.hw = HistoryWidget(self.parent) vbox.addWidget(self.hw) vbox.addStretch(1) vbox.addLayout(Buttons(CloseButton(self))) self.format_amount = self.parent.format_amount h = self.wallet.get_history([self.address]) self.hw.update(h)
def build_tray_menu(self): m = QMenu() m.addAction(_("Show/Hide"), self.show_or_hide) m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Electrum-DOGED"), self.close) self.tray.setContextMenu(m)
def __init__(self, transaction_id, parent): super(TransactionWindow, self).__init__() self.tx_id = str(transaction_id) self.parent = parent self.setModal(True) self.resize(200, 100) self.setWindowTitle(_("Transaction successfully sent")) self.layout = QGridLayout(self) history_label = "%s\n%s" % ( _("Your transaction has been sent."), _("Please enter a label for this transaction for future reference." )) self.layout.addWidget(QLabel(history_label)) self.label_edit = QLineEdit() self.label_edit.setPlaceholderText(_("Transaction label")) self.label_edit.setObjectName("label_input") self.label_edit.setAttribute(Qt.WA_MacShowFocusRect, 0) self.label_edit.setFocusPolicy(Qt.ClickFocus) self.layout.addWidget(self.label_edit) self.save_button = QPushButton(_("Save")) self.layout.addWidget(self.save_button) self.save_button.clicked.connect(self.set_label) self.exec_()
def mouseReleaseEvent(self, event): dialog = QDialog(self) dialog.setWindowTitle(_('Electrum update')) dialog.setModal(1) main_layout = QGridLayout() main_layout.addWidget(QLabel(_("A new version of Electrum is available:")+" " + self.latest_version), 0,0,1,3) ignore_version = QPushButton(_("Ignore this version")) ignore_version.clicked.connect(self.ignore_this_version) ignore_all_versions = QPushButton(_("Ignore all versions")) ignore_all_versions.clicked.connect(self.ignore_all_version) open_website = QPushButton(_("Goto download page")) open_website.clicked.connect(self.open_website) main_layout.addWidget(ignore_version, 1, 0) main_layout.addWidget(ignore_all_versions, 1, 1) main_layout.addWidget(open_website, 1, 2) dialog.setLayout(main_layout) self.dialog = dialog if not dialog.exec_(): return
def on_change_hist(checked): if checked: self.config.set_key('history_rates', 'checked') self.request_history_rates() else: self.config.set_key('history_rates', 'unchecked') self.win.history_list.setHeaderLabels( [ '', _('Date'), _('Description') , _('Amount'), _('Balance')] ) self.win.history_list.setColumnCount(5)
def load_wallet(self, wallet): if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your BTChip device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("BTChip device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def save(self): name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.parent.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn") if fileName: with open(fileName, "w+") as f: f.write(json.dumps(self.tx.as_dict(),indent=4) + '\n') self.show_message(_("Transaction saved successfully")) self.saved = True
def close(self): if not self.saved: if QMessageBox.question( self, _('Message'), _('This transaction is not saved. Close anyway?'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.No: return self.done(0)
def give_error(self, message, clear_client=False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def __init__(self, parent=None): MyTreeWidget.__init__( self, parent, self.create_menu, ['', _('Date'), _('Description'), _('Amount'), _('Balance')], 2) self.config = self.parent.config self.setSortingEnabled(False)
def verify_seed(self, seed, sid, func=None): r = self.enter_seed_dialog(MSG_VERIFY_SEED, sid, func) if not r: return if prepare_seed(r) != prepare_seed(seed): QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK')) return False else: return True
def give_error(self, message, clear_client = False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'btchip': return wallet = BTChipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def export_history_dialog(self, d, hbox): self.wallet = d.wallet history = self.wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(self.wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def ok_cancel_buttons(dialog): row_layout = QHBoxLayout() row_layout.addStretch(1) ok_button = QPushButton(_("OK")) row_layout.addWidget(ok_button) ok_button.clicked.connect(dialog.accept) cancel_button = QPushButton(_("Cancel")) row_layout.addWidget(cancel_button) cancel_button.clicked.connect(dialog.reject) return row_layout
def __init__(self, parent, seed, imported_keys): QDialog.__init__(self, parent) self.setModal(1) self.setMinimumWidth(400) self.setWindowTitle('Electrum' + ' - ' + _('Seed')) vbox = show_seed_box_msg(seed) if imported_keys: vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>")) vbox.addLayout(Buttons(CloseButton(self))) self.setLayout(vbox)
def save(self): name = 'signed_%s.txn' % ( self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.parent.getSaveFileName( _("Select where to save your signed transaction"), name, "*.txn") if fileName: with open(fileName, "w+") as f: f.write(json.dumps(self.tx.as_dict(), indent=4) + '\n') self.show_message(_("Transaction saved successfully")) self.saved = True
def export_history_dialog(self, d,hbox): self.wallet = d.wallet history = self.wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(self.wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def append(self, address, amount, date): if address is None: address = _("Unknown") if amount is None: amount = _("Unknown") if date is None: date = _("Unknown") item = QTreeWidgetItem([amount, address, date]) if amount.find("-") != -1: item.setForeground(0, QBrush(QColor("#BC1E1E"))) self.insertTopLevelItem(0, item)
def __init__(self, owner=None): self.owner = owner self.editing = False QTreeWidget.__init__(self, owner) self.setColumnCount(3) self.setHeaderLabels([_("Address"), _("Label"), _("Used")]) self.setIndentation(0) self.hide_used = True self.setColumnHidden(2, True)
def append(self, address, amount, date): if address is None: address = _("Unknown") if amount is None: amount = _("Unknown") if date is None: date = _("Unknown") item = QTreeWidgetItem([amount, address, date]) if amount.find('-') != -1: item.setForeground(0, QBrush(QColor("#BC1E1E"))) self.insertTopLevelItem(0, item)
def restore_or_create(self): vbox = QVBoxLayout() main_label = QLabel(_("Electrum could not find an existing wallet.")) vbox.addWidget(main_label) grid = QGridLayout() grid.setSpacing(5) gb1 = QGroupBox(_("What do you want to do?")) vbox.addWidget(gb1) b1 = QRadioButton(gb1) b1.setText(_("Create new wallet")) b1.setChecked(True) b2 = QRadioButton(gb1) b2.setText(_("Restore a wallet or import keys")) group1 = QButtonGroup() group1.addButton(b1) group1.addButton(b2) vbox.addWidget(b1) vbox.addWidget(b2) gb2 = QGroupBox(_("Wallet type:")) vbox.addWidget(gb2) group2 = QButtonGroup() self.wallet_types = [ ('standard', _("Standard wallet")), ('twofactor', _("Wallet with two-factor authentication")), ('multisig', _("Multi-signature wallet")), ('hardware', _("Hardware wallet")), ] for i, (wtype, name) in enumerate(self.wallet_types): if not filter(lambda x: x[0] == wtype, electrum.wallet.wallet_types): continue button = QRadioButton(gb2) button.setText(name) vbox.addWidget(button) group2.addButton(button) group2.setId(button, i) if i == 0: button.setChecked(True) vbox.addStretch(1) self.set_layout(vbox) vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next')))) self.show() self.raise_() if not self.exec_(): return None, None action = 'create' if b1.isChecked() else 'restore' wallet_type = self.wallet_types[group2.checkedId()][0] return action, wallet_type
def show_seed_box_msg(seedphrase, sid=None): msg = _("Your wallet generation seed is") + ":" vbox = show_seed_box(msg, seedphrase, sid) save_msg = _("Please save these %d words on paper (order is important).")%len(seedphrase.split()) + " " msg2 = save_msg + " " \ + _("This seed will allow you to recover your wallet in case of computer failure.") + "<br/>" \ + "<b>"+_("WARNING")+":</b> " + _("Never disclose your seed. Never type it on a website.") + "</b><p>" label2 = QLabel(msg2) label2.setWordWrap(True) vbox.addWidget(label2) vbox.addStretch(1) return vbox
def close(self): self.d.accept() if self.error: QMessageBox.warning(self.parent, _('Error'), self.error, _('OK')) else: if self.on_success: if type(self.result) is not tuple: self.result = (self.result,) self.on_success(*self.result) if self.on_complete: self.on_complete()
def add_io(self, vbox): if self.tx.locktime > 0: vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime)) vbox.addWidget(QLabel(_("Inputs"))) ext = QTextCharFormat() own = QTextCharFormat() own.setBackground(QBrush(QColor("lightgreen"))) own.setToolTip(_("Own address")) i_text = QTextEdit() i_text.setFont(QFont(MONOSPACE_FONT)) i_text.setReadOnly(True) i_text.setMaximumHeight(100) cursor = i_text.textCursor() for x in self.tx.inputs: if x.get('is_coinbase'): cursor.insertText('coinbase') else: prevout_hash = x.get('prevout_hash') prevout_n = x.get('prevout_n') cursor.insertText( prevout_hash[0:8] + '...' + prevout_hash[-8:] + ":%d" % prevout_n, ext) cursor.insertText('\t') addr = x.get('address') if addr == "(pubkey)": _addr = self.wallet.find_pay_to_pubkey_address( prevout_hash, prevout_n) if _addr: addr = _addr if addr is None: addr = _('unknown') cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) cursor.insertBlock() vbox.addWidget(i_text) vbox.addWidget(QLabel(_("Outputs"))) o_text = QTextEdit() o_text.setFont(QFont(MONOSPACE_FONT)) o_text.setReadOnly(True) o_text.setMaximumHeight(100) cursor = o_text.textCursor() for addr, v in self.tx.get_outputs(): cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) if v is not None: cursor.insertText('\t', ext) cursor.insertText(self.parent.format_amount(v), ext) cursor.insertBlock() vbox.addWidget(o_text)
def restore_or_create(self): vbox = QVBoxLayout() main_label = QLabel(_("Electrum could not find an existing wallet.")) vbox.addWidget(main_label) grid = QGridLayout() grid.setSpacing(5) gb1 = QGroupBox(_("What do you want to do?")) vbox.addWidget(gb1) b1 = QRadioButton(gb1) b1.setText(_("Create new wallet")) b1.setChecked(True) b2 = QRadioButton(gb1) b2.setText(_("Restore a wallet or import keys")) group1 = QButtonGroup() group1.addButton(b1) group1.addButton(b2) vbox.addWidget(b1) vbox.addWidget(b2) gb2 = QGroupBox(_("Wallet type:")) vbox.addWidget(gb2) group2 = QButtonGroup() self.wallet_types = [ ('standard', _("Standard wallet")), ('twofactor', _("Wallet with two-factor authentication")), ('multisig', _("Multi-signature wallet")), ('hardware', _("Hardware wallet")), ] for i, (wtype,name) in enumerate(self.wallet_types): if not filter(lambda x:x[0]==wtype, electrum.wallet.wallet_types): continue button = QRadioButton(gb2) button.setText(name) vbox.addWidget(button) group2.addButton(button) group2.setId(button, i) if i==0: button.setChecked(True) vbox.addStretch(1) self.set_layout(vbox) vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next')))) self.show() self.raise_() if not self.exec_(): return None, None action = 'create' if b1.isChecked() else 'restore' wallet_type = self.wallet_types[group2.checkedId()][0] return action, wallet_type
def show_seed_box_msg(seedphrase, sid=None): msg = _("Your wallet generation seed is") + ":" vbox = show_seed_box(msg, seedphrase, sid) save_msg = _("Please save these %d words on paper (order is important)." ) % len(seedphrase.split()) + " " msg2 = save_msg + " " \ + _("This seed will allow you to recover your wallet in case of computer failure.") + "<br/>" \ + "<b>"+_("WARNING")+":</b> " + _("Never disclose your seed. Never type it on a website.") + "</b><p>" label2 = QLabel(msg2) label2.setWordWrap(True) vbox.addWidget(label2) vbox.addStretch(1) return vbox
def __init__(self, parent, seed, imported_keys): QDialog.__init__(self, parent) self.setModal(1) self.setMinimumWidth(400) self.setWindowTitle('Electrum' + ' - ' + _('Seed')) vbox = show_seed_box_msg(seed) if imported_keys: vbox.addWidget( QLabel("<b>" + _("WARNING") + ":</b> " + _( "Your wallet contains imported keys. These keys cannot be recovered from seed." ) + "</b><p>")) vbox.addLayout(Buttons(CloseButton(self))) self.setLayout(vbox)
def run_wizard(self, storage, action): import installwizard if storage.file_exists and action != 'new': msg = _("The file '%s' contains an incompletely created wallet.")%storage.path + '\n'\ + _("Do you want to complete its creation now?") if not util.question(msg): if util.question( _("Do you want to delete '%s'?") % storage.path): os.remove(storage.path) QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK')) return return wizard = installwizard.InstallWizard(self.config, self.network, storage) wizard.show() if action == 'new': action, wallet_type = wizard.restore_or_create() else: wallet_type = None try: wallet = wizard.run(action, wallet_type) except BaseException as e: traceback.print_exc(file=sys.stdout) QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def on_change_hist(checked): if checked: self.config.set_key('history_rates', 'checked') self.request_history_rates() else: self.config.set_key('history_rates', 'unchecked') self.win.history_list.setHeaderLabels([ '', _('Date'), _('Description'), _('Amount'), _('Balance') ]) self.win.history_list.setColumnCount(5)
def passphrase_dialog(self): from electrum_doged_gui.qt.password_dialog import make_password_dialog, run_password_dialog d = QDialog() d.setModal(1) d.setLayout(make_password_dialog(d, None, self.message, False)) confirmed, p, passphrase = run_password_dialog(d, None, None) if not confirmed: QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) self.passphrase = None else: if passphrase is None: passphrase = '' # Even blank string is valid Trezor passphrase self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) self.done.set()
def add_io(self, vbox): if self.tx.locktime > 0: vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime)) vbox.addWidget(QLabel(_("Inputs"))) ext = QTextCharFormat() own = QTextCharFormat() own.setBackground(QBrush(QColor("lightgreen"))) own.setToolTip(_("Own address")) i_text = QTextEdit() i_text.setFont(QFont(MONOSPACE_FONT)) i_text.setReadOnly(True) i_text.setMaximumHeight(100) cursor = i_text.textCursor() for x in self.tx.inputs: if x.get('is_coinbase'): cursor.insertText('coinbase') else: prevout_hash = x.get('prevout_hash') prevout_n = x.get('prevout_n') cursor.insertText(prevout_hash[0:8] + '...' + prevout_hash[-8:] + ":%d"%prevout_n, ext) cursor.insertText('\t') addr = x.get('address') if addr == "(pubkey)": _addr = self.wallet.find_pay_to_pubkey_address(prevout_hash, prevout_n) if _addr: addr = _addr if addr is None: addr = _('unknown') cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) cursor.insertBlock() vbox.addWidget(i_text) vbox.addWidget(QLabel(_("Outputs"))) o_text = QTextEdit() o_text.setFont(QFont(MONOSPACE_FONT)) o_text.setReadOnly(True) o_text.setMaximumHeight(100) cursor = o_text.textCursor() for addr, v in self.tx.get_outputs(): cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) if v is not None: cursor.insertText('\t', ext) cursor.insertText(self.parent.format_amount(v), ext) cursor.insertBlock() vbox.addWidget(o_text)
def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None): vbox = QVBoxLayout() self.set_layout(vbox) if icon: logo = QLabel() logo.setPixmap(icon) vbox.addWidget(logo) label = QLabel(msg) label.setWordWrap(True) vbox.addWidget(label) vbox.addStretch(1) vbox.addLayout(Buttons(CancelButton(self, no_label), OkButton(self, yes_label))) if not self.exec_(): return None return True
def setup(self, address): label = QLabel(_("Copied your DogecoinDark address to the clipboard!")) address_display = QLineEdit(address) address_display.setReadOnly(True) resize_line_edit_width(address_display, address) main_layout = QVBoxLayout(self) main_layout.addWidget(label) main_layout.addWidget(address_display) self.setMouseTracking(True) self.setWindowTitle("Electrum - " + _("Receive DogecoinDark payment")) self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.MSWindowsFixedSizeDialogHint) self.layout().setSizeConstraint(QLayout.SetFixedSize)
def on_receive(self): if self.wallet.use_encryption: password = self.win.password_dialog('An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.') if not password: return else: password = None if not self.win.question(_("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?")): return message = self.listener.message key = self.listener.keyname xprv = self.wallet.get_master_private_key(key, password) if not xprv: return try: k = bitcoin.deserialize_xkey(xprv)[-1].encode('hex') EC = bitcoin.EC_KEY(k.decode('hex')) message = EC.decrypt_message(message) except Exception as e: traceback.print_exc(file=sys.stdout) self.win.show_message(str(e)) return self.listener.clear() tx = transaction.Transaction(message) d = transaction_dialog.TxDialog(tx, self.win) d.saved = False d.exec_()
def password_dialog(self, pw, grid, pos): vkb_button = QPushButton(_("+")) vkb_button.setFixedWidth(20) vkb_button.clicked.connect(lambda: self.toggle_vkb(grid, pw)) grid.addWidget(vkb_button, pos, 2) self.kb_pos = 2 self.vkb = None
def __init__(self, win): QWidget.__init__(self) self.win = win self.setWindowTitle('Electrum - ' + _('Payment Request')) self.setMinimumSize(800, 250) self.address = '' self.label = '' self.amount = 0 self.setFocusPolicy(QtCore.Qt.NoFocus) main_box = QHBoxLayout() self.qrw = QRCodeWidget() main_box.addWidget(self.qrw, 1) vbox = QVBoxLayout() main_box.addLayout(vbox) self.address_label = QLabel("") #self.address_label.setFont(QFont(MONOSPACE_FONT)) vbox.addWidget(self.address_label) self.label_label = QLabel("") vbox.addWidget(self.label_label) self.amount_label = QLabel("") vbox.addWidget(self.amount_label) vbox.addStretch(1) self.setLayout(main_box)
def on_receive(self): if self.wallet.use_encryption: password = self.win.password_dialog( 'An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.' ) if not password: return else: password = None if not self.win.question( _("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?" )): return message = self.listener.message key = self.listener.keyname xprv = self.wallet.get_master_private_key(key, password) if not xprv: return try: k = bitcoin.deserialize_xkey(xprv)[-1].encode('hex') EC = bitcoin.EC_KEY(k.decode('hex')) message = EC.decrypt_message(message) except Exception as e: traceback.print_exc(file=sys.stdout) self.win.show_message(str(e)) return self.listener.clear() tx = transaction.Transaction(message) d = transaction_dialog.TxDialog(tx, self.win) d.saved = False d.exec_()
def show_text_edit(self, parent): def handler(): blob = str(parent.toPlainText()) self.sender = self._send(parent=parent, blob=blob) self.sender.start() parent.addButton(':icons/speaker.png', handler, _("Send to speaker"))
def __init__(self, win): QWidget.__init__(self) self.win = win self.setWindowTitle('Electrum - '+_('Payment Request')) self.setMinimumSize(800, 250) self.address = '' self.label = '' self.amount = 0 self.setFocusPolicy(QtCore.Qt.NoFocus) main_box = QHBoxLayout() self.qrw = QRCodeWidget() main_box.addWidget(self.qrw, 1) vbox = QVBoxLayout() main_box.addLayout(vbox) self.address_label = QLabel("") #self.address_label.setFont(QFont(MONOSPACE_FONT)) vbox.addWidget(self.address_label) self.label_label = QLabel("") vbox.addWidget(self.label_label) self.amount_label = QLabel("") vbox.addWidget(self.amount_label) vbox.addStretch(1) self.setLayout(main_box)
def __init__(self, change_quote_currency, parent=None): super(QLabel, self).__init__(_("Connecting..."), parent) self.change_quote_currency = change_quote_currency self.state = self.SHOW_CONNECTING self.balance_text = "" self.amount_text = "" self.parent = parent
def create_menu(self, position): self.selectedIndexes() item = self.currentItem() if not item: return tx_hash = str(item.data(0, Qt.UserRole).toString()) if not tx_hash: return tx_URL = block_explorer_URL(self.config, 'tx', tx_hash) if not tx_URL: return menu = QMenu() menu.addAction(_("Copy ID to Clipboard"), lambda: self.parent.app.clipboard().setText(tx_hash)) menu.addAction(_("Details"), lambda: self.parent.show_transaction(self.wallet.transactions.get(tx_hash))) menu.addAction(_("Edit description"), lambda: self.edit_label(item)) menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL)) menu.exec_(self.viewport().mapToGlobal(position))
def __init__(self, tx, parent): self.tx = tx tx_dict = tx.as_dict() self.parent = parent self.wallet = parent.wallet self.saved = True QDialog.__init__(self) self.setMinimumWidth(600) self.setWindowTitle(_("Transaction")) self.setModal(1) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Transaction ID:"))) self.tx_hash_e = ButtonsLineEdit() qr_show = lambda: self.parent.show_qrcode(str(self.tx_hash_e.text()), 'Transaction ID') self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code")) self.tx_hash_e.setReadOnly(True) vbox.addWidget(self.tx_hash_e) self.status_label = QLabel() vbox.addWidget(self.status_label) self.date_label = QLabel() vbox.addWidget(self.date_label) self.amount_label = QLabel() vbox.addWidget(self.amount_label) self.fee_label = QLabel() vbox.addWidget(self.fee_label) self.add_io(vbox) vbox.addStretch(1) self.sign_button = b = QPushButton(_("Sign")) b.clicked.connect(self.sign) self.broadcast_button = b = QPushButton(_("Broadcast")) b.clicked.connect(self.do_broadcast) b.hide() self.save_button = b = QPushButton(_("Save")) b.clicked.connect(self.save) self.cancel_button = b = QPushButton(_("Close")) b.clicked.connect(self.close) b.setDefault(True) self.qr_button = b = QPushButton() b.setIcon(QIcon(":icons/qrcode.png")) b.clicked.connect(self.show_qr) self.copy_button = CopyButton(lambda: str(self.tx), self.parent.app) self.buttons = [self.copy_button, self.qr_button, self.sign_button, self.broadcast_button, self.save_button, self.cancel_button] run_hook('transaction_dialog', self) vbox.addLayout(Buttons(*self.buttons)) self.update()
def network_dialog(self): # skip this if config already exists if self.config.get('server') is not None: return grid = QGridLayout() grid.setSpacing(5) label = QLabel(_("Electrum communicates with remote servers to get information about your transactions and addresses. The servers all fulfil the same purpose only differing in hardware. In most cases you simply want to let Electrum pick one at random if you have a preference though feel free to select a server manually.") + "\n\n" \ + _("How do you want to connect to a server:")+" ") label.setWordWrap(True) grid.addWidget(label, 0, 0) gb = QGroupBox() b1 = QRadioButton(gb) b1.setText(_("Auto connect")) b1.setChecked(True) b2 = QRadioButton(gb) b2.setText(_("Select server manually")) #b3 = QRadioButton(gb) #b3.setText(_("Stay offline")) grid.addWidget(b1,1,0) grid.addWidget(b2,2,0) #grid.addWidget(b3,3,0) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addStretch(1) vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next')))) self.set_layout(vbox) if not self.exec_(): return if b2.isChecked(): return NetworkDialog(self.network, self.config, None).do_exec() else: self.config.set_key('auto_cycle', True, True) return
def __init__(self, data, parent=None, title = "", show_text=False): QDialog.__init__(self, parent) d = self d.setWindowTitle(title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = electrum_doged.get_config() if config: filename = os.path.join(config.path, "qrcode.bmp") def print_qr(): bmp.save_qrcode(qrw.qr, filename) QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK')) def copy_to_clipboard(): bmp.save_qrcode(qrw.qr, filename) QApplication.clipboard().setImage(QImage(filename)) QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK')) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(d.accept) b.setDefault(True) vbox.addLayout(hbox) d.setLayout(vbox)
def filename_field(parent, config, defaultname, select_msg): vbox = QVBoxLayout() vbox.addWidget(QLabel(_("Format"))) gb = QGroupBox("format", parent) b1 = QRadioButton(gb) b1.setText(_("CSV")) b1.setChecked(True) b2 = QRadioButton(gb) b2.setText(_("json")) vbox.addWidget(b1) vbox.addWidget(b2) hbox = QHBoxLayout() directory = config.get('io_dir', unicode(os.path.expanduser('~'))) path = os.path.join( directory, defaultname ) filename_e = QLineEdit() filename_e.setText(path) def func(): text = unicode(filename_e.text()) _filter = "*.csv" if text.endswith(".csv") else "*.json" if text.endswith(".json") else None p = unicode( QFileDialog.getSaveFileName(None, select_msg, text, _filter)) if p: filename_e.setText(p) button = QPushButton(_('File')) button.clicked.connect(func) hbox.addWidget(button) hbox.addWidget(filename_e) vbox.addLayout(hbox) def set_csv(v): text = unicode(filename_e.text()) text = text.replace(".json",".csv") if v else text.replace(".csv",".json") filename_e.setText(text) b1.clicked.connect(lambda: set_csv(True)) b2.clicked.connect(lambda: set_csv(False)) return vbox, filename_e, b1
def password_dialog(self, msg=None): if not msg: msg = _("Do not enter your device PIN here !\r\n\r\n" \ "Your BTChip wants to talk to you and tell you a unique second factor code.\r\n" \ "For this to work, please open a text editor (on a different computer / device if you believe this computer is compromised) and put your cursor into it, unplug your BTChip and plug it back in.\r\n" \ "It should show itself to your computer as a keyboard and output the second factor along with a summary of the transaction it is signing into the text-editor.\r\n\r\n" \ "Check that summary and then enter the second factor code here.\r\n" \ "Before clicking OK, re-plug the device once more (unplug it and plug it again if you read the second factor code on the same computer)") d = QDialog() d.setModal(1) d.setLayout( make_password_dialog(d, None, msg, False) ) return run_password_dialog(d, None, None)
def waiting_dialog(self, task, msg= _("Electrum is generating your addresses, please wait.")): def target(): task() self.emit(QtCore.SIGNAL('accept')) vbox = QVBoxLayout() self.waiting_label = QLabel(msg) vbox.addWidget(self.waiting_label) self.set_layout(vbox) t = threading.Thread(target = target) t.start() self.exec_()