Merge pull request #532 from pypeclub/feature/text_input_can_have_placeholder

Feature/text input can have placeholder
This commit is contained in:
Milan Kolar 2020-09-18 15:57:50 +02:00 committed by GitHub
commit b68a342165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -111,6 +111,7 @@
### text
- simple text input
- key `"multiline"` allows to enter multiple lines of text (Default: `False`)
- key `"placeholder"` allows to show text inside input when is empty (Default: `None`)
```
{

View file

@ -906,6 +906,7 @@ class TextWidget(QtWidgets.QWidget, InputObject):
self.initial_attributes(input_data, parent, as_widget)
self.multiline = input_data.get("multiline", False)
placeholder = input_data.get("placeholder")
layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
@ -916,6 +917,9 @@ class TextWidget(QtWidgets.QWidget, InputObject):
else:
self.text_input = QtWidgets.QLineEdit(self)
if placeholder:
self.text_input.setPlaceholderText(placeholder)
self.setFocusProxy(self.text_input)
layout_kwargs = {}