source: sasview/src/sas/qtgui/Plotting/AddText.py @ 5a2bb75

Last change on this file since 5a2bb75 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 
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
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.