是否在另一个xrc文件中包含一个xrc文件中的元素

时间:2022-10-16 07:12:46

I've got an wx App that has the UI defined in XRC files. Each form is in its own xrc file. There is one panel that is common to many of the forms. Is there a way to have objects defined in one file that are included and referenced in another?

我有一个wx App,它具有在XRC文件中定义的UI。每个表单都在自己的xrc文件中。有一个面板是许多表格共有的。有没有办法在一个文件中定义对象并在另一个文件中引用?

I know there is a object_ref mechanism, but I can't see how that can reference external xrc files.

我知道有一个object_ref机制,但我看不出它如何引用外部xrc文件。

I'd like something that worked similar to the way you can define xsd elements in one file and include and reference them in another xsd file.

我想要的东西类似于在一个文件中定义xsd元素的方式,并在另一个xsd文件中包含和引用它们。

1 个解决方案

#1


XRC doesn't have an include mechanism that I know of, but you can have custom widgets.

XRC没有我所知道的包含机制,但您可以拥有自定义小部件。

So implement your common panel as its own XRC, and set that up as something that you can reference by class name in other xrc files.

因此,将您的公共面板实现为自己的XRC,并将其设置为可以通过其他xrc文件中的类名引用的内容。

You would create an XmlResourceHandler that handles the custom Panel in the XRC, and instantiates your Panel class. The place to look is demo/wxXmlResourceHandler.py

您将创建一个XmlResourceHandler来处理XRC中的自定义Panel,并实例化您的Panel类。要看的地方是demo / wxXmlResourceHandler.py

You can even extend XRCed to recognize your own resource, and insert it into future dialogs with ease.

您甚至可以扩展XRCed以识别您自己的资源,并轻松地将其插入到将来的对话框中。

#1


XRC doesn't have an include mechanism that I know of, but you can have custom widgets.

XRC没有我所知道的包含机制,但您可以拥有自定义小部件。

So implement your common panel as its own XRC, and set that up as something that you can reference by class name in other xrc files.

因此,将您的公共面板实现为自己的XRC,并将其设置为可以通过其他xrc文件中的类名引用的内容。

You would create an XmlResourceHandler that handles the custom Panel in the XRC, and instantiates your Panel class. The place to look is demo/wxXmlResourceHandler.py

您将创建一个XmlResourceHandler来处理XRC中的自定义Panel,并实例化您的Panel类。要看的地方是demo / wxXmlResourceHandler.py

You can even extend XRCed to recognize your own resource, and insert it into future dialogs with ease.

您甚至可以扩展XRCed以识别您自己的资源,并轻松地将其插入到将来的对话框中。