How can I generate python code? I know I need to change code_generation property from C++ to Python, but there is no Python option... How can i fix this? I have already tried looking for this problem on the internet, but I couldn't find anything.
-
it should probably just create a xrc file or whatever (xml markup thing) that you can then load into wx in python or any other wx implementation .... – Joran Beasley Dec 18 '13 at 23:09
-
I really need python code... – user1176999 Dec 18 '13 at 23:09
-
2xrc is language agnostic. .. then in python you do something like `wx_xrc_resource("some.xrc")` (not sure exact command...) ... but to be honest I typically just hand code my interface... its pretty easy with wx – Joran Beasley Dec 18 '13 at 23:11
3 Answers
Since you didn't specify your OS, I will just review tips for the 3 major ones.
For Windows, the beta release from wxFormBuilder's SourceForge page, version 3.4.x, is able to generate Python code so perhaps try installing that version. I installed this on my Windows box earlier this year and Python was definitely one of the options.
For Linux, it looks like if you installed wxFormBuilder from your distro's software center or manager, you get an older version of the FB, most likely 3.1.xx, which doesn't generate Python code.
In order to obtain the latest (beta) version which does generate Python code, just add the wxFormBuilder PPA.
First, install wxWidgets 3.0 to obtain the prerequisites for wxFormBuilder:
sudo add-apt-repository -y ppa:wxformbuilder/wxwidgets
sudo apt-get update
sudo apt-get install libwxgtk3.0-0 libwxgtk-media3.0-0
Now, install the latest wxFormBuilder release:
sudo add-apt-repository -y ppa:wxformbuilder/release
sudo apt-get update
sudo apt-get install wxformbuilder
After this, you should have wxFormBuilder 3.4.x and should see options for generating code in Python, Lua, PHP in addition to C++/XRC.
This worked for me, but if it doesn't for you, you can try installing from source. Just take a look at the instructions from the SourceForge page of wxFormBuilder.
For Mac, I do not have first-hand experience but you can try downloading version 3.1 from the regular build page.

- 140
- 2
- 7
-
1Finally the answer that helped me! The WxFormBuilder PPA should be known more widely. The best option would be if WxFormBuilder was removed from Ubuntu Official PPA, so people don't get confused. – sjaustirni Aug 18 '14 at 09:12
UPDATE: FormBuilder added Python support recently. You just need to get version 3.4.x.
In older versions, you weren't able to do this (see below).
According to the wxFormBuilder documentation:
Choose which code will be generated. Currently, you can generate C++ and/or XRC code.
As you can see, the choices are C++ or XRC. There is no Python support at this time. You can use XRC in wxPython. Here are a few links:
- http://www.blog.pythonlibrary.org/2010/05/11/wxpython-an-introduction-to-xrc/
- http://www.blog.pythonlibrary.org/2010/10/28/wxpython-an-xrced-tutorial/
- http://wiki.wxpython.org/XRCTutorial
- http://www.blog.pythonlibrary.org/2013/07/24/wxpython-creating-a-grid-with-xrc/
- http://wiki.wxpython.org/UsingXmlResources

- 32,629
- 8
- 45
- 88
-
See the answer with highest score. Only non-up-to-date version has this limitation. – sjaustirni Aug 18 '14 at 09:13
Inside the Object Tree (left panel) you need to select your project (just click on it) and then in the "Object Properties" (rigth panel) go to the code_generation property.
Then select Python.
See the following image

- 93
- 1
- 4