eric6/E5Gui/E5LineEdit.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2009 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
7 Module implementing specialized line edits.
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5726
diff changeset
10 from PyQt5.QtCore import pyqtSignal, Qt, QEvent
7252
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
11 from PyQt5.QtWidgets import (
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 QLineEdit, QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication,
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 QSpacerItem, QSizePolicy
c5e3705073eb Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 )
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
15
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
16 import UI.PixmapCache
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
17
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
18
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
19 class E5LineEditSideWidget(QWidget):
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
20 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
21 Class implementing the side widgets for the line edit class.
5726
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
22
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
23 @signal sizeHintChanged() emitted to indicate a change of the size hint
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
24 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
25 sizeHintChanged = pyqtSignal()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
26
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
27 def __init__(self, parent=None):
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
28 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
29 Constructor
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
30
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
31 @param parent reference to the parent widget (QWidget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
32 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2401
diff changeset
33 super(E5LineEditSideWidget, self).__init__(parent)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
34
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
35 def event(self, evt):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
36 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
37 Public method to handle events.
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
38
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2401
diff changeset
39 @param evt reference to the event (QEvent)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
40 @return flag indicating, whether the event was recognized (boolean)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
41 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
42 if evt.type() == QEvent.LayoutRequest:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
43 self.sizeHintChanged.emit()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
44 return QWidget.event(self, evt)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
46
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 class E5LineEdit(QLineEdit):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Class implementing a line edit widget showing some inactive text.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
51 LeftSide = 0
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
52 RightSide = 1
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
53
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
54 def __init__(self, parent=None, inactiveText=""):
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Constructor
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @param parent reference to the parent widget (QWidget)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param inactiveText text to be shown on inactivity (string)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2401
diff changeset
61 super(E5LineEdit, self).__init__(parent)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
63 self.setMinimumHeight(22)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
64
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
65 self.setPlaceholderText(inactiveText)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
66
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
67 self.__mainLayout = QHBoxLayout(self)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
68 self.__mainLayout.setContentsMargins(0, 0, 0, 0)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
69 self.__mainLayout.setSpacing(0)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
70
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
71 self.__leftMargin = 0
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
72 self.__leftWidget = E5LineEditSideWidget(self)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
73 self.__leftWidget.resize(0, 0)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
74 self.__leftLayout = QHBoxLayout(self.__leftWidget)
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
75 self.__leftLayout.setContentsMargins(0, 0, 2, 0)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
76 if QApplication.isRightToLeft():
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
77 self.__leftLayout.setDirection(QBoxLayout.RightToLeft)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
78 else:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
79 self.__leftLayout.setDirection(QBoxLayout.LeftToRight)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
80 self.__leftLayout.setSizeConstraint(QLayout.SetFixedSize)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
81
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
82 self.__rightWidget = E5LineEditSideWidget(self)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
83 self.__rightWidget.resize(0, 0)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
84 self.__rightLayout = QHBoxLayout(self.__rightWidget)
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
85 self.__rightLayout.setContentsMargins(0, 0, 2, 0)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
86 if self.isRightToLeft():
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
87 self.__rightLayout.setDirection(QBoxLayout.RightToLeft)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
88 else:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
89 self.__rightLayout.setDirection(QBoxLayout.LeftToRight)
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
90
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
91 horizontalSpacer = QSpacerItem(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
92 0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
93 self.__mainLayout.addWidget(
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
94 self.__leftWidget, 0, Qt.AlignVCenter | Qt.AlignLeft)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
95 self.__mainLayout.addItem(horizontalSpacer)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
96 self.__mainLayout.addWidget(
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
97 self.__rightWidget, 0, Qt.AlignVCenter | Qt.AlignRight)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
98 if self.isRightToLeft():
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
99 self.__mainLayout.setDirection(QBoxLayout.RightToLeft)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
100 else:
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
101 self.__mainLayout.setDirection(QBoxLayout.LeftToRight)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
102
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
103 self.setWidgetSpacing(3)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
104 self.__leftWidget.sizeHintChanged.connect(self._updateTextMargins)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
105 self.__rightWidget.sizeHintChanged.connect(self._updateTextMargins)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
106
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
107 def setLeftMargin(self, margin):
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
108 """
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
109 Public method to set the left margin.
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
110
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
111 @param margin left margin in pixel (integer)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
112 """
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
113 self.__leftMargin = margin
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
114
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
115 def leftMargin(self):
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
116 """
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
117 Public method to get the size of the left margin.
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
118
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
119 @return left margin in pixel (integer)
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
120 """
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
121 return self.__leftMargin
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
122
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
123 def event(self, evt):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
124 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
125 Public method to handle events.
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
126
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2401
diff changeset
127 @param evt reference to the event (QEvent)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
128 @return flag indicating, whether the event was recognized (boolean)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
129 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
130 if evt.type() == QEvent.LayoutDirectionChange:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
131 if self.isRightToLeft():
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
132 self.__mainLayout.setDirection(QBoxLayout.RightToLeft)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
133 self.__leftLayout.setDirection(QBoxLayout.RightToLeft)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
134 self.__rightLayout.setDirection(QBoxLayout.RightToLeft)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
135 else:
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
136 self.__mainLayout.setDirection(QBoxLayout.LeftToRight)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
137 self.__leftLayout.setDirection(QBoxLayout.LeftToRight)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
138 self.__rightLayout.setDirection(QBoxLayout.LeftToRight)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
139 return QLineEdit.event(self, evt)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
140
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
141 def _updateTextMargins(self):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
142 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
143 Protected slot to update the text margins.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
144 """
2293
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
145 if self.__leftMargin == 0:
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
146 left = self.__leftWidget.sizeHint().width()
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
147 else:
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
148 left = self.__leftMargin
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
149 right = self.__rightWidget.sizeHint().width()
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
150 top = 0
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
151 bottom = 0
ec6c1459f5b3 Fixed an issue caused by Qt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2206
diff changeset
152 self.setTextMargins(left, top, right, bottom)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
153
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
154 def addWidget(self, widget, position):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
155 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
156 Public method to add a widget to a side.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
157
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
158 @param widget reference to the widget to add (QWidget)
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
159 @param position position to add to (E5LineEdit.LeftSide,
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
160 E5LineEdit.RightSide)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
161 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
162 if widget is None:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
163 return
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
164
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
165 if self.isRightToLeft():
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
166 if position == self.LeftSide:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
167 position = self.RightSide
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
168 else:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
169 position = self.LeftSide
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
170 if position == self.LeftSide:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
171 self.__leftLayout.addWidget(widget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
172 else:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
173 self.__rightLayout.insertWidget(1, widget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
174
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
175 def removeWidget(self, widget):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
176 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
177 Public method to remove a widget from a side.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
178
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
179 @param widget reference to the widget to remove (QWidget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
180 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
181 if widget is None:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
182 return
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
183
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
184 self.__leftLayout.removeWidget(widget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
185 self.__rightLayout.removeWidget(widget)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
186 widget.hide()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
187
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
188 def widgetSpacing(self):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
189 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
190 Public method to get the side widget spacing.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
191
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
192 @return side widget spacing (integer)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
193 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
194 return self.__leftLayout.spacing()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
195
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
196 def setWidgetSpacing(self, spacing):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
197 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
198 Public method to set the side widget spacing.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
199
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
200 @param spacing side widget spacing (integer)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
201 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
202 self.__leftLayout.setSpacing(spacing)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
203 self.__rightLayout.setSpacing(spacing)
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
204 self._updateTextMargins()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
205
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
206 def textMargin(self, position):
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
207 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
208 Public method to get the text margin for a side.
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
209
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
210 @param position side to get margin for (E5LineEdit.LeftSide,
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
211 E5LineEdit.RightSide)
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2401
diff changeset
212 @return text margin (integer)
643
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
213 """
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
214 spacing = self.__rightLayout.spacing()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
215 w = 0
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
216 if position == self.LeftSide:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
217 w = self.__leftWidget.sizeHint().width()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
218 else:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
219 w = self.__rightWidget.sizeHint().width()
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
220 if w == 0:
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
221 return 0
719db11dd4df Added a line widget with embeddable buttons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
222 return w + spacing * 2
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 def inactiveText(self):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 Public method to get the inactive text.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2401
diff changeset
228 @return inactive text (string)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
230 return self.placeholderText()
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def setInactiveText(self, inactiveText):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 Public method to set the inactive text.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 @param inactiveText text to be shown on inactivity (string)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 """
7198
684261ef2165 Removed the Qt4 runtime stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
238 self.setPlaceholderText(inactiveText)
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
239
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
240
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
241 class E5ClearableLineEdit(E5LineEdit):
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
242 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
243 Class implementing a line edit widget showing some inactive text and a
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
244 clear button, if it has some contents.
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
245 """
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
246 def __init__(self, parent=None, inactiveText="",
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
247 side=E5LineEdit.RightSide):
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
248 """
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
249 Constructor
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
250
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
251 @param parent reference to the parent widget (QWidget)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
252 @param inactiveText text to be shown on inactivity (string)
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
253 @param side side the clear button should be shown at
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
254 (E5LineEdit.RightSide, E5LineEdit.LeftSide)
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
255 @exception ValueError raised to indicate a bad parameter value
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
256 """
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
257 if side not in [E5LineEdit.RightSide, E5LineEdit.LeftSide]:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
258 raise ValueError("Bad value for 'side' parameter.")
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
259
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2401
diff changeset
260 super(E5ClearableLineEdit, self).__init__(parent, inactiveText)
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
261
2401
4f428de32b69 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
262 from E5Gui.E5LineEditButton import E5LineEditButton
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
263 self.__clearButton = E5LineEditButton(self)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
264 self.__clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft"))
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
265 self.addWidget(self.__clearButton, side)
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
266 self.__clearButton.setVisible(False)
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
267
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
268 self.__clearButton.clicked.connect(self.clear)
2206
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
269 self.textChanged.connect(self.__textChanged)
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
270
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
271 def __textChanged(self, txt):
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
272 """
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
273 Private slot to handle changes of the text.
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
274
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
275 @param txt text (string)
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
276 """
b2da5a8d7f15 Added a line edit widget with an internal clear button to E5LineEdit.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2084
diff changeset
277 self.__clearButton.setVisible(txt != "")

eric ide

mercurial