What’s the best method of getting an instance of “theApp”
wx.App.Get(), wx.GetApp(), wx.App.GetInstance() all return typeof wx._core.AppConsole
I would like to get an instance that is typeof wxApp or wxAppBase
I see native has GetGUIInstance()
What’s the best method of getting an instance of “theApp”
wx.App.Get(), wx.GetApp(), wx.App.GetInstance() all return typeof wx._core.AppConsole
I would like to get an instance that is typeof wxApp or wxAppBase
I see native has GetGUIInstance()
Are you calling these using python or C++ ?
When I run the code below they all return the same wx.App object.
I am using Python 3.10.12 + wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1 on Linux Mint 21.2
import wx
app = wx.App()
print(app)
print(wx.GetApp())
print(wx.App.Get())
print(wx.App.GetInstance())
print(wx.AppConsole.GetInstance())
Output:
/usr/bin/python3.10 /home/richardt/Development/python/exp/hci/wxpython/app/app_exp_1.py
<wx.core.App object at 0x7f677992bd90>
<wx.core.App object at 0x7f677992bd90>
<wx.core.App object at 0x7f677992bd90>
<wx.core.App object at 0x7f677992bd90>
<wx.core.App object at 0x7f677992bd90>
I just use wx.GetApp()
in my own python code.
Hi Richard
Note, I am creating “wxApp’ in C++, but accessing it from Python
This is what I get
def PyRxCmd_doit():
try:
print(sys.version)
print(wx.version())
print(wx.GetOsDescription())
print(wx.GetApp())
print(wx.App.Get())
print(wx.App.GetInstance())
print(wx.AppConsole.GetInstance())
except Exception as err:
traceback.print_exception(err)
Output:
Command: DOIT
3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
4.2.0 msw (phoenix) wxWidgets 3.2.0
Windows 10 (build 19045), 64-bit edition
<wx._core.AppConsole object at 0x000001A88C4C3E20>
<wx._core.AppConsole object at 0x000001A88C4C3E20>
<wx._core.AppConsole object at 0x000001A88C4C3E20>
<wx._core.AppConsole object at 0x000001A88C4C3E20>
My hunch is wx.App() creates a wxPyApp and not a wxApp.
The solution for embedded might be to create their own wrapper
I was able to do this using wxPyConstructObject(pApp, wxT(“wxPyApp”));