IC Python API:Message Box

From Reallusion Wiki!
Revision as of 20:17, 17 September 2019 by Chuck (RL) (Talk | contribs)

Jump to: navigation, search

Main article: RL Python Samples.

iClone Python API has the ability to display pop-up message boxes that can ease the flow of your scripted procedures, as well as provide warnings and alerts. Message boxes can be sparse with no interaction except for the universal close window button on the top right of the window bar. They can also support a single checkbox and a single button interaction. The label on the single button changes according to the type of button called, they are the following:


Required Modules

The only required module for this lesson is the standard Reallusion Python API library.

import RLPy
</sytnaxhighlight>


== Simple Message Box ==

The most simple message boxes just provide additional information to the user.

<syntaxhighlight lang="python">
RLPy.RUi.ShowMessageBox(
    "Message 1/3",
    "Message boxes can block operations.",
    RLPy.EMsgButton_Ok)


Message Box with Checkbox

In addition, message boxes can support check-boxes for more complex interactions.

button_status = RLPy.RUi.ShowMessageBox(
    "Message 2/3",
    "We can demonstrate this with a check-box...",
    RLPy.EMsgButton_Close,
    True,
    "Try me!"
)
</sytnaxhighlight>


== Action Blocking Message Boxes ==

Message boxes are asynchronous; they block the next action until the user removes it by clicking on the button or exiting the window.

<syntaxhighlight lang="python">
RLPy.RUi.ShowMessageBox(
    "Message 3/3",
    {1024: "<b>False:</b> Checkbox was <b><i>NOT</i></b> activated.",
     268435456: "<b>True</b> Checkbox was activated!",
     2097152: "<b>Canceled:</b> The message box was closed prematurely.",
     }[button_status],
    RLPy.EMsgButton_Ok
)

Everything Put Together

You can copy and paste the following code into a PY file and load it into iClone via Script > Load Python.

import RLPy

RLPy.RUi.ShowMessageBox(
    "Message 1/3",
    "Message boxes can block operations.",
    RLPy.EMsgButton_Ok)

button_status = RLPy.RUi.ShowMessageBox(
    "Message 2/3",
    "We can demonstrate this with a check-box...",
    RLPy.EMsgButton_Close,
    True,
    "Try me!"
)

RLPy.RUi.ShowMessageBox(
    "Message 3/3",
    {1024: "<b>False:</b> Checkbox was <b><i>NOT</i></b> activated.",
     268435456: "<b>True</b> Checkbox was activated!",
     2097152: "<b>Canceled:</b> The message box was closed prematurely.",
     }[button_status],
    RLPy.EMsgButton_Ok
)

APIs Used

You can research the following references for the APIs deployed in this code.