Skip to content

Instantly share code, notes, and snippets.

@antiero
Created July 10, 2014 14:17
Show Gist options
  • Save antiero/d32585af7038da249c61 to your computer and use it in GitHub Desktop.
Save antiero/d32585af7038da249c61 to your computer and use it in GitHub Desktop.
Hiding actions on right-click menus
import hiero.core
from PySide.QtGui import QAction
class ContextMenuOverride(QAction):
def __init__(self):
QAction.__init__(self, "kill menu", None)
hiero.core.events.registerInterest("kShowContextMenu/kTimeline", self.eventHandler)
hiero.core.events.registerInterest("kShowContextMenu/kBin", self.eventHandler)
hiero.core.events.registerInterest("kShowContextMenu/kSpreadsheet", self.eventHandler)
self.menuActionNamesToHide = ["New",
"Set Media Colour Transform",
"Localisation",
"Import",
"Tags"]
def eventHandler(self, event):
menuActions = event.menu.actions()
for action in menuActions:
menuItemTitle = ""
if action.menu():
menuItemTitle = action.menu().title()
else:
menuItemTitle = action.text()
if menuItemTitle in self.menuActionNamesToHide:
action.setVisible(False)
action.menu().setVisible(False)
cmo = ContextMenuOverride()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment