| |
- builtins.object
-
- RibbonAddInABC
class RibbonAddInABC(builtins.object) |
|
Abstract base class for making add-ins in SIMCA.
To add a command button to the ribbon in simca, make a class that inherits RibbonAddInABC
and overload get_button_name() and on_command().
Optionally overload enable_command if the button needs to be disabled.
Optionally, in the derived class __init__() method set:
tooltip to the tooltip text used for the button.
icon_file_name to the name of the file that contains the button icon.
The resulting buttons will be placed in the same ribbon group when
several classes in the same module inherits RibbonAddInABC.
Use variables group_name and group_order to control the name of the group and the order of the
buttons within the group (see example).
Attributes:
icon_file_name The name of a file that contains an icon for the button.
Note that this is only the name of the file ('myicon.png'),
not the full path to the file (r'c:\icons\myicon.png').
The icon file must be located in the same directory as the module
that contains the class that defines the command button.
Supported file formats are bmp, png, jpeg, wmf, ico and gif.
Size for full height buttons are 32*32 pixels and
16*16 pixels for half height buttons.
If the string is empty (the default) a default icon will be used.
tooltip Set this to the tooltip string that will be displayed when
the user hoovers over the button.
Example:
from ribbonabc import RibbonAddInABC
from tkinter import messagebox, Tk
from umetrics import SimcaApp
def show_message(message):
# Show a tkinter messagebox with the message.
tk_main=Tk()
tk_main.withdraw()
messagebox.showinfo(title='Ribbon add in', message=message)
tk_main.destroy()
class CompleteCommand(RibbonAddInABC):
def __init__(self):
self.icon_file_name = 'ribbon_example.png'
self.tooltip = 'This example has an enabler, a small button, an icon and a tooltip'
def enable_command(self):
# Disable button if SIMCA has no active project
with SimcaApp.get_active_project() as project:
if not project:
return False
return True
def on_command(self):
show_message('Complete example clicked')
def get_button_name(self):
return 'Complete'
class MinimalCommand(RibbonAddInABC):
def on_command(self):
show_message('Minimal example clicked')
def get_button_name(self):
return 'Minimal'
group_name = 'Ribbon example'
group_order = [MinimalCommand, CompleteCommand] |
|
Methods defined here:
- enable_command(self)
- Overload enable_command if the button should be disabled sometimes.
Return True to enable the button and False to disable it.
The method will be called whenever SIMCA is idle so it is important
that it is fast.
The default is to always enable the button.
- get_button_name(self)
- get_button_name must be overloaded and return a string that contains the
name of the command button.
- on_command(self)
- on_command must be overloaded. It will be called when the user presses the button.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __abstractmethods__ = frozenset({'get_button_name', 'on_command'})
- icon_file_name = ''
- tooltip = ''
| |