Forum: Poser Python Scripting


Subject: GUI Close Handler for wxPython and poserPython

gbn opened this issue on Apr 05, 2023 · 3 posts


gbn posted Wed, 05 April 2023 at 3:34 PM

Hello, I'm porting my Tkinter-script to wxPython and using wxFormBuilder as GUI builder.

The GUI script is running well on Poser Pro 11. I used the HelloWorld-example (Not Standalone) from PhilC's book "Python for Poser 8" as template.

But implementing the close of the GUI in a controlled way, currently I use just the Close-button of the AUI-pane w/o any syncronization, is from my humble view harder than expected.

The easiest way to write self.Destroy() inside MyApp::ButQuitFunc() and deactivation of Close-button of the AUI-Pane followed to a hangup in the script and crash of P11pro.

Contacting the pane-object, which might be useful, inside class MyApp is not so easy since its commands are in the main-part of the script after the class-definition.

I tried out several proposals of chatGPT for adding  class-methods OnInit() and OnClose(), but failed.

Has anyone maybe PhilC ;-) an idea to solve my problem ? TIA /Gunnar

===================================================================================================================

mport wx

import wx.aui

import poser 

import os

import sys

sys.path.append(r"D:\Users\public\Documents\PoserPython\wxFormBuilder\RJB")

from RJB_gui import *

sys.path.append(r"D:\Users\public\Documents\PoserPython")

from WxAddOn import *


man = poser.WxAuiManager() 

root = man.GetManagedWindow()


scene=poser.Scene()

PU = 262.128

class MyApp(MyMainPanel):

def __init__(self, root) :

MyMainPanel.__init__(self, root)

self.root = root

self.Show()


# Virtual event handlers, override them in your derived class


def ButNewFunc( self, event ):

print "New!"

def ButLoadFunc( self, event ):

print "Load!"


def ButSaveFunc( self, event ):

print "Save!"


def ButShowFunc( self, event ):

print "Show!"


def ButAddFunc( self, event ):

print "Add!"


def ButInsertFunc( self, event ):

print "Insert!"


def ButDeleteFunc( self, event ):

print "Delete!"


def ButUpdateFunc( self, event ):

print "Update!"


def ButRenderFunc( self, event ):

print "Render!"


def ButPreviewFunc( self, event ):

print "Preview!"


def ButCamResFunc( self, event ):

print "CamRes!"


def ButCamSizeFunc( self, event ):

print "CamSize!"


def ButPOVFunc( self, event ):

print "POV!"


def ButSizeHgtFunc( self, event ):

print "SizeMgt!"

def ButQuitFunc( self, event ):

print "Quit!"

app = MyApp(root)


man.AddPane(app, wx.aui.AuiPaneInfo(). 

Caption("RJB").CaptionVisible(). 

Float().Resizable().DestroyOnClose(). 

FloatingSize(app.GetSize()).CloseButton(True))

info = man.GetPane(app)

info.Show()


man.Update()