Your add-in may control its behavior by implementing any or all of the following methods, from UserCustomization.UserCustomBase. Some code from BackgroundCustom.py is provided to illustrate sample implementations of these methods.
from UserCustomization import UserCustomBase
class BackgroundCustom(UserCustomBase):
def __init__(self):
self.__myCallMenu = None
self.__myCallIdBlack = None
self.__myCallIdWhite = None
self.__myCallIdDef = None
self.__myCall800x600 = None
self.__myInterpreter = LocalInterpreter()
# ...
- def getInterpreter( self, isInteractive ) If you are defining a custom message interpreter, this method must return it. isInteractive will be True when Showcase is
run in the interactive mode (which is currently always). For more on message interpreters, see Handling Messages (Message Interpreters).
def getInterpreter(self,isInteractive):
if isInteractive:
return self.__myInterpreter
return None
- def appendMenu( self, menuInterpreter ) Lets you add menus after the Help menu in Showcase. The new menus must be derived from GenericMenu.GenericMenu and can be
added by calling the menuInterpreter.appendMenu() method. You must populate your custom menu fully before adding it. An example
of the use of appendMenu can be found in the extras/Interactive/GridArrangeCustom.py file.
- def appendMenuItems( self, id, menu ) Lets you add menu items to existing menus. The id argument specifies which menu you are currently processing (e.g., File,
Edit, View, Presentation, Behavior, Help, Scene, Select). You can add menu items using the menu.appendItem( "Menu title",
callback ) method. The callback method has signature callback( self, event ) where event is of the type RTFapi.Event. The
callback functions will usually just issue messages, using self.sendMessage() method.
def appendMenuItems(self,id,menu):
if "View" == id:
menu.appendSeparator()
self.__myCallMenu = menu
self.__myCallIdDef = menu.appendItem(_( 'Default background' ), self.__onBackgroundDefault )
self.__myCallIdBlack = menu.appendItem(_( 'Black background' ), self.__onBackgroundBlack )
self.__myCallIdWhite = menu.appendItem(_( 'White background' ), self.__onBackgroundWhite )
self.__myCall800x600 = menu.appendItem(_( 'Set size to 800x600'), self.__onSize800x600)
- def appendPopupMenuItems( self, id, popupMenu, data ) Similar to appendMenuItems(), this method lets you append items to the popup menus. The id argument specifies which popup
you are currently processing (e.g., "MaterialSelector", "EnvironmentSelector"). Menu items must be instances of GenericPopupMenu.GenericPopupMenuItem
and can be added using the popupMenu.append() method.
- def appendSelectItems(self, id, popupMenu) This method is used in the behavior selection process. It can be used to add a new popup menu item to the popupMenu passed
to this method.
- def enableMenuStates( self, id, enableStates ) For a given menu (identified by id argument), set the enableStates[menuItemId] method to True or False, depending on whether
the menu item with the given ID should be enabled or not.
def enableMenuStates(self,id,enableStates):
if "View" == id:
enableStates[self.__myCallIdDef] = True
enableStates[self.__myCallIdBlack] = True
enableStates[self.__myCallIdWhite] = True
enableStates[self.__myCall800x600] = True
- def getDefaultIcon( self, id, data ) This method is used for behaviors. Given the ID ("BehaviorSelector", etc.) and some data (behavior in the BehaviorSelector
case), return the icon used for this object.
- def getDefaultImage( self, id, data ) This method is used for setting behavior images. Given the ID ("BehaviorSelector", etc.) and some data (behavior in the BehaviorSelector
case), return the image used for this object.
- def inputDevices( self, uiWindow, eventQueue ) This method allows additional input devices (game controllers, etc.) to be added to the application. On startup, this method
will be called with a window and a reference to the application event queue where mouse and keyboard events can be sent.
- def resetMenuStates(self, id) This method is used to reset the values of a add-in's menu items. For example, it can be used to set or clear the checked
state of a menu item.
- def uiWindowHookup( self, uiWindow, parentWindow ) Reserved for future use.