-
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 #633 from hhslepicka/install_inspector
ENH: Add utilities.shortcuts and initial shortcut ConnectionInspector
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
from qtpy import QtWidgets, QtGui, QtCore | ||
|
||
|
||
def install_connection_inspector(parent, keys=None): | ||
""" | ||
Install a QShortcut at the application which opens the PyDM Connection | ||
Inspector | ||
Parameters | ||
---------- | ||
parent : QWidget | ||
A shortcut is "listened for" by Qt's event loop when the shortcut's | ||
parent widget is receiving events. | ||
keys : QKeySequence, optional | ||
Default value is `Alt+C` | ||
""" | ||
from pydm.connection_inspector import ConnectionInspector | ||
|
||
def show_inspector(): | ||
c = ConnectionInspector(parent=parent) | ||
c.show() | ||
|
||
parent = parent or QtWidgets.QApplication.desktop() | ||
|
||
if keys is None: | ||
keys = QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_C) | ||
shortcut = QtWidgets.QShortcut(keys, parent); | ||
shortcut.setContext(QtCore.Qt.ApplicationShortcut) | ||
shortcut.activated.connect(show_inspector) |
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