Sun, Nov 24, 10:29 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 Sep 18 2:50 am)

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: Problem exiting script


fivecat ( ) posted Sat, 27 September 2008 at 1:39 PM · edited Sun, 24 November 2024 at 8:20 AM

I noticed that a few of my scripts seem to leave some process running that pegs my processor until I exit out of Poser 7. I did some experimenting and found out that: 1. It happens only with my scripts that use a selectable listbox. 2. It happens only on exiting the script, whether using the button that calls command master.destroy or the "x" close on the window. Any ideas on what is happening here?


fivecat ( ) posted Sat, 27 September 2008 at 3:46 PM

Okay, any script using the tKinter listbox seems to do the same.


adp001 ( ) posted Sun, 28 September 2008 at 9:39 AM

Sounds like a pointer to something inside your script is left active after your script ends.
Background: Python is allways active and any script started is working in the same Python namespace. There is no "reset" after your script stops.

Try this: Start any script (probably one using a listbox). Exit the script. Create and run a new script containing:

**print "LEFT OVERS"
print "Globalsn",globals()

**You will see a list of objects/variables left over from the previously started script.

Better use classes. If you declare most of your script in class myApp, after

root=Tk()
app=myApp(root)
root.mainloop()
del app
del root

All your objects should be deleted via Pythons garbage collector.




fivecat ( ) posted Sun, 28 September 2008 at 12:21 PM

Okay, I'm using classes, and adding the two "del" lines prevents the problem as long as I use the close button on the script window. Right now I'm using this: self.button = Button(frame, text="DONE", fg="red", command=master.destroy) to exit the script. What is a better way to do this than just calling master.destroy?


adp001 ( ) posted Sun, 28 September 2008 at 2:43 PM

If you close your script window, you interrupt Tkinter with whatever it does. But before the window is closed, Tkinter fires an event. Catch this event, call your "clean-up" and you are done:

<pre class="python wide">
root.protocol(<span class="pystring">"WM_DELETE_WINDOW"</span>, myApp.master.destroy)




fivecat ( ) posted Sun, 28 September 2008 at 6:21 PM

Thank you for your help, it has been very much appreciated. 


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.