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:
29 class HelpButton(QPushButton):
30 def __init__(self, text):
31 QPushButton.__init__(self, '?')
32 self.setFocusPolicy(Qt.NoFocus)
33 self.setFixedWidth(20)
34 self.clicked.connect(lambda: QMessageBox.information(self, 'Help', text, 'OK') )
39 def close_button(dialog, label=_("Close") ):
42 b = QPushButton(label)
44 b.clicked.connect(dialog.close)
48 def ok_cancel_buttons(dialog, ok_label=_("OK") ):
51 b = QPushButton(_("Cancel"))
53 b.clicked.connect(dialog.reject)
54 b = QPushButton(ok_label)
56 b.clicked.connect(dialog.accept)
60 def text_dialog(parent, title, label, ok_label, default=None):
61 dialog = QDialog(parent)
62 dialog.setMinimumWidth(500)
63 dialog.setWindowTitle(title)
67 l.addWidget(QLabel(label))
72 l.addLayout(ok_cancel_buttons(dialog, ok_label))
74 return unicode(txt.toPlainText())
77 class MyTreeWidget(QTreeWidget):
78 def __init__(self, parent):
79 QTreeWidget.__init__(self, parent)
80 self.setContextMenuPolicy(Qt.CustomContextMenu)
81 self.connect(self, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.itemactivated)
83 def itemactivated(self, item):
85 for i in range(0,self.viewport().height()/5):
86 if self.itemAt(QPoint(0,i*5)) == item:
91 if self.itemAt(QPoint(0,i*5 + j)) != item:
93 self.emit(SIGNAL('customContextMenuRequested(const QPoint&)'), QPoint(50, i*5 + j - 1))