-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtextforcopying.py
43 lines (39 loc) · 1.43 KB
/
textforcopying.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QDialog, QLineEdit, QShortcut, QFormLayout, QLabel
from PyQt5.QtGui import QKeySequence
class TextForCopying(QDialog):
"""
This class defines a window which shows copyable information about the
currently loaded sweep.
"""
def __init__(self, title, date_stamp, name, xlabel, ylabel, zlabel=None):
super().__init__()
self.title = title
self.date_stamp = date_stamp
self.name = name
self.xlabel = xlabel
self.ylabel = ylabel
self.zlabel = zlabel
self.labels = ['title', 'date_stamp', 'name', 'xlabel', 'ylabel',
'zlabel']
self.init_geometry()
self.set_hotkeys()
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
def init_geometry(self):
layout = QFormLayout()
for label in self.labels:
text = getattr(self, label)
label = QLabel(label)
wdg = QLineEdit(text)
wdg.setMinimumWidth(1000)
layout.addRow(label, wdg)
self.setLayout(layout)
def set_hotkeys(self):
self.hotkey1 = QShortcut(QKeySequence('Ctrl+w'), self)
self.hotkey1.activated.connect(self.close)
if __name__=='__main__':
import sys
qApp = QtWidgets.QApplication(sys.argv)
diag = TextForCopying('foo', 'longstriiiiiing', 'foo', 'abc', 'foo', 'foo')
diag.show()
sys.exit(qApp.exec_())