When the user selects a module from the Module list in the context bar, the GUI infrastructure does the following:
Calls the deactivate method of the current GUI module.
Calls the activate method of the GUI module selected by the user.
To switch to a GUI module using a script, you can use the switchModule method. For example, if you want to switch to your module upon application startup, you can add the following line to the application startup file:
switchModule('My Module')This line should appear just before the app.run() statement.
You can use the setSwitchModuleHook( function) method to set a callback function that will be invoked when the user switches into a GUI module. Every time the user switches into a GUI module, your function will be called and the name of the module will be passed into the function. For example,
def onModuleSwitch(moduleName): if moduleName == 'Part': # Do part module tasks elif moduleName == 'Mesh': # Do mesh module tasks etc. setSwitchModuleHook(onModuleSwitch)