Experemental XML UI, define panels/menus/headers which load at startup like python scripts.

- 2 panels implimented in properties_render_test.xml (Render Dimensions and Stamp)
- only enabled in debug mode.
- poll() functions are not supported yet.
- as stated above experemental, we'll see if this is at all useful, remove if not.
- XML could be replaced with JSON or YAML.
This commit is contained in:
Campbell Barton
2010-08-07 16:21:15 +00:00
parent 2b3c8bdc27
commit 057aac553b
4 changed files with 266 additions and 4 deletions

View File

@@ -30,6 +30,8 @@ import sys as _sys
from _bpy import blend_paths
from _bpy import script_paths as _bpy_script_paths
_TEST_XML = _bpy.app.debug
def _test_import(module_name, loaded_modules):
import traceback
import time
@@ -52,6 +54,35 @@ def _test_import(module_name, loaded_modules):
loaded_modules.add(mod.__name__) # should match mod.__name__ too
return mod
if _TEST_XML:
# TEST CODE
def _test_import_xml(path, f, loaded_modules):
import bpy_xml_ui
import traceback
f_full = _os.path.join(path, f)
_bpy_types._register_immediate = True
try:
classes = bpy_xml_ui.load_xml(f_full)
except:
traceback.print_exc()
classes = []
_bpy_types._register_immediate = False
if classes:
mod_name = f.split(".")[0]
# fake module
mod = type(traceback)(mod_name)
mod.__file__ = f_full
for cls in classes:
setattr(mod, cls.__name__, cls)
loaded_modules.add(mod_name)
_sys.modules[mod_name] = mod
mod.register = lambda: None # quiet errors
return mod
def modules_from_path(path, loaded_modules):
"""
@@ -79,6 +110,10 @@ def modules_from_path(path, loaded_modules):
else:
mod = None
if _TEST_XML:
if mod is None and f.endswith(".xml"):
mod = _test_import_xml(path, f, loaded_modules)
if mod:
modules.append(mod)