enthought / enthought/traitsui
QtView modal dialog cannot properly use a style_sheet
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
There are two problems when trying to use a style sheet with QtView modal dialogs, as in:
```
from traitsui.qt4.extra.qt_view import QtView
from traitsui.message import Message
style_sheet = """
* {font: 12pt "Verdana";
background: #191919;
color: #DDDDDD;
border: 1px solid #5A5A5A;
}
"""
def message(message="hello", title="Message", buttons=["OK"]):
msg = Message(message=message)
ui = msg.edit_traits(
view=QtView(
["message~", "|<>"], title=title, buttons=buttons, kind="modal",
style_sheet= style_sheet)
)
return ui
```
First, the style_sheet is not taken into account, and second there is an error on exit:
```
In [2]: message()
Traceback (most recent call last):
File "", line 1, in
message()
File "/Volumes/FAT/Developpement/Python/core/untitled22.py", line 14, in message
File "/Users/yves/miniconda3/lib/python3.8/site-packages/traits/has_traits.py", line 1736, in edit_traits
return view.ui(
File "/Users/yves/miniconda3/lib/python3.8/site-packages/traitsui/qt4/extra/qt_view.py", line 65, in ui
ui.control.setStyleSheet(self.style_sheet)
AttributeError: 'NoneType' object has no attribute 'setStyleSheet'
```
With `kind='live'`, no problem.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.