1 from electrum.i18n import _
2 from PyQt4.QtGui import *
3 from PyQt4.QtCore import *
11 self.emit(SIGNAL('timersignal'))
15 class EnterButton(QPushButton):
16 def __init__(self, text, func):
17 QPushButton.__init__(self, text)
19 self.clicked.connect(func)
21 def keyPressEvent(self, e):
22 if e.key() == Qt.Key_Return:
26 def waiting_dialog(f, w=None):
33 w.setWindowTitle('Electrum')
35 if w.layout(): QWidget().setLayout(w.layout())
45 w.connect(s, SIGNAL('timersignal'), ff)
50 class HelpButton(QPushButton):
51 def __init__(self, text):
52 QPushButton.__init__(self, '?')
53 self.setFocusPolicy(Qt.NoFocus)
54 self.setFixedWidth(20)
55 self.clicked.connect(lambda: QMessageBox.information(self, 'Help', text, 'OK') )
59 def backup_wallet(path):
61 directory, fileName = os.path.split(path)
63 otherpath = unicode( QFileDialog.getOpenFileName(QWidget(), _('Enter a filename for the copy of your wallet'), directory) )
64 if otherpath and path!=otherpath:
65 shutil.copy2(path, otherpath)
66 QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(otherpath))
67 except (IOError, os.error), reason:
68 QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
70 def ok_cancel_buttons(dialog, ok_label=_("OK") ):
73 b = QPushButton(_("Cancel"))
75 b.clicked.connect(dialog.reject)
76 b = QPushButton(ok_label)
78 b.clicked.connect(dialog.accept)
82 def text_dialog(parent, title, label, ok_label):
83 dialog = QDialog(parent)
84 dialog.setMinimumWidth(500)
85 dialog.setWindowTitle(title)
89 l.addWidget(QLabel(label))
92 l.addLayout(ok_cancel_buttons(dialog, ok_label))
94 return unicode(txt.toPlainText())