How to make Icon buttons and Shortcut in python plugin
-
Sorry for basic question
First time building a plugin.
Have read through the Python Doc but cannot understand
how to make some Icon Buttons and Shortcut key so users can run some of my script with clicking the icon buttons and some of my script with press shortcut key in keyboard.Any help would be appreciated
-
Hi,
Welcome to the forum, you do not need to be sorry, we all ask basic question.There are differences between creating a script and plugins. Script is something you create inside the Script Manager. You can save them in a file and this file extension is
.py
. Plugins are something you must create in an external editor and save the file with the extension.pyp
or.pypv
(for encrypted files) with a certain plugin structureThere are differents way to create an icon and a shortcut.
icon for script:- as state here, you can just use the command in the Script Manager to load a file that will be used as the icon for that script. If you save the script or already saved it, the picture will be saved in the same directory with the same name as the script.
- save the picture you want to use for a script in the same directory than your script with the same filename.
icon for plugins:
Plugins are registered using register commands like RegisterCommandPlugin, most of those commands allow you to pass as an argument the bitmap that will be used as the icon for that plugin.Shortcuts:
To create shortcuts you must use the function AddShortcut you can check this thread where Maxime answer the question in the second part of his thread.Finally, you might want to create a palette to store your different icons and add the possibility to load the palette. Ferdinand answer this question in this thread.
Cheers,
Manuel