You can write your own activate or deactivate methods if you need to perform any special processing when entering or leaving a module. If you need to issue a command to the kernel when the user changes modules, you must use the sendCommandString method of the AFXModuleGui object to issue the command. If you do not use the sendCommandString method, the application may hang while trying to process the command. You should enclose the statements that call the sendCommandString method in a try block to catch any exceptions generated by the kernel command. 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) |