[Bf-blender-cvs] [9f08a9c077] app-templates: Example panel for a template

Campbell Barton noreply at git.blender.org
Fri Mar 17 10:04:46 CET 2017


Commit: 9f08a9c0773b25384247b43d381109e11afcda56
Author: Campbell Barton
Date:   Fri Mar 17 20:09:08 2017 +1100
Branches: app-templates
https://developer.blender.org/rB9f08a9c0773b25384247b43d381109e11afcda56

Example panel for a template

Just add a single panel to show a template can define it's own panels.

===================================================================

M	release/datafiles/app_templates/101/template/__init__.py
A	release/datafiles/app_templates/101/template/ui.py

===================================================================

diff --git a/release/datafiles/app_templates/101/template/__init__.py b/release/datafiles/app_templates/101/template/__init__.py
index 07b7334c5f..901d21cfc8 100644
--- a/release/datafiles/app_templates/101/template/__init__.py
+++ b/release/datafiles/app_templates/101/template/__init__.py
@@ -64,12 +64,17 @@ class AppStateStore:
 
 app_state = AppStateStore()
 
+from . import ui
 
 def register():
     print("Template Register", __file__)
     app_state.backup()
 
+    ui.register()
 
 def unregister():
     print("Template Unregister", __file__)
+
+    ui.unregister()
+
     app_state.restore()
diff --git a/release/datafiles/app_templates/101/template/ui.py b/release/datafiles/app_templates/101/template/ui.py
new file mode 100644
index 0000000000..028fa82bdf
--- /dev/null
+++ b/release/datafiles/app_templates/101/template/ui.py
@@ -0,0 +1,58 @@
+
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8-80 compliant>
+
+import bpy
+from bpy.types import (
+    Panel,
+)
+
+from bl_ui.properties_render import RenderButtonsPanel
+
+
+# Just an example of a render panel
+class RENDER_PT_render_simple(Panel, RenderButtonsPanel):
+    bl_label = "101 Render Panel"
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+    def draw(self, context):
+        layout = self.layout
+
+        row = layout.row(align=True)
+        row.operator("render.render", text="Render", icon='RENDER_STILL')
+
+
+classes = (
+    RENDER_PT_render_simple,
+)
+
+def register():
+    print("Template UI Register", __file__)
+    from bpy.utils import register_class
+
+    for cls in classes:
+        register_class(cls)
+
+
+def unregister():
+    print("Template UI Unregister", __file__)
+    from bpy.utils import unregister_class
+
+    for cls in classes:
+        unregister_class(cls)




More information about the Bf-blender-cvs mailing list