Trying to update wxpython code to wxpython 4

I’m sorry, but I’m totally new to wxpython…

I’ve started to update the old Python PAWS project (PAWS: Python Adventure Writing System (for Interactive Fiction, originally by Roger Plowman)) @

I’ve gotten to the point where the WXPython GUI is attempting to start, but is dying on the creation of the menu bar. I believe it’s due to it originally being wxpython 2? And there are compatibility issues with v4 of wxpython (trying to run outdated code).

Since I’m a newbie with wxpython, I decided to try to rebuild the GUI via wxGlide, and I suspect that I am totally missing something… The glide file is here @

I can’t get the menu bar to appear…?

Are there any wxpython folks that might want to spare a few minutes, and either point out where I’ve goofed? Or be interested in assisting in updating PAWS?

It’s a very nice system, but I’m surprised at some of the design choices that Roger originally went with…

Any help would be greatly appreciated… Just please be kind, I’ve barely scratched the wxPython documentation at this point.

Are you getting an exception and traceback? If so, please share.

Yes, there are some incompatibilities. Details and hints are documented here:

(PAWS) nerv:paws benjamin$ LoadTerminal.pyy 
Traceback (most recent call last):
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 35, in OnInit
    self.main = TerminalFrame.create(None)
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 46, in create
    return TFrame(parent)
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 223, in __init__
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 182, in _init_ctrls
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 172, in _init_utils
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 87, in _init_coll_menuFile_Items
    kind=wx.ITEM_NORMAL, text='Pick Game …')
TypeError: Menu.Append(): arguments did not match any overloaded call:
  overload 1: 'help' is not a valid keyword argument
  overload 2: 'help' is not a valid keyword argument
  overload 3: 'help' is not a valid keyword argument
OnInit returned false, exiting...
    def _init_coll_menuFile_Items(self, parent):
        # generated method, don't edit

        parent.Append(help='', id=wxID_TFRAMEMENUFILEPLAYGAME,
              kind=wx.ITEM_NORMAL, text='Pick Game …')
        parent.Append(help='', id=wxID_TFRAMEMENUFILESAVE, kind=wx.ITEM_NORMAL,
        parent.Append(help='', id=wxID_TFRAMEMENUFILEITEMS2,
              kind=wx.ITEM_NORMAL, text='Restore')
        parent.Append(help='', id=wxID_TFRAMEMENUFILEDEBUG, kind=wx.ITEM_NORMAL,
        parent.Append(help='', id=wxID_TFRAMEMENUFILELOGGAME,
              kind=wx.ITEM_NORMAL, text='Log Game')
        parent.Append(help='', id=wxID_TFRAMEMENUFILEVERBOSE,
              kind=wx.ITEM_NORMAL, text='Verbose')
        parent.Append(help='', id=wxID_TFRAMEMENUFILETERSE, kind=wx.ITEM_NORMAL,
        parent.Append(help='', id=wxID_TFRAMEMENUFILEEXIT, kind=wx.ITEM_NORMAL,
        self.Bind(wx.EVT_MENU, self.OnMenuFileSaveMenu,

From what I saw, in my first glance through the documentation, parent.Append isn’t handled like this anymore.

You need to create an menu Item, and then append that to the parent. Which means, I have to rewrite those for the 3 menus, etc. Which is why I started to muck with Glide…

     - Benjamin

Not unless you really want to do it that way. It’s just a matter of the parameter name changing. Most of wxPython4 is now generated instead of maintained by hand, so things like this will now always match the published wxWidgets API instead of being subject getting out of sync with reality. It also means that the wxPython version of the docs are always accurate. See:

Thanks. I have had a bit of success? But I’m now blocked again…

(PAWS) nerv:paws benjamin$ LoadTerminal.pyy 
Traceback (most recent call last):
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 35, in OnInit
    self.main = TerminalFrame.create(None)
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 46, in create
    return TFrame(parent)
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 223, in __init__
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 219, in _init_ctrls
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 158, in _init_sizers
  File "/Volumes/4TB_Drive/PAWS/PAWS/", line 66, in _init_coll_flexGridSizer1_Items
    parent.AddWindow(self.TDisplay, 0, border=0, flag=wx.GROW | wx.EXPAND)
AttributeError: 'FlexGridSizer' object has no attribute 'AddWindow'
OnInit returned false, exiting...
def _init_coll_flexGridSizer1_Items(self, parent):

    # generated method, don't edit

    parent.AddWindow(self.TDisplay, 0, border=0, flag=wx.GROW | wx.EXPAND)

    parent.AddWindow(self.TInput, 1, border=1,

          flag=wx.GROW | wx.RIGHT | wx.LEFT | wx.EXPAND | wx.ALIGN_BOTTOM)

This is where the code is adding the Display to the FlexGrid, and the input window to the flexgrid.

The only AddWindow I see in wxpython’s docs is wx.lib.agw.foldpanelbar.FoldPanelItem.AddWindow, Which doesn’t match the header.

Nor do I see anything in the migration guide that seems to match….

Any suggestions would be greatly appreciated.

  • Benjamin

Please note this about Python and wxPython versions from the wxGlade documentation:

If you want to build a GUI for wxPython Classic or Phoenix: Start wxGlade in your target version - if it runs under Phoenix, it will create Phoenix code. The .wxg file format is not affected by this. So you may use a single .wxg file to generate code for both Classic and Phoenix. The generated code should always run under both Python 2.7 and Python 3.

About menus:
If you enter an explicit ID like wxIDOpenFile, you need to be sure that wx.IDOpenFile exists, e.g. by adding import code. Most of the time you don’t need explicit IDs except for some stock items like e.g. wxID_OPEN.

Okay, figured out the flexgrid issue… (Add vs AddWindow).

The GUI now is up, and seems to be frozen. No Menu Bar, But everything else appears…

Digging through the code, I see that it was constructed with BOA (Boa-Constructor),… Which doesn’t support Python 3, I believe…

So I’m assuming there isn’t any good way to auto convert from BOA to wxGlide?


I follow what your saying regarding the wxg files… But this wasn’t originally made in wxGlide, I’m trying to recreate it in wxGlide, to help prevent this from happening again. This was created by someone else in Boa-Constructor.

If you have Boa still running and it supports XRC export, you may give this a try. Basic XRC import should work with wxGlade.
You may want to have a look at the wxGlade version from the master branch of the github repository.The created code looks more what a human being would write.

I’ll strip Python 3 off of a machine, and see if I can get Boa running, and see if it has exporting abilities…

The Overloaded Functions section applies here.

In this case, the new method name is simply Add, and it can be used for adding windows, sizers and spacers. ( In other words, there is now only the one method instead of three.

I have just searched the Boa 0.6.1 code for ‘XRC’ and could only find about some examples for use of wx.xrc.
So I don’t think it can export.

You probably have to re-create. It should not be so much work as you usually can ignore most of the ID related stuff. You can access the elements, including menu items, by name instead. If you use an IDE, auto-completion will save you a lot of time.

Actually, I just finished and it’s working fine. The problem was on my side, I missed the menu bar… The App was performing as expected.

I’ll eventually look at wxGlade to effectively rewrite the BOA code, but it seems to be working 100% at this point.

Thank you for all the help.