Sun, Dec 29, 1:32 PM 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: Demonstrating simple wx.SingleChoiceDialog and wx.MultiChoiceDialog


adp001 ( ) posted Fri, 27 December 2019 at 6:48 AM · edited Sun, 29 December 2024 at 12:56 PM

Bildschirmfoto von 2019-12-27 13-32-40.png


import wx

try:
    import poser
except ImportError:
    raise RuntimeError("Script must run in Poser.")


def generate_names(obj_list):
    if hasattr(obj_list, "__iter__"):
        for obj in obj_list:
            if hasattr(obj, "Name"):
                yield obj.Name()


def actor_choice(choicelist=None):
    """
    Demonstrates wx.control SingleChoiceDialog
    """
    if choicelist is None:
        choicelist = poser.Scene().Actors()

    choices = list(generate_names(choicelist))
    with wx.SingleChoiceDialog(None,
                               caption="My Actor Dialog",
                               message="Select one actor",
                               choices=choices,
                               style=wx.CHOICEDLG_STYLE
                               ) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            return dlg.GetStringSelection()
        else:
            return None


def actor_choices(choicelist=None):
    """
    Demonstrates wx.control MultiChoiceDialog
    """
    if choicelist is None:
        choicelist = poser.Scene().Actors()

    choices = list(generate_names(choicelist))
    with wx.MultiChoiceDialog(None,
                              caption="My Actor Dialog",
                              message="Select one actor",
                              choices=choices,
                              style=wx.CHOICEDLG_STYLE
                              ) as dlg:
        if dlg.ShowModal() == wx.ID_OK:
            return [choices[i] for i in dlg.GetSelections()]
        else:
            return None


actorname = actor_choice()
print("Selected Actors:", actorname if actorname is not None else "None")

actornames = actor_choices()
print("Selected Actors:", actornames if actornames is not None else "None")





FVerbaas ( ) posted Sat, 28 December 2019 at 9:05 AM
Forum Coordinator

Very convenient!

Thanx for sharing.


adp001 ( ) posted Sat, 28 December 2019 at 10:19 AM

You are welcome!

For the other thread: I think about clothes. Without MD ;)




maur_2005 ( ) posted Wed, 05 February 2020 at 8:13 AM

That very useful, thank you.

one question, how can I add an option that allows me to select all?


adp001 ( ) posted Wed, 05 February 2020 at 9:11 AM

This shows "SingleChoiceDialog" and "MultiChoiceDialog" as it is provided by wxPython as a quick solution. If you need it more complicated, you need to create your own dialog.

But I'm sure I also showed a dialog with "select/deselect all" somewhere :).




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.