本文整理汇总了Python中electrum_gui.qt.amountedit.AmountEdit.setText方法的典型用法代码示例。如果您正苦于以下问题:Python AmountEdit.setText方法的具体用法?Python AmountEdit.setText怎么用?Python AmountEdit.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electrum_gui.qt.amountedit.AmountEdit
的用法示例。
在下文中一共展示了AmountEdit.setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_google_auth
# 需要导入模块: from electrum_gui.qt.amountedit import AmountEdit [as 别名]
# 或者: from electrum_gui.qt.amountedit.AmountEdit import setText [as 别名]
def setup_google_auth(self, window, _id, otp_secret):
vbox = QVBoxLayout()
window.set_layout(vbox)
if otp_secret is not None:
uri = "otpauth://totp/%s?secret=%s" % ("trustedcoin.com", otp_secret)
vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator."))
qrw = QRCodeWidget(uri)
vbox.addWidget(qrw, 1)
msg = _("Then, enter your Google Authenticator code:")
else:
label = QLabel(
"This wallet is already registered, but it was never authenticated. To finalize your registration, please enter your Google Authenticator Code. If you do not have this code, delete the wallet file and start a new registration"
)
label.setWordWrap(1)
vbox.addWidget(label)
msg = _("Google Authenticator code:")
hbox = QHBoxLayout()
hbox.addWidget(QLabel(msg))
pw = AmountEdit(None, is_int=True)
pw.setFocus(True)
hbox.addWidget(pw)
hbox.addStretch(1)
vbox.addLayout(hbox)
b = OkButton(window, _("Next"))
b.setEnabled(False)
vbox.addLayout(Buttons(CancelButton(window), b))
pw.textChanged.connect(lambda: b.setEnabled(len(pw.text()) == 6))
while True:
if not window.exec_():
return False
otp = pw.get_amount()
try:
server.auth(_id, otp)
return True
except:
QMessageBox.information(self.window, _("Message"), _("Incorrect password"), _("OK"))
pw.setText("")
示例2: setup_google_auth
# 需要导入模块: from electrum_gui.qt.amountedit import AmountEdit [as 别名]
# 或者: from electrum_gui.qt.amountedit.AmountEdit import setText [as 别名]
def setup_google_auth(self, window, _id, otp_secret):
vbox = QVBoxLayout()
if otp_secret is not None:
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
l = QLabel("Please scan the following QR code in Google Authenticator. You may as well use the following key: %s"%otp_secret)
l.setWordWrap(True)
vbox.addWidget(l)
qrw = QRCodeWidget(uri)
vbox.addWidget(qrw, 1)
msg = _('Then, enter your Google Authenticator code:')
else:
label = QLabel("This wallet is already registered, but it was never authenticated. To finalize your registration, please enter your Google Authenticator Code. If you do not have this code, delete the wallet file and start a new registration")
label.setWordWrap(1)
vbox.addWidget(label)
msg = _('Google Authenticator code:')
hbox = QHBoxLayout()
hbox.addWidget(WWLabel(msg))
pw = AmountEdit(None, is_int = True)
pw.setFocus(True)
pw.setMaximumWidth(50)
hbox.addWidget(pw)
vbox.addLayout(hbox)
def set_enabled():
window.next_button.setEnabled(len(pw.text()) == 6)
pw.textChanged.connect(set_enabled)
while True:
if not window.set_main_layout(vbox, next_enabled=False,
raise_on_cancel=False):
return False
otp = pw.get_amount()
try:
server.auth(_id, otp)
return True
except:
window.show_message(_('Incorrect password'))
pw.setText('')
示例3: Plugin
# 需要导入模块: from electrum_gui.qt.amountedit import AmountEdit [as 别名]
# 或者: from electrum_gui.qt.amountedit.AmountEdit import setText [as 别名]
#.........这里部分代码省略.........
try:
tx_info = tx_list[str(item.data(0, Qt.UserRole).toPyObject())]
except Exception:
newtx = self.wallet.get_tx_history()
v = newtx[[x[0] for x in newtx].index(str(item.data(0, Qt.UserRole).toPyObject()))][3]
tx_info = {'timestamp':int(time.time()), 'value': v }
pass
tx_time = int(tx_info['timestamp'])
if cur_exchange == "CoinDesk":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d')
try:
tx_USD_val = "%.2f %s" % (Decimal(str(tx_info['value'])) / 100000000 * Decimal(resp_hist['bpi'][tx_time_str]), "USD")
except KeyError:
tx_USD_val = "%.2f %s" % (self.btc_rate * Decimal(str(tx_info['value']))/100000000 , "USD")
elif cur_exchange == "Winkdex":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d') + "T16:00:00-04:00"
try:
tx_rate = resp_hist[[x['timestamp'] for x in resp_hist].index(tx_time_str)]['price']
tx_USD_val = "%.2f %s" % (Decimal(tx_info['value']) / 100000000 * Decimal(tx_rate)/Decimal("100.0"), "USD")
except ValueError:
tx_USD_val = "%.2f %s" % (self.btc_rate * Decimal(tx_info['value'])/100000000 , "USD")
except KeyError:
tx_USD_val = _("No data")
elif cur_exchange == "BitcoinVenezuela":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime('%Y-%m-%d')
try:
num = resp_hist[tx_time_str].replace(',','')
tx_BTCVEN_val = "%.2f %s" % (Decimal(str(tx_info['value'])) / 100000000 * Decimal(num), cur_currency)
except KeyError:
tx_BTCVEN_val = _("No data")
if cur_exchange in ["CoinDesk", "Winkdex"]:
item.setText(5, tx_USD_val)
elif cur_exchange == "BitcoinVenezuela":
item.setText(5, tx_BTCVEN_val)
if Decimal(str(tx_info['value'])) < 0:
item.setForeground(5, QBrush(QColor("#BC1E1E")))
for i, width in enumerate(self.gui.main_window.column_widths['history']):
self.gui.main_window.history_list.setColumnWidth(i, width)
self.gui.main_window.history_list.setColumnWidth(4, 140)
self.gui.main_window.history_list.setColumnWidth(5, 120)
self.gui.main_window.is_edit = False
def settings_widget(self, window):
return EnterButton(_('Settings'), self.settings_dialog)
def settings_dialog(self):
d = QDialog()
d.setWindowTitle("Settings")
layout = QGridLayout(d)
layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0)
layout.addWidget(QLabel(_('Currency: ')), 1, 0)
layout.addWidget(QLabel(_('History Rates: ')), 2, 0)
combo = QComboBox()
combo_ex = QComboBox()
hist_checkbox = QCheckBox()
hist_checkbox.setEnabled(False)
hist_checkbox.setChecked(self.config.get('history_rates', 'unchecked') != 'unchecked')
ok_button = QPushButton(_("OK"))
def on_change(x):
try:
cur_request = str(self.currencies[x])
示例4: Plugin
# 需要导入模块: from electrum_gui.qt.amountedit import AmountEdit [as 别名]
# 或者: from electrum_gui.qt.amountedit.AmountEdit import setText [as 别名]
#.........这里部分代码省略.........
try:
tx_info = self.tx_list[str(item.data(0, Qt.UserRole).toPyObject())]
except Exception:
newtx = self.wallet.get_history()
v = newtx[[x[0] for x in newtx].index(str(item.data(0, Qt.UserRole).toPyObject()))][2]
tx_info = {"timestamp": int(time.time()), "value": v}
pass
tx_time = int(tx_info["timestamp"])
tx_value = Decimal(str(tx_info["value"])) / COIN
if self.cur_exchange == "CoinDesk":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime("%Y-%m-%d")
try:
tx_fiat_val = "%.2f %s" % (tx_value * Decimal(self.resp_hist["bpi"][tx_time_str]), "USD")
except KeyError:
tx_fiat_val = "%.2f %s" % (self.btc_rate * Decimal(str(tx_info["value"])) / COIN, "USD")
elif self.cur_exchange == "Winkdex":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime("%Y-%m-%d") + "T16:00:00-04:00"
try:
tx_rate = self.resp_hist[[x["timestamp"] for x in self.resp_hist].index(tx_time_str)]["price"]
tx_fiat_val = "%.2f %s" % (tx_value * Decimal(tx_rate) / Decimal("100.0"), "USD")
except ValueError:
tx_fiat_val = "%.2f %s" % (self.btc_rate * Decimal(tx_info["value"]) / COIN, "USD")
except KeyError:
tx_fiat_val = _("No data")
elif self.cur_exchange == "BitcoinVenezuela":
tx_time_str = datetime.datetime.fromtimestamp(tx_time).strftime("%Y-%m-%d")
try:
num = self.resp_hist[tx_time_str].replace(",", "")
tx_fiat_val = "%.2f %s" % (tx_value * Decimal(num), self.fiat_unit())
except KeyError:
tx_fiat_val = _("No data")
tx_fiat_val = " " * (12 - len(tx_fiat_val)) + tx_fiat_val
item.setText(5, tx_fiat_val)
item.setFont(5, QFont(MONOSPACE_FONT))
if Decimal(str(tx_info["value"])) < 0:
item.setForeground(5, QBrush(QColor("#BC1E1E")))
self.win.history_list.setColumnWidth(5, 120)
self.win.is_edit = False
def settings_widget(self, window):
return EnterButton(_("Settings"), self.settings_dialog)
def settings_dialog(self):
d = QDialog()
d.setWindowTitle("Settings")
layout = QGridLayout(d)
layout.addWidget(QLabel(_("Exchange rate API: ")), 0, 0)
layout.addWidget(QLabel(_("Currency: ")), 1, 0)
layout.addWidget(QLabel(_("History Rates: ")), 2, 0)
combo = QComboBox()
combo_ex = QComboBox()
hist_checkbox = QCheckBox()
hist_checkbox.setEnabled(False)
hist_checkbox.setChecked(self.config.get("history_rates", "unchecked") != "unchecked")
ok_button = QPushButton(_("OK"))
def on_change(x):
try:
cur_request = str(self.currencies[x])
except Exception:
return
if cur_request != self.fiat_unit():
self.config.set_key("currency", cur_request, True)
cur_exchange = self.config.get("use_exchange", "Blockchain")