Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 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.
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?
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)
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.
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?