source: sasview/src/sas/qtgui/Plotting/AddText.py @ 33c0561

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_sync_sascalc
Last change on this file since 33c0561 was 33c0561, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 5 years ago

Replace Apply button menu driven functionality with additional button.
Removed Cancel.
Removed the window system context help button from all affected widgets.
SASVIEW-1239

  • Property mode set to 100644
File size: 1.5 KB
Line 
1from PyQt5 import QtCore
2from PyQt5 import QtGui
3from PyQt5 import QtWidgets
4
5import sas.sasview
6
7from sas.qtgui.Plotting.UI.AddTextUI import Ui_AddText
8
9class 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        # disable the context help icon
15        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
16
17        self._font = QtGui.QFont()
18        self._color = "black"
19        self.btnFont.clicked.connect(self.onFontChange)
20        self.btnColor.clicked.connect(self.onColorChange)
21
22    def text(self):
23        return self.textEdit.toPlainText()
24
25    def font(self):
26        return self._font
27
28    def color(self):
29        return self._color
30
31    def onFontChange(self, event):
32        """
33        Pop up the standard Qt Font change dialog
34        """
35        self._font, ok = QtWidgets.QFontDialog.getFont(parent=self)
36        if ok:
37            self.textEdit.setFont(self._font)
38
39    def onColorChange(self, event):
40        """
41        Pop up the standard Qt color change dialog
42        """
43        # Pick up the chosen color
44        self._color = QtWidgets.QColorDialog.getColor(parent=self)
45        # Update the text control
46        palette = QtGui.QPalette()
47        palette.setColor(QtGui.QPalette.Text, self._color)
48        self.textEdit.setPalette(palette)
49
50        # Save the color as #RRGGBB
51        self._color = str(self._color.name())
Note: See TracBrowser for help on using the repository browser.