ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change
on this file since aefde77 was
53c771e,
checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago
|
Converted unit tests
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | from PyQt5 import QtCore |
---|
2 | from PyQt5 import QtGui |
---|
3 | from PyQt5 import QtWidgets |
---|
4 | |
---|
5 | import sas.sasview |
---|
6 | |
---|
7 | from sas.qtgui.Plotting.UI.AddTextUI import Ui_AddText |
---|
8 | |
---|
9 | class AddText(QtWidgets.QDialog, Ui_AddText): |
---|
10 | """ Simple GUI for a single line text query """ |
---|
11 | def __init__(self, parent=None): |
---|
12 | super(AddText, self).__init__(parent) |
---|
13 | self.setupUi(self) |
---|
14 | |
---|
15 | self._font = QtGui.QFont() |
---|
16 | self._color = "black" |
---|
17 | self.btnFont.clicked.connect(self.onFontChange) |
---|
18 | self.btnColor.clicked.connect(self.onColorChange) |
---|
19 | |
---|
20 | def text(self): |
---|
21 | return self.textEdit.toPlainText() |
---|
22 | |
---|
23 | def font(self): |
---|
24 | return self._font |
---|
25 | |
---|
26 | def color(self): |
---|
27 | return self._color |
---|
28 | |
---|
29 | def onFontChange(self, event): |
---|
30 | """ |
---|
31 | Pop up the standard Qt Font change dialog |
---|
32 | """ |
---|
33 | self._font, ok = QtWidgets.QFontDialog.getFont(parent=self) |
---|
34 | if ok: |
---|
35 | self.textEdit.setFont(self._font) |
---|
36 | |
---|
37 | def onColorChange(self, event): |
---|
38 | """ |
---|
39 | Pop up the standard Qt color change dialog |
---|
40 | """ |
---|
41 | # Pick up the chosen color |
---|
42 | self._color = QtWidgets.QColorDialog.getColor(parent=self) |
---|
43 | # Update the text control |
---|
44 | palette = QtGui.QPalette() |
---|
45 | palette.setColor(QtGui.QPalette.Text, self._color) |
---|
46 | self.textEdit.setPalette(palette) |
---|
47 | |
---|
48 | # Save the color as #RRGGBB |
---|
49 | self._color = str(self._color.name()) |
---|
Note: See
TracBrowser
for help on using the repository browser.