Skip to content

How to set wx.App() from C++? #1126

@pointhi

Description

@pointhi

Operating system: Arch Linux
wxPython version & source: '4.0.3 gtk3 (phoenix) wxWidgets 3.0.4'
Python version & source: 3.7.2

Description of the problem:

I did the Python3/Phoenix Port of KiCad some time ago. Unfortunately, it seems like the application is not exiting correctly when the scripting console (based on wx) was used: https://bugs.launchpad.net/kicad/+bug/1809913

I assume it is due to a hack needed to get phoenix working which required me to to create a new wx.App() inside python, and not to reuse the main one of the c++ application itself. Removing it cause the error: assert app is not None, 'No wx.App created yet' because ofwx.GetApp() returns None. How do I correctly instantiate a wx.Phoenix frame using the c++ app?


My patchset to get Phoenix working can be found here:

KiCad/kicad-source-mirror@0e0b4d5

Notable is the change to instantiate a new wx.App():

KiCad/kicad-source-mirror@0e0b4d5#diff-51d04e3e5130cdd6081b1702c5e35827R92

As well as the change to actually create the window. In the old implementation, we used the wxWindow parent of the c++ application, while in the new implementation the window id is used.

KiCad/kicad-source-mirror@0e0b4d5#diff-b4427d47c8cfee59a51819e36acbdd4aL383


It would be nice to know how to correctly create wx Phoenix frames from c++ or what issues I created in this implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions