E5Gui/E5LineEdit.py

changeset 5736
000ea446ff4b
parent 5726
e1dbd217214a
child 6048
82ad8ec9548c
equal deleted inserted replaced
5735:f606dbe20be6 5736:000ea446ff4b
7 Module implementing specialized line edits. 7 Module implementing specialized line edits.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import pyqtSignal, Qt, QEvent, qVersion 12 from PyQt5.QtCore import pyqtSignal, Qt, QEvent
13 from PyQt5.QtGui import QPainter, QPalette 13 from PyQt5.QtGui import QPainter, QPalette
14 from PyQt5.QtWidgets import QLineEdit, QStyle, QWidget, QHBoxLayout, \ 14 from PyQt5.QtWidgets import QLineEdit, QStyle, QWidget, QHBoxLayout, \
15 QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy 15 QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy
16 if qVersion() >= "5.0.0": 16
17 from Globals import qVersionTuple
18
19 if qVersionTuple() >= (5, 0, 0):
17 from PyQt5.QtWidgets import QStyleOptionFrame 20 from PyQt5.QtWidgets import QStyleOptionFrame
18 else: 21 else:
19 from PyQt5.QtWidgets import QStyleOptionFrameV2 as QStyleOptionFrame 22 from PyQt5.QtWidgets import QStyleOptionFrameV2 as QStyleOptionFrame
20 23
21 import UI.PixmapCache 24 import UI.PixmapCache
65 """ 68 """
66 super(E5LineEdit, self).__init__(parent) 69 super(E5LineEdit, self).__init__(parent)
67 70
68 self.setMinimumHeight(22) 71 self.setMinimumHeight(22)
69 72
70 if qVersion() < "4.7.0": 73 if qVersionTuple() < (4, 7, 0):
71 self.__inactiveText = inactiveText 74 self.__inactiveText = inactiveText
72 else: 75 else:
73 self.setPlaceholderText(inactiveText) 76 self.setPlaceholderText(inactiveText)
74 77
75 self.__mainLayout = QHBoxLayout(self) 78 self.__mainLayout = QHBoxLayout(self)
152 155
153 @param evt reference to the paint event (QPaintEvent) 156 @param evt reference to the paint event (QPaintEvent)
154 """ 157 """
155 super(E5LineEdit, self).paintEvent(evt) 158 super(E5LineEdit, self).paintEvent(evt)
156 159
157 if qVersion() < "4.7.0": 160 if qVersionTuple() < (4, 7, 0):
158 if not self.text() and \ 161 if not self.text() and \
159 self.__inactiveText and \ 162 self.__inactiveText and \
160 not self.hasFocus(): 163 not self.hasFocus():
161 panel = QStyleOptionFrame() 164 panel = QStyleOptionFrame()
162 self.initStyleOption(panel) 165 self.initStyleOption(panel)
260 """ 263 """
261 Public method to get the inactive text. 264 Public method to get the inactive text.
262 265
263 @return inactive text (string) 266 @return inactive text (string)
264 """ 267 """
265 if qVersion() < "4.7.0": 268 if qVersionTuple() < (4, 7, 0):
266 return self.__inactiveText 269 return self.__inactiveText
267 else: 270 else:
268 return self.placeholderText() 271 return self.placeholderText()
269 272
270 def setInactiveText(self, inactiveText): 273 def setInactiveText(self, inactiveText):
271 """ 274 """
272 Public method to set the inactive text. 275 Public method to set the inactive text.
273 276
274 @param inactiveText text to be shown on inactivity (string) 277 @param inactiveText text to be shown on inactivity (string)
275 """ 278 """
276 if qVersion() < "4.7.0": 279 if qVersionTuple() < (4, 7, 0):
277 self.__inactiveText = inactiveText 280 self.__inactiveText = inactiveText
278 self.update() 281 self.update()
279 else: 282 else:
280 self.setPlaceholderText(inactiveText) 283 self.setPlaceholderText(inactiveText)
281 284

eric ide

mercurial