Should we provide a DockPaneWithToolbar class?
- Dominant language
- Python
- Stars
- 115
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
Currently Toolbars are defined on a task itself, but in some scenarios one may want to have a toolbar which is specific to a dock pane. For example, one could be using a TraitsDockPane to create a dock pane for a TraitsUI model/view. That TraitsUI view may have a toolbar defined, but that will not show up as a dock pane currently.
At least on Qt, the problem is that tool bars can only be attached to QMainWindow objects. This problem has been solved elsewhere and to do so, one simply needs to wrap the contents of the dock pane in a QMainWindow object.
For reference:
If you subclass TraitsDockPane and have a TraitsUI view that contains a toolbar, by default it will not show up in the dock pane. However, if the `create_contents` method is modified like so for Qt:
```
def create_contents(self, parent):
""" Create and return the toolkit-specific contents of the dock pane.
"""
if is_qt:
from pyface.qt import QtGui
self._panel = QtGui.QMainWindow()
self._content = super(CoolTraitsDockPaneWithToolbar, self).create_contents(self._panel)
self._panel.setCentralWidget(self._content)
return self._panel
```
The toolbar can appear.
Pulling this idea out into a separate base class could be useful
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.