From eecdd445e2808ce44c39ab8b4febebcdf50e3e10 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Sun, 20 Feb 2011 11:43:47 +0100 Subject: [PATCH] don't overwrite scene.__getitem__ for glob-style access to scene objects It's breaking more complexcases, e.g. scene["model"].selection=scene["model"].view.Select('aname=CA') To use the glob-style access, use scene.Match("*") --- modules/gfx/pymod/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/gfx/pymod/__init__.py b/modules/gfx/pymod/__init__.py index 4dfc0fd64..5788da8cf 100644 --- a/modules/gfx/pymod/__init__.py +++ b/modules/gfx/pymod/__init__.py @@ -141,7 +141,7 @@ def FitToScreen(gfx_ent, width=None, height=None, margin=0.01): scene.SetRTC(rtc) -class GfxNodeListAttrProxy: +class GfxNodeListAttrProxy(object): def __init__(self, node_list, name): self._node_list=node_list self._name=name @@ -164,6 +164,11 @@ class GfxNodeListProxy(object): return super(GfxNodeListProxy, self).__getattr__(name) return GfxNodeListAttrProxy(self._nodes, name) + def __dir__(self): + if len(self._nodes)==0: + return dir(None) + return dir(self._nodes[0]) + def __setattr__(self, name, value): if name.startswith('_'): super(GfxNodeListProxy, self).__setattr__(name, value) @@ -183,4 +188,4 @@ def _Match(scene, pattern="*"): return matches return GfxNodeListProxy(_Recurse("", Scene().root_node, pattern)) -SceneSingleton.__getitem__=_Match +SceneSingleton.Match=_Match -- GitLab