Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用InstanceEditor的自定义视图_Python_Enthought_Traitsui - Fatal编程技术网

Python 使用InstanceEditor的自定义视图

Python 使用InstanceEditor的自定义视图,python,enthought,traitsui,Python,Enthought,Traitsui,我正在开发一个动态的Traits用户界面,在这里我可以选择用于特定实例的类。我使用InstanceEditor和包含InstanceFactoryChoice实例的“values”参数,使它工作得很好 当我要为所选实例指定要使用的视图时,会出现问题。如果我省略了“values”参数,那么使用“view”参数是有效的,但是使用它我得到了默认的视图。视图的相关部分如下所示: Item('item', show_label=False, editor=InstanceEditor(

我正在开发一个动态的Traits用户界面,在这里我可以选择用于特定实例的类。我使用InstanceEditor和包含InstanceFactoryChoice实例的“values”参数,使它工作得很好

当我要为所选实例指定要使用的视图时,会出现问题。如果我省略了“values”参数,那么使用“view”参数是有效的,但是使用它我得到了默认的视图。视图的相关部分如下所示:

Item('item',
     show_label=False,
     editor=InstanceEditor(
         view=item_view,
         values=[InstanceFactoryChoice(klass=k) for k in classes],
         editable=True),
     style='custom')
更让我困惑的是,当我使用“简单”样式而不是“自定义”样式时,它也能按预期工作(即使用“item_view”视图显示实例)。但是,当视图出现在一个新窗口中时,我希望它是内联的


我是不是遗漏了什么?我使用的是TraitsUI 4.3。

好的,在一些源代码分析之后,我发现在InstanceFactoryChoice调用中添加“view”参数似乎可以满足我的要求。不过,似乎在某个地方有不一致之处

InstanceFactoryChoice(klass=k, view=item_view)