Error on my app: TypeError: could not convert 'SourceEditor' to 'Dialog' in wxPython 4.2.0

I am having this error TypeError: could not convert 'SourceEditor' to 'Dialog, with new wxPython 4.2.0, when starting my app, RIDE. This is not happening in my current development environment (Fedora 36, Python 3.10.6 and wxPython 4.0.7).
The error happens in Windows and Linux (and probably in Mac) for this version wxPython 4.2.0.

Like I mention in the Issue in RIDE project for this “TypeError: could not convert ‘SourceEditor’ to ‘Dialog’”, the offending class depends on wx.Panel, and uses a class based on wx.Dialog as an object.
Here is the note I have added to the issue.

class SourceEditor(wx.Panel, RIDEDialog):  # (...) with superclass init:
    wx.Panel.__init__(self, parent)
    self.dlg = RIDEDialog()
class RIDEDialog(wx.Dialog):  # (...) with superclass init:
    wx.Dialog.__init__(self, parent=parent, title=title, size=size, style=style)

Please help me in making the code functional, and clarify if this coding style is wrong.

I did not inspected for changes that may help understand why now the error is happening.


Based on the comments in the RIDE issue, it sounds like this isn’t related to wxPython changes, but rather Python 3.10.

I’m a bit confused about what you’re trying to do with SourceEditor. It subclasses both wx.Panel and RIDEDialog, but also has an instance of a RIDEDialog? I can’t see a reason why you would want a class to subclass both wx.Panel and wx.Dialog at the same time, so that seems wrong.

About the use of both wx.Panel and wx.Dialog from my RIDEDialog, was to have access to variables/properties that are declared in another Dialog and stored in a file (style type .ini). My RIDEDialog class, can be called as a Dialog (with the colors and styles defined), or just as a provider for those settings. This was my solution to have a “dark mode”, or colors customization across the app.

The SourceEditor is a STC editor and added as a page on auibook, and originally (~2018) did not have this colors customization.

At the time I coded the feature, I found the need to declare as an implementation of RIDEDialog, but these days I should see if that is still needed, and the removal could be the solution for my problem.


A single widget can not be both a wx.Panel and a wx.Dialog. In other words, you can not inherit from more than one widget class. So you should remove RIDEDIalog from the SourceEditor list of parents.


past magic & present problems are not unique to software :innocent:

1 Like