dynamic panel destruction

37 views
Skip to first unread message

Nathan smith

unread,
Jun 10, 2024, 6:25:00 AMJun 10
to wxpytho...@googlegroups.com
Hello,


So I have a program that I am working on which has the ability to offer
the user the chance to mod screens.

The process it goes through would be something like:


1: display the loading panel

2: for each user added module,

 2.1: import it

 2.2: Run their screen_mod function with args of self so they can
access the class.

3: If success, carry on, but if failure, destroy any panels they created
or frames that were made.


What I am trying to do here is be able to catch if their mod tracebacks
and stop it from crashing the entire program, requiring a restart.


Is this possible?

The main program would not be returned any modifications made.

Thanks in advance for any help

Nathan

Dietmar Schwertberger

unread,
Jun 10, 2024, 2:58:20 PMJun 10
to wxpytho...@googlegroups.com
When destroying windows or widgets, you need to be sure that there are
no pending events.

So, e.g. call .Hide() and then .DestroyLater() or use wx.CallAfter to
call .Destroy()

Regards,

Dietmar

Nathan smith

unread,
Jun 21, 2024, 9:48:19 AM (13 days ago) Jun 21
to wxpytho...@googlegroups.com, Dietmar Schwertberger
Hi all,


thanks Dietmar , good to know and explains certain tracebacks I got.


My question more is though, if another module creates a panel/window, is
there a way for me to dynamically list all the wx windows/panels created?


In the senario of:

Main program calls module.create_screen, but module.create_screen
tracebacks, I want a catch to then clean up the failure of that tmodule.


Nathan

Dietmar Schwertberger

unread,
Jun 21, 2024, 1:41:05 PM (12 days ago) Jun 21
to wxpytho...@googlegroups.com
On 21.06.2024 15:48, Nathan smith wrote:
> My question more is though, if another module creates a panel/window,
> is there a way for me to dynamically list all the wx windows/panels
> created?

You can always query wx objects for their children.

Have a look at class StructurePrinter to get an idea:

https://github.com/wxGlade/wxGlade/blob/master/utilities.py

Regards,

Dietmar

Reply all
Reply to author
Forward
0 new messages