Thu, Oct 3, 5:20 AM CDT

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: is there any simple user input function available ??


jenay ( ) posted Tue, 17 June 2008 at 4:54 AM · edited Thu, 03 October 2024 at 5:17 AM

I need some help with Python from the gurus here :)
I am just a beginner with Python.
here is a code snippet:

ok = "y"
while ok !="x":
        ok = raw_input("... repeat action ...")
        print("... do something ...")
print ("... quit ...")

I wrote a simple loop that exits when the "x" is entered. It works fine within
my Python console, but PoserPython refuses to accept the input (raw_input) funktion.
now I didn't find any docu about this matter. seems, that the PoserPython console
doesn't accept any user input ??
do I have to use Tk for that purpose and create a dialog along with buttons - or is
there a simpler solution ???
I found somethong like Poser.dialog - but this seems not available under Poser5 ??


PhilC ( ) posted Tue, 17 June 2008 at 5:09 AM

In Poser 6 and later, Poser has a number of input dialogs but for Poser 5 your only option is to use Tkinter. Raw input does not work in any version.


jenay ( ) posted Tue, 17 June 2008 at 5:42 AM

Hi Phil - thanks for the quick answer :)
so it seems that I have to learn TkInter ...


adp001 ( ) posted Tue, 17 June 2008 at 7:00 AM

To use Tkinter isn't bad. Try this for a fist start to solve your problem:

from Tkinter import * import tkMessageBox

if tkMessageBox.askyesno(title="My Questiondialog", 
                         message="Please press Yes or No") :
    # YES-Button pressed - we are happy :)
    print "Thanks, you pressed YES"

else :
    # NO-Button pressed or dialog closed
    print "Thanks, you decided to press NO"

Because this simple demo doesn't use a "complete" Tkinter environment, Tkinter sets one up for you. This is the reason for the little extra window that appears if you run the above demonstration.

To learn how to use Tkinter and all the predefined dialogs, learn from the best:

Tkinter: http://effbot.org/tkinterbook/
Dialog-description: http://effbot.org/tkinterbook/tkinter-standard-dialogs.htm

If you have questions, feel free to ask. I'm pretty familar with Python and Tkinter.




jenay ( ) posted Wed, 18 June 2008 at 3:03 AM

Hi, thank you very much - very usefull, just what I needed :)
I did some tests and read some chapters of the tkinter manual (thanks for the
links).
JoeK


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.