XRCed migration to wxPython 4

Hi,
We used to use XRCed to maintain a few projects, however, it doesn’t work anymore since wxPython 4.0. It also only works on Python 2. We tried to update/extend the XRC using just a XML editor. It’s possible, but quite inefficient.

During the holidays, I’ve tryed to get XRCed working on a more “modern” system. I got to a point where it kind-of works. It can open, edit, display and save XRC files. There are still several issues, in particular, I disabled some properties because it caused a crash (see ./src/XRCed/AttributePanel.py:218), and for some complex XRC files, it doesn’t manage to display the frame.

Anyway, maybe it’s already useful for someone else, so you can find it here: https://bitbucket.org/delmic/xrced/src/master/
On Linux, you should be able to run it by running the ./xrced script. Otherwise, it’s just a matter of running python -m XRCed .

Any help welcome :wink:
Cheers,
Éric

Hi Eric,
thank you for the effort. I used it a lot in the past and whenever I had to change something during the last years I went for a simple text editor, which is a mess. I will give it a try. Maybe you are not aware of wxGlade. I tried it recently and it imported the xrc data just fine.
Christian

Hi Eric,
my xrc files are pretty old and they have some combinations of flags which are wrong and now deprecated. Importing the file works fine but when selecting any node the following assertion error is shown:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wx/core.py", line 3383, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "/Users/ck/devel/xrced/src/XRCed/presenter.py", line 154, in setData
    self.panels = view.panel.SetData(self.container, self.comp, node)
  File "/Users/ck/devel/xrced/src/XRCed/AttributePanel.py", line 181, in SetData
    panel = AttributePanel(self.pageA, comp.attributes, comp.params, comp.renameDict)
  File "/Users/ck/devel/xrced/src/XRCed/AttributePanel.py", line 301, in __init__
    control = paramClass(self, sParam)
  File "/Users/ck/devel/xrced/src/XRCed/params.py", line 297, in __init__
    sizer.Add(self.text, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.ALL, textB)
wx._core.wxAssertionError: C++ assertion "!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL))" failed at /Users/robind/projects/bb2/dist-osx-py37/build/ext/wxWidgets/src/common/sizer.cpp(2114) in DoInsert(): Vertical alignment flags are ignored with wxEXPAND

Could you have a look into it? Maybe you could automatically remove the wx.EXPAND flag whenever the assertion error occurs.

Christian

wxFormBuilder also supports XRC.

Hi Christian,

Thanks for the pointer to wxGlade. I hadn’t heard of it, but will try it. I had tried wxFormBuilder, but our XRC files immediately crashes it on import. I don’t know if it’s because we have extra widgets, but it didn’t give me much hopes.

Concerning the issue you’re mentioning, it could be that you’re using wxPython v4.1? Apparently, it is much stricter with the flags passed to the sizers. I’m still using v4.0, so didn’t encounter the issue.
I’m not really planning to maintain much XRCed. Especially, maybe it’s best if everyone uses wxGlade instead. Anyway, if you send me a pull-request, I can merge it. Note that you don’t need a bitbucket account, you can just clone the git repo and fork it on github. If you send me a link to a branch with a fix, I can merge it.

Best,
Éric

Be aware that XRC support in wxGlade is limited only. You may have to tweak xrc2wxg.py.
Also, I would suggest to switch from XRC to generating Python code. XRC does not improve anything. You’re losing many features and are increasing your workload instead.
Regards,
Dietmar

Dietmar, thanks for the pointer about xrc2wxg.py.
What do you mean about the XRC not improving anything? It’s at least an improvement over manually writing Python code to generate a window with all the widgets, right? We actually use the XRC files to automatically generate Python code, while keeping a sane way to edit the widgets placements. So in this case, I guess it’s the same as wxGlade or wxFormBuilder, or are we still missing some features?

Best,
Éric

Hi Eric,

I just wanted to report back that I am quite happy with wxGlade as xrced replacement. It reads all my old xrc files. After export I just have to delete the subclass attribute of the topmost widget and it works.

Christian