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') )
60 def close_button(dialog, label=_("Close") ):
63 b = QPushButton(label)
65 b.clicked.connect(dialog.close)
69 def ok_cancel_buttons(dialog, ok_label=_("OK") ):
72 b = QPushButton(_("Cancel"))
74 b.clicked.connect(dialog.reject)
75 b = QPushButton(ok_label)
77 b.clicked.connect(dialog.accept)
81 def text_dialog(parent, title, label, ok_label):
82 dialog = QDialog(parent)
83 dialog.setMinimumWidth(500)
84 dialog.setWindowTitle(title)
88 l.addWidget(QLabel(label))
91 l.addLayout(ok_cancel_buttons(dialog, ok_label))
93 return unicode(txt.toPlainText())
96 class MyTreeWidget(QTreeWidget):
97 def __init__(self, parent):
98 QTreeWidget.__init__(self, parent)
99 self.setContextMenuPolicy(Qt.CustomContextMenu)
100 self.connect(self, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.itemactivated)
102 def itemactivated(self, item):
104 for i in range(0,self.viewport().height()/5):
105 if self.itemAt(QPoint(0,i*5)) == item:
109 for j in range(0,30):
110 if self.itemAt(QPoint(0,i*5 + j)) != item:
112 self.emit(SIGNAL('customContextMenuRequested(const QPoint&)'), QPoint(50, i*5 + j - 1))