def __init__(self, wallet): self.wallet = wallet self.app = QApplication(sys.argv) # Should probably not modify the current path but instead # change the behaviour of rsrc(...) self.old_path = QDir.currentPath() cd_data_dir() with open(rsrc("style.css")) as style_file: self.app.setStyleSheet(style_file.read())
def load_theme(self): """Load theme retrieved from wallet file.""" try: theme_prefix, theme_path = self.themes[self.theme_name] except KeyError: util.print_error("Theme not found!", self.theme_name) return QDir.setCurrent(os.path.join(theme_prefix, theme_path)) with open(rsrc("style.css")) as style_file: qApp.setStyleSheet(style_file.read())
if self.state == self.READY: return self.state = self.READY self.window.activate() def update_balance(self): conf_balance, unconf_balance = self.wallet.get_balance() balance = D(conf_balance + unconf_balance) self.window.set_balances(balance) def update_completions(self): completions = [] for addr, label in self.wallet.labels.items(): if addr in self.wallet.addressbook: completions.append("%s <%s>" % (label, addr)) completions = completions + self.wallet.aliases.keys() self.window.update_completions(completions) def update_history(self): tx_history = self.wallet.get_tx_history() self.window.update_history(tx_history) if __name__ == "__main__": app = QApplication(sys.argv) with open(rsrc("style.css")) as style_file: app.setStyleSheet(style_file.read()) mini = MiniWindow() sys.exit(app.exec_())
def ready(self): if self.state == self.READY: return self.state = self.READY self.window.activate() def update_balance(self): conf_balance, unconf_balance = self.wallet.get_balance() balance = D(conf_balance + unconf_balance) self.window.set_balances(balance) def update_completions(self): completions = [] for addr, label in self.wallet.labels.items(): if addr in self.wallet.addressbook: completions.append("%s <%s>" % (label, addr)) completions = completions + self.wallet.aliases.keys() self.window.update_completions(completions) def update_history(self): tx_history = self.wallet.get_tx_history() self.window.update_history(tx_history) if __name__ == "__main__": app = QApplication(sys.argv) with open(rsrc("style.css")) as style_file: app.setStyleSheet(style_file.read()) mini = MiniWindow() sys.exit(app.exec_())
def __init__(self, actuator, expand_callback): super(MiniWindow, self).__init__() self.actuator = actuator accounts_button = IconButton(rsrc("icons", "accounts.png")) accounts_button.setObjectName("accounts_button") self.accounts_selector = QMenu() accounts_button.setMenu(self.accounts_selector) interact_button = IconButton(rsrc("icons", "interact.png")) interact_button.setObjectName("interact_button") app_menu = QMenu(interact_button) report_action = app_menu.addAction(_("&Report Bug")) about_action = app_menu.addAction(_("&About Electrum")) app_menu.addSeparator() quit_action = app_menu.addAction(_("&Quit")) interact_button.setMenu(app_menu) self.connect(report_action, SIGNAL("triggered()"), self.show_report_bug) self.connect(about_action, SIGNAL("triggered()"), self.show_about) self.connect(quit_action, SIGNAL("triggered()"), self.close) expand_button = IconButton(rsrc("icons", "expand.png")) expand_button.setObjectName("expand_button") self.connect(expand_button, SIGNAL("clicked()"), expand_callback) self.btc_balance = None self.quote_currencies = ["EUR", "USD", "GBP"] self.actuator.set_configured_currency(self.set_quote_currency) self.exchanger = exchange_rate.Exchanger(self) # Needed because price discovery is done in a different thread # which needs to be sent back to this main one to update the GUI self.connect(self, SIGNAL("refresh_balance()"), self.refresh_balance) self.balance_label = BalanceLabel(self.change_quote_currency) self.balance_label.setObjectName("balance_label") self.receive_button = QPushButton(_("&Receive")) self.receive_button.setObjectName("receive_button") self.receive_button.setDefault(True) self.connect(self.receive_button, SIGNAL("clicked()"), self.copy_address) self.address_input = TextedLineEdit(_("Enter a Bitcoin address...")) self.address_input.setObjectName("address_input") self.connect(self.address_input, SIGNAL("textEdited(QString)"), self.address_field_changed) resize_line_edit_width(self.address_input, "1BtaFUr3qVvAmwrsuDuu5zk6e4s2rxd2Gy") self.address_completions = QStringListModel() address_completer = QCompleter(self.address_input) address_completer.setCaseSensitivity(False) address_completer.setModel(self.address_completions) self.address_input.setCompleter(address_completer) self.valid_address = QCheckBox() self.valid_address.setObjectName("valid_address") self.valid_address.setEnabled(False) self.valid_address.setChecked(False) address_layout = QHBoxLayout() address_layout.addWidget(self.address_input) address_layout.addWidget(self.valid_address) self.amount_input = TextedLineEdit(_("... and amount")) self.amount_input.setObjectName("amount_input") # This is changed according to the user's displayed balance self.amount_validator = QDoubleValidator(self.amount_input) self.amount_validator.setNotation(QDoubleValidator.StandardNotation) self.amount_validator.setDecimals(8) self.amount_input.setValidator(self.amount_validator) self.connect(self.amount_input, SIGNAL("textChanged(QString)"), self.amount_input_changed) amount_layout = QHBoxLayout() amount_layout.addWidget(self.amount_input) amount_layout.addStretch() send_button = QPushButton(_("&Send")) send_button.setObjectName("send_button") self.connect(send_button, SIGNAL("clicked()"), self.send) main_layout = QGridLayout(self) main_layout.addWidget(accounts_button, 0, 0) main_layout.addWidget(interact_button, 1, 0) main_layout.addWidget(expand_button, 2, 0) main_layout.addWidget(self.balance_label, 0, 1) main_layout.addWidget(self.receive_button, 0, 2) main_layout.addLayout(address_layout, 1, 1, 1, -1) main_layout.addLayout(amount_layout, 2, 1) main_layout.addWidget(send_button, 2, 2) quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self) self.connect(quit_shortcut, SIGNAL("activated()"), self.close) close_shortcut = QShortcut(QKeySequence("Ctrl+W"), self) self.connect(close_shortcut, SIGNAL("activated()"), self.close) self.setWindowIcon(QIcon(":electrum.png")) self.setWindowTitle("Electrum") self.setWindowFlags(Qt.Window|Qt.MSWindowsFixedSizeDialogHint) self.layout().setSizeConstraint(QLayout.SetFixedSize) self.setObjectName("main_window") self.show()