Sample Files
Introducing sample Python plugin files.
Create a plugin file and place it in the plugin directory ($EBV_CONFIG_DIR/plugins
. By default, ~/.config/ncs/nebv/plugins
), you can add and use functions to neoEBV.
One or more “plugin classes” can be defined in a plugin file, and each “plugin class” can define a function.
.py
extension.pynebv.Plugin
.location
.label
for display. This will be used as the name of the menu item.contact
.exec
as a method.
exec
method must have params
as well as the argument self
.location
.# Please change the class name to something appropriate
Plugin): # Specifies where to add the plugin
Plugin: # Specifies where to add the plugin
# By intentionally specifying incorrectly, you can see a list of possible locations in the error message
location = 'file_panel/panel_menu'
# Specifies the name displayed on the menu and tool button
label = 'Sample Plugin 1'
# Specifies the plugin creator's contact information
contact = 'sample creator'
# Describes the process when executing the plugin
def exec(self, params): print('Hello, world!
print('Hello, world!')
files = pynebv.file.list()
if len(files) == 0: return
return
files.color = 'Blue'
error_files = pynebv.file.items('*error*')
if len(error_files) == 0: return
return
error_files.hatch = 'Blank'
error_files.bold = True
error_files.color = 'Red'
The following locations can be specified with location
:
location | plugin type |
---|---|
main_window/global_menu | global_menu |
file_panel/panel_menu | panel_menu |
file_panel/item_menu | item_menu |
calculation_panel/panel_menu | panel_menu |
calculation_panel/item_menu | item menu |
registration_panel/panel_menu | panel_menu |
registration_panel/item_menu | item menu |
inspection_panel/panel_menu | panel_menu |
inspection_panel/item_menu | item menu |
mark_panel/panel_menu | panel_menu |
mark_panel/item_menu | item_menu |
matching_template_panel/panel_menu | panel menu |
matching_template_panel/figure_item_menu | item menu |
matching_template_panel/measurement_item_menu | item menu |
measurement_panel/panel_menu | panel menu |
measurement_points_tab/tab_menu | panel menu |
measurement_points_tab/item_menu | item menu |
measurement_alignments_tab/item_menu | item menu |
ls_detect_dialog/dialog_menu | panel menu |
ls_detect_dialog/item_menu | item menu |
screen/context_menu | screen context menu |
mini_map_panel/context_menu | panel menu |
console_panel/panel_menu | panel menu |
python_panel/panel_menu | panel menu |
note_panel/panel_menu | panel menu |
help_panel/panel_menu | panel menu |
The details of where to add the plugin menu and button for each “plugin type” as determined by location
are as follows.
Plugin Type | Location where menu item is added | Location where Run button is added |
---|---|---|
Global Menu | Hamburger Menu at the top right of the app | Main Toolbar |
panel menu | the ... menu in the upper right of the panel (or Tab face) indicated by location |
the toolbar of the corresponding panel (if there is no corresponding toolbar, it will not be added) |
Item menu | menu that appears when you right-click (or right range-select) an item in the list indicated by location | not displayed on the toolbar |
screen context menu | menu that appears when you right-click (or right range-select) on the screen | not shown on the toolbar |
The location
of the plugin determines the params
argument given at runtime (when the exec
method is called).
Context menus (item menus, screen menus) will set the following information.
params content | value to be set | type of plugin to be set |
---|---|---|
items | list of items selected (or within the selected range) | item menu, screen context menu |
point | the position (in um) where the mouse was released. (<x>,<y>) |
screen context menu |
area | area selected by mouse (in um). (<x1>,<y1>,<x2>,<y2>) |
screen context menu |
start_end | the position (in um) where the mouse is pressed and released. (<start x>,<start y>,<end x>,<end y>) |
screen context menu |
The params
argument is a dictionary, e.g. for a screen context menu
params = {"items" : [item1, item2], "point" : (<x>,<y>), "area" : (<x1>,<y1>,<x2>,<y2>), "start_end" : (<start x>,<start y>,<end x>,<end y>)}
Empty for directly executable menus (global and panel menus).
params = {}
The exec
method describes the functionality you want to achieve with the plugin.
Please refer to this pynebv reference page for available methods.
The current plugin loading status is displayed on the Plugins
tab of the About dialog that appears from the main menu Help
/About...
from the main menu.
In the same tab, there is also a Relaod Plugin
button. This button allows you to reload the plugin. Please use this function when developing plug-ins.
The menu item Plugins
is added to the menu according to the location
, and a plugin menu name which is specified by label
. In some cases, a button will also be added to the toolbar.
Selecting this item calls the exec
method of the plugin class and executes the plugin.
Standard output and standard error output can be used for calculations and other output from plugins. When executed from the GUI, the output content is displayed in the neoEBV Console Panel.
Please note that the content will not be visible unless the Others
filter is turned ON.
Registered plug-ins are loaded at startup and can be executed in the neoEBV python script function as follows
pynebv.plugin['SamplePlugin1'].exec({})
In this case, output to standard output and standard error is treated as script output.
This means that when output during execution without GUI (when the --headless
option is specified at startup), it is directly output to the terminal, and when output with GUI present (when the --headless
option is not specified at startup), it is displayed in the Python Panel.
Introducing sample Python plugin files.