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?
So to start with you could launch your app via the before_app_launch.py hook with the following code.
# launch the publish app
engine = self.parent.engine
engine.execute_in_main_thread(engine.commands["Publish..."]["callback"])
# 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 before_app_launch.py hook until the window is closed.