Skip to content

Commit 39e3f78

Browse files
committed
here we go. scaffold created.
1 parent 4a9353f commit 39e3f78

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

app.py

+49-9
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,60 @@ def init_app(self):
2121
"""
2222
Called as the application is being initialized
2323
"""
24-
2524
# first, we use the special import_module command to access the app module
2625
# that resides inside the python folder in the app. This is where the actual UI
2726
# and business logic of the app is kept. By using the import_module command,
2827
# toolkit's code reload mechanism will work properly.
2928
app_payload = self.import_module("app")
3029

31-
# now register a *command*, which is normally a menu entry of some kind on a Shotgun
32-
# menu (but it depends on the engine). The engine will manage this command and
33-
# whenever the user requests the command, it will call out to the callback.
30+
# now register a panel, this is to tell the engine about the our panel ui
31+
# that the engine can automatically create the panel - this happens for
32+
# example when a saved window layout is restored in Nuke or at startup.
33+
self._unique_panel_id = self.engine.register_panel(self.create_panel)
34+
35+
# keep track of the last dialog we have created
36+
# in order to support the DIALOG mode for the navigate() method
37+
self._current_dialog = None
38+
39+
# also register a menu entry on the shotgun menu so that users
40+
# can launch the panel
41+
self.engine.register_command("Shotgun Chat...",
42+
self.create_panel,
43+
{"type": "panel",
44+
"short_name": "shotgun_chat"})
3445

35-
# first, set up our callback, calling out to a method inside the app module contained
36-
# in the python folder of the app
37-
menu_callback = lambda : app_payload.dialog.show_dialog(self)
46+
def create_dialog(self):
47+
"""
48+
Shows the panel as a dialog.
49+
50+
Contrary to the create_panel() method, multiple calls
51+
to this method will result in multiple windows appearing.
52+
53+
:returns: The widget associated with the dialog.
54+
"""
55+
app_payload = self.import_module("app")
56+
widget = self.engine.show_dialog("Chat", self, app_payload.AppDialog)
57+
self._current_dialog = widget
58+
return widget
3859

39-
# now register the command with the engine
40-
self.engine.register_command("Show Starter Template App...", menu_callback)
60+
def create_panel(self):
61+
"""
62+
Shows the UI as a panel.
63+
Note that since panels are singletons by nature,
64+
calling this more than once will only result in one panel.
65+
66+
:returns: The widget associated with the panel.
67+
"""
68+
app_payload = self.import_module("app")
69+
70+
# start the UI
71+
try:
72+
widget = self.engine.show_panel(self._unique_panel_id, "Chat", self, app_payload.AppDialog)
73+
except AttributeError, e:
74+
# just to gracefully handle older engines and older cores
75+
self.log_warning("Could not execute show_panel method - please upgrade "
76+
"to latest core and engine! Falling back on show_dialog. "
77+
"Error: %s" % e)
78+
widget = self.create_dialog()
79+
80+
return widget

python/app/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
99
# not expressly granted therein are reserved by Shotgun Software Inc.
1010

11-
from . import dialog
11+
from .dialog import AppDialog

python/app/dialog.py

-11
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@
2626

2727
from .delegate_list_item import ListItemDelegate
2828

29-
def show_dialog(app_instance):
30-
"""
31-
Shows the main dialog window.
32-
"""
33-
# in order to handle UIs seamlessly, each toolkit engine has methods for launching
34-
# different types of windows. By using these methods, your windows will be correctly
35-
# decorated and handled in a consistent fashion by the system.
36-
37-
# we pass the dialog class to this method and leave the actual construction
38-
# to be carried out by toolkit.
39-
app_instance.engine.show_dialog("Starter Template App...", app_instance, AppDialog)
4029

4130
class AppDialog(QtGui.QWidget):
4231
"""

0 commit comments

Comments
 (0)