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