3. Generic Menu Items¶
This section explains how to create and edit generic menu items.
Files of this video:
3.1. Usage¶
A generic menu item is a simple way to access common tasks from a menu, either from the top level or contextual.
Menu items can also be defined as element of a plugin.
3.2. File location¶
To be recognized by the application, generic menu items should be located in one of these folders:
- %LocalAppData%/ORS/Dragonfly(version)/pythonUserExtensions/GenericMenuItems (available for the current user)
- %ProgramData%/ORS/Dragonfly(version)/pythonAllUsersExtensions/GenericMenuItems (available for all users)
- %ProgramData%/ORS/Dragonfly(version)/python/OrsPythonPlugins/OrsGenericMenuItems/menuItems (distributed with the application)
3.3. File creation¶
To create a generic menu item, start the application,
start the OrsPythonPlugins.OrsGenericMenuItemGenerator.OrsGenericMenuItemGenerator
(found in Developer/Generic Menu Item Generator),
fill in the required fields and press the button Create menu item.
3.4. File edition¶
Open the file in a text editor. Fill in the required methods.
For more information about menu items, see ORSServiceClass.decorators.infrastructure.menuItem().
3.5. Demos¶
Top level generic menu item
Source code example:
- Download the
file; - Put that file into a generic menu item extension folder;
- Start the application;
- Open the top level menu Demos to see the menu item named Demo: top level generic menu item;
- By clicking on the menu item, a web browser will be opened on the Dragonfly developer site.
Contextual generic menu item
Source code example:
- Download the
file; - Put that file into a generic menu item extension folder;
- Start the application;
- Import a dataset;
- Create a ROI having the same shape as the dataset;
- When selecting exactly 1 dataset and 1 ROI and doing a right-click on it, the contextual menu will contain the menu item named Demo: overwrite channel with ROI. If these objects have the same shape (size, spacing, direction), this menu item will be enabled. When clicking on that menu item, every painted pixel of the ROI will put a value of 0 in the dataset.
See also