Launch app from before_app_launch


In a config, I’d like to launch a simple app popup window from inside the execute method of the before_app_launch hook.

Here’s the scenario:
When the BeforeAppLaunch execute function is running, I am checking to see if the DCC app that is being launched is already running. If it is, I want to launch my custom app that displays a dialog window. (I used the tk-multi-starterapp to build my dialog panel.)

In testing my app dialog panel, it runs via a Shotgun toolkit menu command and also via a tk-shell command. However, I can’t quite figure out how to access and run it from within the before_app_launch execute function.

Is this possible - can I somehow import my app and run it from before_app_launch? If not, what would I need to change to use it there?

Thanks for any help,


Hi Rich

Welcome to the forums!!

So to start with you could launch your app via the hook with the following code.

# launch the publish app
engine = self.parent.engine
# to see all the available commands, print `engine.commands`

This in itself wont make it blocking. However you can use the engine.show_modal in your app to display your window in a blocking way.

Using the starter app as an example you would change this line:

To be show_modal rather than shot_dialog. This will prevent it from continuing with the hook until the window is closed.



Thanks, Phil!

That opens up a whole new world of ideas. I did not know it was that simple to run any of the registered app commands!

I needed only two lines:

engine = self.parent.engine
engine.execute_in_main_thread(engine.commands['Illustrator Task Start']['callback'])