Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app_display_mode to choose default launch mode (panel or dialog) #42

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,33 @@ def init_app(self):
self._current_dialog = None
self._current_panel = None

# Register the app as a panel.
self._unique_panel_id = self.engine.register_panel(self.create_panel)

# Register a menu entry on the ShotGrid menu so that users can launch the panel.
self.engine.register_command(
"Scene Breakdown...",
self.create_panel,
{"type": "panel", "short_name": "breakdown"},
)
if self.get_setting("app_display_mode") == "panel":

# Register the app as a panel.
self._unique_panel_id = self.engine.register_panel(self.create_panel)

# Register a menu entry on the ShotGrid menu so that users can launch the panel.
self.engine.register_command(
"Scene Breakdown...",
self.create_panel,
{"type": "panel", "short_name": "breakdown"},
)

elif self.get_setting("app_display_mode") == "dialog":

# Register the app as a dialog
# Register a menu entry on the ShotGrid menu so that users can launch the dialog.
self.engine.register_command(
"Scene Breakdown...",
lambda: self.create_dialog(),
{"type": "dialog", "short_name": "breakdown"},
)

else:
self.logger.error(
"An invalid app_display_mode was configured. `{}` is not a valid app_display_mode "
"setting!".format(self.get_setting("app_display_mode"))
)

def show_dialog(self):
"""Show the Scene Breakdown 2 App dialog."""
Expand Down
5 changes: 5 additions & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

configuration:

app_display_mode:
type: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @RicardoMusch ,
Instead of using a string setting here, I'd prefer to use a boolean to switch the display mode (something like the modal mode for tk-multi-publish2)
I think it's safer and should avoid your "else" condition.

default_value: panel
description: Specify if the app should launch as `panel` or `dialog`. Not all engines support panels.

hook_scene_operations:
type: hook
default_value: "{self}/{engine_name}_scene_operations.py"
Expand Down