Fri, Jan 10, 6:13 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: GUI Close Handler for wxPython and poserPython


gbn ( ) posted Wed, 05 April 2023 at 3:34 PM · edited Thu, 09 January 2025 at 1:20 AM

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()





adp001 ( ) posted Wed, 05 April 2023 at 4:57 PM

To catch a close-event you have to set up a corresponding handler using "Bind":

class MyApp(MyMainPanel):
def __init__(self, root) :
MyMainPanel.__init__(self, root)
                self.Bind(wx.EVT_WINDOW_DESTROY, self.myCloseHandler)
        ...




gbn ( ) posted Fri, 07 April 2023 at 2:44 PM

THX, works. Now it closes always. Trying to make it optionally.



Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.