Wrapped C/C++ object has been deleted

Hello wxPython users,

  1. Launch ‘test.py’
  2. Push ‘Show logging frame’ button,
  3. Close ‘Redirect’ frame,
  4. Push ‘Show logging frame’ button again.

ERROR:

Traceback (most recent call last):
File “C:\Users\jean-\Desktop\test.py”, line 113, in OnLoggingFrm
self.frm.Show(True)
RuntimeError: wrapped C/C++ object of type MyForm has been deleted

What’s the problem?

test.py (3.8 KB)

I would suggest a thorough read of section window deletion and which buttons do what (the error message is spot on) :cowboy_hat_face:

If the example can help someone, here is my solution :slight_smile:

one_frame_no_modal.py (5.4 KB)

here is an article by the master himself mentioning a singleton, and some more interesting insights: not brand new but always entertaining :sunglasses:

I forgot to upload my idea of the new of your coding (I couldn’t get over the ‘self’ in new: that piece acts on a class & hopefully returns an instance of it)

one_frame_no_modal - Copy.py (5.2 KB)

I appreciate! thank you very much da-dada.

I have another problem:
if you launch both frames and exit the ‘Main frame’, the ‘Single Instance Frame’ remains open.
How to properly close both windows at the same time? :hot_face:

on many controls the first parameter is parent and by keeping that relation consistent saves a lot of bother: the product is mature & luckily, they knew what they where doing… :face_with_monocle:

I’ve just noticed a more interesting feature: when your MainFrame is focussed then the single frame is going behind, but pressing button ‘Showing logging frame’ does not move the logging frame on top !!! with that you’ll loose the patience of the ordinary user, especially if the frames cover the whole of the screen :nauseated_face:

i have modified None to parent (class ‘SingleInstanceFrame’) and i have define a new kwargs style (‘wx.FRAME_FLOAT_ON_PARENT’).

The result is perfect :grinning:

Good informations and very good job from da-dada. :+1:

THANK you so much !

final_result.py (5.8 KB)

To put it mildly your ‘result’ is not even taking the direction towards perfect: if you watch the console you can easily realize that every time a new instance is created by showing the logging frame, so your main objective has gone down the drains (and who wants the log always on top? answer: the logger) :sweat_smile:

final_result_copy.py (6.1 KB)

The upside is that some alterations may clarify the intension :relieved:

final_result_workable.py (6.0 KB)

Last improvement, i have added a menu into the dialog.


P.S. : i loved your examples.
They are sometimes difficult to understand for me because I am an amateur but this will be of great use to me in the future.
Thanks again !

modified_file.py (13.0 KB)

Well, it may be better to keep things apart (and running): it’s the old play of spaghetti vs ravioli (and please no threat of ‘CallAfter’ for lasagne, it’s all swirling around at the moment) :wink: