Browse Source

access to global configuration using set_config and get_config

283
ThomasV 11 years ago
parent
commit
c07c1c58ed
  1. 19
      gui/qt/qrcodewidget.py
  2. 2
      lib/__init__.py
  3. 11
      lib/simple_config.py

19
gui/qt/qrcodewidget.py

@ -6,6 +6,7 @@ import PyQt4.QtGui as QtGui
import os
import qrcode
import electrum
from electrum import bmp
from electrum.i18n import _
@ -99,9 +100,9 @@ class QRDialog(QDialog):
hbox = QHBoxLayout()
hbox.addStretch(1)
if parent:
self.config = parent.config
filename = os.path.join(self.config.path, "qrcode.bmp")
config = electrum.get_config()
if config:
filename = os.path.join(config.path, "qrcode.bmp")
def print_qr():
bmp.save_qrcode(qrw.qr, filename)
@ -112,13 +113,13 @@ class QRDialog(QDialog):
self.parent().app.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(_("Copy"))
hbox.addWidget(b)
b.clicked.connect(copy_to_clipboard)
b = QPushButton(_("Save"))
hbox.addWidget(b)
b.clicked.connect(print_qr)
b = QPushButton(_("Save"))
hbox.addWidget(b)
b.clicked.connect(print_qr)
b = QPushButton(_("Close"))
hbox.addWidget(b)

2
lib/__init__.py

@ -5,7 +5,7 @@ from wallet import Wallet, Wallet_2of2, Wallet_2of3, Imported_Wallet
from verifier import TxVerifier
from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server
from interface import Interface
from simple_config import SimpleConfig
from simple_config import SimpleConfig, get_config, set_config
import bitcoin
import account
import transaction

11
lib/simple_config.py

@ -6,6 +6,15 @@ import os
from util import user_dir, print_error, print_msg
config = None
def get_config():
global config
return config
def set_config(c):
global config
config = c
class SimpleConfig:
"""
@ -32,7 +41,7 @@ a SimpleConfig instance then reads the wallet file.
self.user_config = {}
self.read_user_config()
set_config(self)

Loading…
Cancel
Save