Why wx.SingleChoiceDialog is not properly subclassed

I am trying to subclass the wxpython SingleChoiceDialog class. I have a TableChoiceDialog class that inherits from SingleChoiceDialog, adding universal functionality, and I have 2 subclasses for which more advanced functionality has been added. Mostly I'm OOP'ing

In my TableChoiceDialog class, I have a row that calls the __init__ superclass, i.e.

 class TableChoiceDialog(wx.SingleChoiceDialog): def __init__(self, parent, message, caption, list, ...other args...): wx.SingleChoiceDialog.__init__(self, parent, message, caption, list) 

The problem I am facing is that according to SingleChoiceDialog.__init__ docstring (and wxPython API) SingleChoiceDialog does not have a self argument as part of this __init__ method.

  __init__(Window parent, String message, String caption, List choices=EmptyList, long style=CHOICEDLG_STYLE, Point pos=DefaultPosition) -> SingleChoiceDialog 

As I said above, the program prints an error:

 swig/python detected a memory leak of type 'wxSingleChoiceDialog *', no destructor found. 

If I select the self parameter, the system complains that it expected the SingleChoiceDialog object SingleChoiceDialog be the first argument, which seems to indicate that it really wants a reference to itself.

When I take out the parent argument, leaving self (and the other 3, which I'm sure everything is fine), the system complains that it only got 3 arguments when it needs 4. I'm pretty sure I'm passing 4.

So. What obvious mistake have I made? I did not completely understand how python handles objects (and, therefore, rather misunderstood python)? Am I misunderstood OOP in general?

Please, help. thanks in advance

+4
source share
2 answers
  • The __init__ call looks fine (the first __init__ argument is always self ).
  • You may have the wrong wx build. A warning swing message indicates that a handle is not created for wxSingleChoiceDialog , see this discussion of memory leaks .

The message may not be associated with a __init__ call.

0
source

Some of the dialogs in wxPython are not subclasses because they are not real classes, but instead wrap around the platform API method to display the dialog box. I know that this is the case for wx.MessageDialog , it can also be for wx.SingleChoiceDialog .

0
source

All Articles