-
Notifications
You must be signed in to change notification settings - Fork 81
ENH: Add PyDMWindow widget to configure hiding the nav bar, menu bar, and status bar components on first load #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
craftablescience
wants to merge
4
commits into
slaclab:master
Choose a base branch
from
craftablescience:pr-lxlewis-1113
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d0d0d35
ENH: add PyDMWindow widget to apply custom attributes to Display, all…
craftablescience 6f91ecc
TST: add tests for PyDMWindow widget
craftablescience 8bcd3bc
DOC: add example and documentation for PyDMWindow
craftablescience 016671d
DOC: fix PyDMChannel import path
craftablescience File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
####################### | ||
PyDMWindow | ||
nstelter-slac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
####################### | ||
|
||
The PyDM Window Widget is a container widget that allows the display creator to set certain global display | ||
properties. It is currently used to hide specific UI elements when the display is the first loaded display | ||
in the running PyDM instance. | ||
|
||
Using the PyDM Window Widget in Designer | ||
======================================== | ||
|
||
In designer, when creating a new display, select PyDMWindow as the base widget. | ||
|
||
|
||
Widget Properties | ||
================= | ||
|
||
============= ==== =========== | ||
Property Type Description | ||
============= ==== =========== | ||
hideMenuBar bool Hide the menu bar if this is the first loaded display. | ||
hideNavBar bool Hide the nav bar if this is the first loaded display. | ||
hideStatusBar bool Hide the status bar if this is the first loaded display. | ||
============= ==== =========== | ||
|
||
|
||
API Documentation | ||
================= | ||
|
||
.. autoclass:: pydm.widgets.window.PyDMWindow | ||
:members: | ||
:show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
nstelter-slac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ui version="4.0"> | ||
<class>Display</class> | ||
<widget class="PyDMWindow" name="Display"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>PyDMWindow</string> | ||
</property> | ||
<property name="hideMenuBar" stdset="0"> | ||
<bool>true</bool> | ||
</property> | ||
<property name="hideNavBar" stdset="0"> | ||
<bool>true</bool> | ||
</property> | ||
<property name="hideStatusBar" stdset="0"> | ||
<bool>true</bool> | ||
</property> | ||
<widget class="QLabel" name="Label"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>380</width> | ||
<height>280</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string><html><head/><body><p>This display is using a PyDMWindow widget as the root widget. This allows it to customize some otherwise unavailable properties.</p><p><br/></p><p>Currently it is used for hiding specific parts of the PyDM interface, including the menu bar, nav bar, and status bar. Disabling these elements can make your popup displays look nicer!</p></body></html></string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>PyDMWindow</class> | ||
<extends>QWidget</extends> | ||
<header>pydm.widgets.window</header> | ||
<container>1</container> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Unit Tests for the Window Widget | ||
|
||
from ...widgets.window import PyDMWindow | ||
|
||
|
||
# -------------------- | ||
# POSITIVE TEST CASES | ||
# -------------------- | ||
|
||
|
||
def test_construct(qtbot): | ||
""" | ||
Test the construction of the widget. | ||
|
||
Expectations: | ||
The correct default values are assigned to the widget's attributes. | ||
|
||
Parameters | ||
---------- | ||
qtbot : fixture | ||
pytest-qt window for widget test | ||
""" | ||
pydm_window = PyDMWindow() | ||
qtbot.addWidget(pydm_window) | ||
|
||
assert pydm_window._hide_menu_bar is False | ||
assert pydm_window._hide_nav_bar is False | ||
assert pydm_window._hide_status_bar is False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import warnings | ||
from qtpy.QtWidgets import QWidget | ||
from qtpy.QtCore import Property | ||
from typing import Optional | ||
from .base import is_qt_designer | ||
|
||
|
||
class PyDMWindow(QWidget): | ||
""" | ||
QWidget with support for some custom PyDM properties. Right now it only | ||
supports disabling the menu bar, nav bar, and status bar by default. This | ||
widget will only function if it is at the root of the UI hierarchy. | ||
This class inherits from QWidget. It is NOT a PyDMWidget. | ||
|
||
Parameters | ||
---------- | ||
parent : QWidget | ||
The parent widget for the Window. Should ideally be None | ||
""" | ||
|
||
def __init__(self, parent: Optional[QWidget] = None): | ||
if parent is not None and not is_qt_designer(): | ||
warnings.warn("PyDMWindow must be at the root of the UI hierarchy, or it will not function properly!") | ||
|
||
super().__init__(parent) | ||
self._hide_menu_bar = False | ||
self._hide_nav_bar = False | ||
self._hide_status_bar = False | ||
|
||
@Property(bool) | ||
def hideMenuBar(self): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
menu bar when the display is loaded. | ||
|
||
Returns | ||
------- | ||
hide_menu_bar : bool | ||
The configured value | ||
""" | ||
return self._hide_menu_bar | ||
|
||
@hideMenuBar.setter | ||
def hideMenuBar(self, new_val): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
menu bar when the display is loaded. | ||
|
||
Parameters | ||
---------- | ||
new_val : bool | ||
The new configuration to use | ||
""" | ||
self._hide_menu_bar = new_val | ||
|
||
@Property(bool) | ||
def hideNavBar(self): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
nav bar when the display is loaded. | ||
|
||
Returns | ||
------- | ||
hide_nav_bar : bool | ||
The configured value | ||
""" | ||
return self._hide_nav_bar | ||
|
||
@hideNavBar.setter | ||
def hideNavBar(self, new_val): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
nav bar when the display is loaded. | ||
|
||
Parameters | ||
---------- | ||
new_val : bool | ||
The new configuration to use | ||
""" | ||
self._hide_nav_bar = new_val | ||
|
||
@Property(bool) | ||
def hideStatusBar(self): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
status bar when the display is loaded. | ||
|
||
Returns | ||
------- | ||
hide_status_bar : bool | ||
The configured value | ||
""" | ||
return self._hide_status_bar | ||
|
||
@hideStatusBar.setter | ||
def hideStatusBar(self, new_val): | ||
""" | ||
Whether or not the widget should automatically disable the | ||
status bar when the display is loaded. | ||
|
||
Parameters | ||
---------- | ||
new_val : bool | ||
The new configuration to use | ||
""" | ||
self._hide_status_bar = new_val |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.