I want my scripts go in menu: Tools → My Commands → Draw
instead of
Tools → Scripts → Draw
Is there a way to do it?
window.createAction("YDraw", "Draw", "tools/mycommads")
Does not seem to work.
I want my scripts go in menu: Tools → My Commands → Draw
instead of
Tools → Scripts → Draw
Is there a way to do it?
window.createAction("YDraw", "Draw", "tools/mycommads")
Does not seem to work.
You have to add a QMenu to it, here is an example:
def createActions(self, window):
action = window.createAction("shapesAndLayers", "Shapes And Layers", "tools/scripts")
menu = QtWidgets.QMenu("shapesAndLayers", window.qwindow())
action.setMenu(menu)
subaction1 = window.createAction("shapesAndLayersFontAdjust", "Adjust Font Sizes...", "tools/scripts/shapesAndLayers")
subaction1.triggered.connect(self.slotFontAdjust)
Perfect. Works for me. Thank you!
thank you @KnowZero this helped me to clean up my stuff so much.
I was wondering if you could go deeper in menu?
I was trying to do this:
def createActions(self, window):
action = window.createAction("yap", "YAP", "tools")
menu = QtWidgets.QMenu("yap", window.qwindow())
action.setMenu(menu)
action2 = window.createAction("yap/configure", "Configure", "tools/YAP")
menu2 = QtWidgets.QMenu("yap", window.qwindow())
action2.setMenu(menu2)
subaction = window.createAction("YQuickShadingConfigure", "Plugin", "tools/YAP/Configure")
subaction.triggered.connect(self.dlg.exec)
Though Plugin is under ‘tools/YAP’.
I feel like I am making a silly mistake.
Well first of all, I would not use “/” for naming the action. Either do things like yapConfigure or yap_configure. Second of all, the path should be “tools/yap”, not “tools/YAP”. yap is the object name, while YAP is the display name.
To demonstrate how I do it for show eraser:
self.action = window.createAction("shapesAndLayersShowEraser", "Show Eraser Cursor", "tools/scripts/shapesAndLayers")
menu = QtWidgets.QMenu("shapesAndLayersShowEraser", window.qwindow())
self.action.setMenu(menu)
self.subaction1 = window.createAction("shapesAndLayersShowEraserEnable", "Enable", "tools/scripts/shapesAndLayers/shapesAndLayersShowEraser")
self.subaction1.setCheckable(True)
subaction2 = window.createAction("shapesAndLayersShowEraserConfig", "Configure...", "tools/scripts/shapesAndLayers/shapesAndLayersShowEraser")
subaction2.triggered.connect(self.slotOpenConfig)