Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wx/core.py fails to launch on Fedora 40 Python 3.12

Open telombardi opened this issue 1 year ago • 8 comments
trafficstars

Operating system: Fedora 40 (6.11.6-200.fc40.x86_64) wxPython version & source: 4.2.2 via pip Requirement already satisfied: wxpython in /usr/local/lib64/python3.12/site-packages (4.2.2) Python version & source: Python 3.12.7 from dnf install

Description of the problem:

We are running an application that we've run for sometime with wxPython. When we run the code on our new build, we get the following error when we launch the GUI.

/usr/local/lib64/python3.12/site-packages/wx/core.py:2232: Warning: cannot register existing type 'GdkDisplayManager' self._BootstrapApp() /usr/local/lib64/python3.12/site-packages/wx/core.py:2232: Warning: g_once_init_leave_pointer: assertion 'result != 0' failed self._BootstrapApp() /usr/local/lib64/python3.12/site-packages/wx/core.py:2232: Warning: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed self._BootstrapApp()

I suspect that this is a configuration error on my part, but I cannot find it.

Any ideas?

Code Example (click to expand)
# Put code sample here

telombardi avatar Nov 13 '24 01:11 telombardi

Are you possibly mixing GTK2 and GTK3 (wxPython) in your app somehow?

https://stackoverflow.com/questions/61509812/issue-glib-gobject-warning-cannot-register-existing-type-gdkdisplaymanager

swt2c avatar Nov 13 '24 03:11 swt2c

Are you possibly mixing GTK2 and GTK3 (wxPython) in your app somehow?

https://stackoverflow.com/questions/61509812/issue-glib-gobject-warning-cannot-register-existing-type-gdkdisplaymanager

Thanks for the suggestion. I will check it out and post back shortly.

telombardi avatar Nov 15 '24 00:11 telombardi

https://stackoverflow.com/questions/61509812/issue-glib-gobject-warning-cannot-register-existing-type-gdkdisplaymanager

Python 3.12.7 (main, Oct 1 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux Type "help", "copyright", "credits" or "license" for more information.

import wx wx.version() '4.2.2 gtk3 (phoenix) wxWidgets 3.2.6'

I am confirming with developers what version the code depends on.

If this is the issue, then I suppose I'll need to find a version wxPython that can be built with gtk2. Does that sound right?

telombardi avatar Nov 15 '24 00:11 telombardi

If this is the issue, then I suppose I'll need to find a version wxPython that can be built with gtk2. Does that sound right?

Not necessarily. My question was more about whether you are using other GUI libraries (other than wxPython) in your application.

swt2c avatar Nov 15 '24 00:11 swt2c

The code has been using GTK3 for quite some time (since 2019).

Any other possible explanations?

telombardi avatar Nov 15 '24 00:11 telombardi

If this is the issue, then I suppose I'll need to find a version wxPython that can be built with gtk2. Does that sound right?

Not necessarily. My question was more about whether you are using other GUI libraries (other than wxPython) in your application.

We use matplotlib among other things. I think I see your point. I will chase down some of our other packages too.

Any suggestions in this regard?

telombardi avatar Nov 15 '24 00:11 telombardi

matplotlib is a good suspect. If it's trying to use GTK-2, that could be a problem.

swt2c avatar Nov 15 '24 01:11 swt2c

Verify Matplotlib Backend It is not necessary that Matplotlib is the culprit but just for verification you can have a look at the backend being used by Matplotlib as it can use different backends for rendering. Ensure that it is configured to use a compatible backend.

You can check and set the Matplotlib backend in your code:

import wx
import matplotlib

print(f"wxPython version: {wx.version()}")
print(f"Matplotlib backend: {matplotlib.get_backend()}")

# # Try setting a different Matplotlib backend
# matplotlib.use("qtagg")

# Print versions and configurations
print(f"wxPython version: {wx.version()}")
print(f"Matplotlib backend: {matplotlib.get_backend()}")

# Your application code here
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
frame.Show(True)
app.MainLoop()

HassaanShah016 avatar Mar 01 '25 19:03 HassaanShah016