Skip to main content
Participant
June 6, 2023
Question

Invoking a python plugin using a keyboard shortcut

  • June 6, 2023
  • 1 reply
  • 268 views

Hello, Is there a way to invoke my python plugin using a keyboard shortcut/key? Currently, the only way I know is by invoking it through a menu widget.

This topic has been closed for replies.

1 reply

Inspiring
June 26, 2023

If you are creating a menu item within Substance, you can assign a key sequence to the QAction. This snippet shows me assigning Ctrl + Shift + U to a menu item "Load Plugin"

 

# assuming you have made a menu widget called "my_menu"
self.load_plugin_action = QtWidgets.QAction('Load Plugin', parent=my_menu)

# set the key sequence for the action, which will also show up in the UI as a hint
self.load_plugin_action.setShortcut(
    QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_U
)

 

Inspiring
June 26, 2023

Can't edit my post but there is a close parenthesis missing after "...QtCore.Qt.Key_U"