IC8 Python API:RLPy RUi

From Reallusion Wiki!
Jump to: navigation, search

Contents

Description

This class is a package of instructions related to the application user interface (UI). It includes the ability to bridge communication between plugins and the application UI system, provides operations for the main window and menu, application version settings, show message boxes, open file browse dialog, as well as adding RIDialog and RIDockWidget related components, and much more. By using this class, developers can define plugin behaviors via custom user interfaces to achieve their goals.

Constructor & Destructor

__init__ (self)

Initializes a new ui instance.

Member Functions

AddContextAction (spObject, strText)

Adds context action.

Parameters

  • spObject
  • strText

AddContextMenu (spObject, strText)

Adds context menu.

Parameters

  • spObject
  • strText

AddHotKey (strKeySequence)

Create and register a hotkey event. The input hotkey string will be compared with the keys within QKeySequence of the Qt component and returns a QAction address. If the given hotkey is already registered to another event, then the previous event will be replaced by the newly registered hotkey event. In order to revert to the previous event, one must first unregister the current event.

Parameters

  • strKeySequence

Sample code

Register a Tab shortcut and remove it in a finally block.

def run_script():
    import RLPy
    hotkey = RLPy.RUi.AddHotKey("tab")
    if hotkey is None:
        raise RuntimeError("AddHotKey did not return an action.")
    try:
        pass
    finally:
        result = RLPy.RUi.RemoveHotKey(hotkey)
    assert result == RLPy.RStatus.Success

Preconditions

  • Before running, confirm that Tab is not already assigned to another action; AddHotKey can replace an existing Tab event.

Side Effects

  • Temporarily registers Tab. If Tab already has an event, AddHotKey replaces it, and RemoveHotKey does not restore the previous event.

AddMenu (*args)

Currently, this function can only create menu items within the Plugins menu. The Qmenu address is returned upon creation.

Parameters

  • args

Sample code

Add a uniquely named item to the Plugins menu.

def run_script():
    import uuid
    import RLPy
    menu_name = "Codex API sample " + uuid.uuid4().hex
    menu_item = RLPy.RUi.AddMenu(menu_name, RLPy.EMenu_Plugins)
    assert menu_item is not None

Side Effects

  • Adds a uniquely named item to the Plugins menu. The item remains after run_script returns; this sample does not remove it.

CallLuaFunction (strFilePath, strFunction, kParam, kReturn)

Call Lua function.

Parameters

  • strFilePath
  • strFunction
  • kParam
  • kReturn

ClearViewportLabels (strOwnerId)

Removes all viewport labels owned by strOwnerId.

Parameters

  • strOwnerId

CreateRDialog (*args)

Create either a normal or exclusive dialog object and return it. A normal dialog can exist among other instances at the same time, while exclusive means that only one instance can be displayed at any given time.

Parameters

  • args

CreateRDockWidget (*args)

Create a new dock widget object and return it as RIDockWidget.

Parameters

  • args

FindMenu (*args)

Find submenu under Plugin menu, create if not found.

Parameters

  • args

FindToolBar (strToolBarName)

Find toolbar, create if not exist.

Parameters

  • strToolBarName

GetCSSType ()

Get the current application cascading style sheet (CSS) settings.

GetMainWindow ()

Get the QWidget address for the main window. You can bind the main window to a PySide object by using this function, for UI operations.

Sample code

Retrieve the application's main window handle.

def run_script():
    import RLPy
    main_window = RLPy.RUi.GetMainWindow()

GetResolutionType ()

Get the application resolution settings.

IsProgressCancel ()

Checks if the user has requested to cancel the operation.

LoadLuaUI (strFilePath)

Loads Lua UI.

Parameters

  • strFilePath

OpenFileDialog (*args)

Browse for a file by opening the file open dialog window according to the extension filter and a starting directory. If the starting directory is an empty string, then it will automatically browse to the last directory location recorded by the application as the opening path. See also: OpenFilesDialog

Parameters

  • args

Sample code

Open a JSON file-selection dialog and return the selected path, if any.

def run_script():
    import RLPy
    selected_path = RLPy.RUi.OpenFileDialog("Json Files(*.json)")
    return selected_path

Preconditions

  • Run in an interactive iClone session.

Side Effects

  • Displays a modal dialog until the user selects a path or cancels.

OpenFilesDialog (*args)

Browse for multiple files by opening the file open dialog window according to the extension filter and a starting directory. If the starting directory is an empty string, then it will automatically browse to the last directory location recorded by the application as the opening path. See also: OpenFileDialog

Parameters

  • args

PopProgress ()

Updates the progress and pops the current task from the progress stack.

PushProgress (fProgress)

Pushes a new task onto the progress stack.

Parameters

  • fProgress

RemoveContextAction (spObject, pAction)

Removes context action.

Parameters

  • spObject
  • pAction

RemoveContextMenu (spObject, pMenu)

Removes context menu.

Parameters

  • spObject
  • pMenu

RemoveHotKey (pAction)

Remove a hotkey event registered to the given QAction address.

Parameters

  • pAction

Sample code

Register a Tab shortcut and remove it in a finally block.

def run_script():
    import RLPy
    hotkey = RLPy.RUi.AddHotKey("tab")
    if hotkey is None:
        raise RuntimeError("AddHotKey did not return an action.")
    try:
        pass
    finally:
        result = RLPy.RUi.RemoveHotKey(hotkey)
    assert result == RLPy.RStatus.Success

Preconditions

  • Before running, confirm that Tab is not already assigned to another action; AddHotKey can replace an existing Tab event.

Side Effects

  • Temporarily registers Tab. If Tab already has an event, AddHotKey replaces it, and RemoveHotKey does not restore the previous event.

RemoveMenu (pMenu)

Remove a menu item from the main window. Currently, this function only supports removal of menu items from the Plugins menu.

Parameters

  • pMenu

SaveFileDialog (*args)

Launch a save file dialog window and save a file to a specified file path. The possible file types can be restricted by the strFilter parameter. Once a file is saved, its absolute path is returned.

Parameters

  • args

Sample code

Open a JSON save dialog and return the selected path, if any.

def run_script():
    import RLPy
    selected_path = RLPy.RUi.SaveFileDialog("Json Files(*.json)")
    return selected_path

Preconditions

  • Run in an interactive iClone session.

Side Effects

  • Displays a modal dialog until the user selects a path or cancels.

SetProgressStatusString (strStatus)

Sets progress dialog status string.

Parameters

  • strStatus

SetViewportLabels (ownerId, labels, defaultTextStyle=None)

Replaces the viewport labels owned by strOwnerId.

Parameters

  • ownerId
  • labels
  • defaultTextStyle

ShowMessageBox (*args)

Displays a message box with the configured button choices and returns the selected button status.

Parameters

  • args

ShowProgressDialog (bShow, bCancelable=False, bPauseRender=True)

Show progress dialog.

Parameters

  • bShow
  • bCancelable (default: False)
  • bPauseRender (default: True)

Properties

thisown

Indicates whether this SWIG proxy owns the underlying C++ object.