I have been playing with XRCed and wxGlade… both are really cool for generating widgets from XML. However, I have some existing applications where I would like to go in the other direction–I would like to generate XRC source from an existing application that was created with python code, and modified dynamically during run time. Is there a utility to do this? I would like to pass the utility a window or frame object, and have it traverse through the children to generate an XRC source. I’m sure someone, somewhere has done this… I’d hate to re-invent the wheel here…
Sounds like a fun project. I suspect you could read the Python file
as a text file and look for the keywords, and build the XRC object out
of it. I have no idea if someone has tried this before.
···
On 5/17/07, Paul Perez <paul@paulperez.net> wrote:
I have been playing with XRCed and wxGlade... both are really cool for
generating widgets from XML. However, I have some existing applications
where I would like to go in the other direction--I would like to generate
XRC source from an existing application that was created with python code,
and modified dynamically during run time. Is there a utility to do this? I
would like to pass the utility a window or frame object, and have it
traverse through the children to generate an XRC source. I'm sure someone,
somewhere has done this... I'd hate to re-invent the wheel here...
Sounds like a fun project. I suspect you could read the Python file
as a text file and look for the keywords, and build the XRC object out
of it. I have no idea if someone has tried this before.
How about overriding all wx controls/sizers? Then you could simply run your
program and the xml would be generated automatically. This sounds really doable.
Sounds like a fun project. I suspect you could read the Python file
as a text file and look for the keywords, and build the XRC object out
of it. I have no idea if someone has tried this before.
Then you need to parse the source code.
What may be easier is after everything is constructed, start from the
main frame of the application and traverse all of its children, sizers,
etc.
Heck, this quick little method will traverse your wxWindow hierarchy:
It doesn't really do anything useful...except tell you what objects are
parented where. If you get the sizer for a frame (if any), you can also
handle layout. With a little work, you could produce xml (I have a nice
recipe in the Python cookbook for quickly producing XML...)
On 5/17/07, Paul Perez <paul@paulperez.net> wrote:
> I have been playing with XRCed and wxGlade... both are really cool for
> generating widgets from XML. However, I have some existing applications
> where I would like to go in the other direction--I would like to generate
> XRC source from an existing application that was created with python code,
> and modified dynamically during run time. Is there a utility to do this? I
> would like to pass the utility a window or frame object, and have it
> traverse through the children to generate an XRC source. I'm sure someone,
> somewhere has done this... I'd hate to re-invent the wheel here...
>
> Thanks in advance for your response.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
I have been playing with XRCed and wxGlade... both are really cool for generating widgets from XML. However, I have some existing applications where I would like to go in the other direction--I would like to generate XRC source from an existing application that was created with python code, and modified dynamically during run time. Is there a utility to do this? I would like to pass the utility a window or frame object, and have it traverse through the children to generate an XRC source. I'm sure someone, somewhere has done this... I'd hate to re-invent the wheel here...
I have some code for traversing a live widget/sizer tree in the wx.lib.inspection module. It isn't currently designed to be used independently, but you could certainly get some ideas from it. If you see a way to refactor it so it can be used both for the inspection tool and your tool that would be nice too.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
That's exactly what I do in Dabo's Class Designer. The design surface is a live set of controls, and when we save the design, the classes are traversed to generate a recursive dictionary that mirrors the class's structure. Then that it converted to XML and written to a file.
It isn't XRC, since we have our own XML format, but the logic sounds like what you're looking for.
I would like to generate XRC source from an existing application that was created with python code, and modified dynamically during run time. Is there a utility to do this? I would like to pass the utility a window or frame object, and have it traverse through the children to generate an XRC source. I'm sure someone, somewhere has done this... I'd hate to re-invent the wheel here...