-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1007 from jbellister-slac/help_files
ENH: Add support for loading help files for displays
- Loading branch information
Showing
12 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,19 @@ | ||
================= | ||
Adding Help Files | ||
================= | ||
|
||
If you are creating a display and would like to add some documentation on how it works, PyDM provides the ability | ||
to do this with a minimum of extra effort. By placing a .txt or .html file in the same directory as your display, | ||
PyDM will load this file and automatically add it to both the View menu of the top menu bar, as well as the right | ||
click menu of widgets on the display. | ||
|
||
In order for PyDM to associate the help file with your display, it must have the same name as your display file. For | ||
example, let's say that we have a file called drawing_demo.ui. By adding a file called drawing_demo.txt to the same | ||
location, PyDM will load that file along with the display. | ||
|
||
.. figure:: /_static/help_files.gif | ||
:scale: 100 % | ||
:align: center | ||
:alt: Help files | ||
|
||
Where to find the automatically loaded help file |
This file contains 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 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 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 @@ | ||
from .help_window import HelpWindow |
This file contains 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,33 @@ | ||
from pathlib import Path | ||
from qtpy.QtWidgets import QTextBrowser, QVBoxLayout, QWidget | ||
from qtpy.QtCore import Qt | ||
from typing import Optional | ||
|
||
|
||
class HelpWindow(QWidget): | ||
""" | ||
A window for displaying a help file for a PyDM display | ||
Parameters | ||
---------- | ||
help_file_path : str | ||
The path to the help file to be displayed | ||
""" | ||
def __init__(self, help_file_path: str, parent: Optional[QWidget] = None): | ||
super().__init__(parent, Qt.Window) | ||
self.resize(500, 400) | ||
|
||
path = Path(help_file_path) | ||
self.setWindowTitle(f'Help for {path.stem}') | ||
|
||
self.display_content = QTextBrowser() | ||
|
||
with open(help_file_path) as file: | ||
if path.suffix == '.txt': | ||
self.display_content.setText(file.read()) | ||
else: | ||
self.display_content.setHtml(file.read()) | ||
|
||
self.vBoxLayout = QVBoxLayout() | ||
self.vBoxLayout.addWidget(self.display_content) | ||
self.setLayout(self.vBoxLayout) |
This file contains 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 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 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 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 @@ | ||
This is a test help file for the test.ui display |
This file contains 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 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