IC Python API:RLPy RIDockWidget

From Reallusion Wiki!
Jump to: navigation, search

Main article: Modules. Last modified: 05/13/2020

Description

Provides dock widget related functions such as creating dock widgets and dock-able window related properties. It also allows the registration and unregistration of dock widget callback events.

Member Functions

GetWindow ( self )

Get the QWidget address of this dock widget, which can be used to create a PySide representation and later accomodate a Qt ui or qml file.

Returns

The QWidget address for this dock widget - QWidget address
 1 # Get RIDockWidget QWidget address and add view to the dockwidget
 2 main_dockwidget_url = QUrl("...ui path")
 3 main_dockwidget_view = PySide2.QtQuick.QQuickView()
 4 main_dockwidget_view.setSource(main_dockwidget_url)
 5 
 6 main_dockwidget = RLPy.RUi.CreateRDockWidget()
 7 main_pyside_dockwidget = wrapInstance(int(main_dockwidget.GetWindow()), PySide2.QtWidgets.QDockWidget)
 8 main_pyside_dockwidget.setObjectName("Main DockWidget")
 9 main_dockwidget_container = main_pyside_dockwidget.createWindowContainer(main_dockwidget_view)
10 main_dockwidget_container.setMinimumWidth(main_dockwidget_view.width())
11 main_dockwidget_container.setMinimumHeight(main_dockwidget_view.height())
12 main_pyside_dockwidget.setWidget(main_dockwidget_container)

GetTitle ( self )

Get the QWidget address of this dock widget's title-bar, which can be used to deploy PySide operations.

Returns

The QWidget address of this dock widget's title-bar - QWidget address
1 # Get RIDockWidget titlebar QWidget address
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget_title_bar_widget = wrapInstance(int(main_dockwidget.GetTitle()), PySide2.QtWidgets.QWidget)

GetWindowTitle ( self )

Get this dock widget's title-bar label text.

See Also: SetWindowTitle

Returns

This dock widget's title text - string
1 # Get RIDockWidget titlebar text
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget_window_title = main_dockwidget.GetWindowTitle()
4 print(main_dockwidget_window_title)

SetWindowTitle ( self, strTitleName )

Set the label text for this dock widget's title-bar.

Parameters

strTitleName [IN] Label text for the title-bar - string
1 # Set RIDockWidget titlebar text
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")

SetWidget ( self, pWidget )

Insert another widget into this dock widget, by way of its window address, into this dock widget.

Parameters

pWidget [IN] The insert widget's window address.
1 # Set RIDockWidget widget window address
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_dockwidget = RLPy.RUi.CreateRDockWidget()
4 main_dockwidget.SetWidget(main_rl_dlg.GetWindow())

SetParent ( self, pWidget )

Set the parent widget for this dock widget according to its window address. Currently, the main window is the only viable option as the parent widget.

Parameters

pWidget [IN] Parent widget's window address.
1 # Set RIDockWidget parent window address
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetParent(RLPy.RUi.GetMainWindow())

Show ( self )

Make this dock widget visible.

See Also: Hide, Close

1 # Show RIDockWidget
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.Show()

Hide ( self )

Hide this dock widget, but keep it in system memory.

See Also: Show, Close

1 # Hide RIDockWidget
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.Show()
5 main_dockwidget.Hide()

Close ( self )

Close this dock widget and release it from system memory.

See Also: Show, Hide

1 # Close RIDockWidget
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.Show()
5 main_dockwidget.Close()

IsVisible ( self )

Check whether if this dock widget is visible or not.

See Also: Show, Hide, Close

Returns

Visibility state of this dock widget - boolean
1 # Is RIDockWidget visible
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 rl_dockwidget.Show()
5 is_dockwidget_visible = main_dockwidget.IsVisible()
6 print(is_dockwidget_visible)

SetAllowedAreas ( self, eArea )

Set the dockable areas for this dock widget. Bit-wise operations can be used to combine and exclude different dock-able areas

See Also: IsAreaAllowed

Parameters

eArea [IN] The dock-able areas for this dock widget - RLPy.EDockWidgetAreas
1 # Set RIDockWidget allowed area
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.SetAllowedAreas(RLPy.EDockWidgetAreas_LeftDockWidgetArea)
5 main_dockwidget.Show()

SetFloating ( self, bFloating )

Set the floating state of this dock widget. Currently, only a value of True takes effect.

See Also: IsFloating

Parameters

bFloating [IN] The float state for this dock widget - boolean
1 # Set RIDockWidget floating status
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.SetFloating(True)
5 main_dockwidget.Show()

SetFeatures ( self, eFeatures )

Allow this dock widget to be movable, closable, and floatable. The feature parameter can be treated with bit-wise operations. The available RLPy.EDockWidgetFeatures match those inside PySide2.QtCore.Qt.

See Also: Features

Parameters

eFeatures [IN] Features flags to be applied to this dock widget - RLPy.EDockWidgetFeatures
1 # Set RIDockWidget [[#Features ( self )|Features]]
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.SetFeatures(RLPy.EDockWidgetFeatures_Movable)
5 main_dockwidget.Show()

Features ( self )

Get all of the feature flags applied to this dock widget.

See also: SetFeatures

Returns

All feature flags on this dock widget - RLPy.EDockWidgetFeatures
1 # Get RIDockWidget [[#Features ( self )|Features]]
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.SetFeatures(RLPy.EDockWidgetFeatures_Movable)
5 main_dockwidget.Show()
6 features = rl_dockwidget.Features()
7 print(features)

IsAreaAllowed ( self, eArea )

Check if this dock widget can be docked into a certain region of the application.

See Also: SetAllowedAreas

Returns

returns True if this dock widget can dock with the region in question, else False - boolean
1 # Is RIDockWidget area allowed
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.SetAllowedAreas(RLPy.EDockWidgetAreas_LeftDockWidgetArea)
5 main_dockwidget.Show()
6 is_dockwidget_area_allowed = main_dockwidget.IsAreaAllowed(RLPy.EDockWidgetAreas_LeftDockWidgetArea)
7 print(is_dockwidget_area_allowed)

IsFloating ( self )

Check if this dock widget is floating (not docked to the application's main window).

See also: SetFloating

Returns

Floating status of this dock widget - boolean
1 # Get RIDockWidget floating status
2 main_dockwidget = RLPy.RUi.CreateRDockWidget()
3 main_dockwidget.SetWindowTitle("Main Dockwidget")
4 main_dockwidget.Show()
5 is_dockwidget_floating = main_dockwidget.IsFloating()
6 print(is_dockwidget_floating)

RegisterNativeEventCallback ( self, pfCallback )

Register a RWinMessageCallback with this dock widget and returns its ID.

See Also: UnregisterNativeEventCallback, UnregisterNativeEventCallbacks

Parameters

pfCallback [IN] The Windows message callback for registration - RWinMessageCallback

Returns

ID of the unregsitered RWinMessageCallback - integer
 1 # Define RWinMessageCallback
 2 class WinMessageCallback(RLPy.RWinMessageCallback):
 3    def __init__(self):
 4        RLPy.RWinMessageCallback.__init__(self)
 5       
 6    def OnWinMsgReceieved(self, data):
 7        print("window message received")
 8 
 9 # Register RIDockWidget native event callback
10 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
11 rl_dockwidget.SetWindowTitle("main_dockwidget")
12 native_event_callback = WinMessageCallback()
13 dialog_register_id = rl_dockwidget.RegisterNativeEventCallBack(native_event_callback)
14 print(dialog_register_id)

UnregisterNativeEventCallback ( self, uId )

Unregister a RWinMessageCallback from this dock widget.

See Also: RegisterNativeEventCallback, UnregisterNativeEventCallbacks

Parameters

uId [IN] ID of the unregisterd RWinMessageCallback - integer

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Define RWinMessageCallback
 2 class WinMessageCallback(RLPy.RWinMessageCallback):
 3    def __init__(self):
 4        RLPy.RWinMessageCallback.__init__(self)
 5       
 6    def OnWinMsgReceieved(self, data):
 7        print("window message received")
 8 
 9 # Unregister RIDockWidget native event callback
10 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
11 rl_dockwidget.SetWindowTitle("main_dockwidget")
12 native_event_callback = WinMessageCallback()
13 dialog_register_id = rl_dialog.RegisterNativeEventCallBack(native_event_callback)
14 result = rl_dockwidget.UnregisterNativeEventCallback(dialog_register_id)
15 print(result)

UnregisterNativeEventCallbacks ( self, kIds )

Unregister a collection of RWinMessageCallback from this dock widget. If unregistration of one of the callbacks fails, it will still attempt to unregister the rest.

See Also: RegisterNativeEventCallback, UnregisterNativeEventCallback

Parameters

kIds [IN] Collection of Windows message callback ids - integer list

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Define RWinMessageCallback 1
 2 class WinMessageCallback1(RLPy.RWinMessageCallback):
 3    def __init__(self):
 4        RLPy.RWinMessageCallback.__init__(self)
 5       
 6    def OnWinMsgReceieved(self, data):
 7        print("[WinMessageCallback1]window message received")
 8 
 9 # Define RWinMessageCallback 2
10 class WinMessageCallback2(RLPy.RWinMessageCallback):
11    def __init__(self):
12        RLPy.RWinMessageCallback.__init__(self)
13       
14    def OnWinMsgReceieved(self, data):
15        print("[WinMessageCallback2]window message received2")
16 
17 # Unregister RIDockWidget native event callbacks
18 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
19 rl_dockwidget.SetWindowTitle("main_dockwidget")
20 native_event_callback_1 = WinMessageCallback1()
21 dialog_register_id_1 = rl_dockwidget.RegisterNativeEventCallBack(native_event_callback_1)
22 native_event_callback_2 = WinMessageCallback2()
23 dialog_register_id_2 = rl_dockwidget.RegisterNativeEventCallBack(native_event_callback_2)
24 event_handler_list = []
25 event_handler_list.append(dialog_register_id_1)
26 event_handler_list.append(dialog_register_id_2)
27 result = rl_dockwidget.UnregisterNativeEventCallbacks(event_handler_list)
28 print(result)

RegisterEventCallback ( self, pfCallback )

Register a RDialogCallback to this dock widget and return its ID.

See Also: UnregisterEventCallback, UnregisterEventCallbacks

Parameters

pfCallback [IN] The designated dialog callback object - RDialogCallback

Returns

The ID of the registered RDialogCallback - integer
 1 # Define RDialogCallback
 2 class DialogEventCallback(RLPy.RDialogCallback):
 3    def __init__(self):
 4        RLPy.RDialogCallback.__init__(self)
 5       
 6    def OnDialogShow(self):
 7        print("dialog show")
 8       
 9    def OnDialogHide(self):
10        print("dialog hide")
11 
12    def OnDialogClose(self):
13        print("dialog close")
14        return True
15 
16 # Register RIDockWidget event callback
17 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
18 rl_dockwidget.SetWindowTitle("main_dockwidget")
19 dialog_event_callback = DialogEventCallback()
20 dialog_register_id = rl_dockwidget.RegisterEventCallBack(dialog_event_callback)
21 print(dialog_register_id)

UnregisterEventCallback ( self, uId )

Unregister a RDialogCallback from this dock widget.

See Also: RegisterEventCallback, UnregisterEventCallbacks

Parameters

uId [IN] ID of the callback for unregistering - integer

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Define RDialogCallback
 2 class DialogEventCallback(RLPy.RDialogCallback):
 3    def __init__(self):
 4        RLPy.RDialogCallback.__init__(self)
 5       
 6    def OnDialogShow(self):
 7        print("dialog show")
 8       
 9    def OnDialogHide(self):
10        print("dialog hide")
11 
12    def OnDialogClose(self):
13        print("dialog close")
14        return True
15 
16 # Unregister RIDockWidget event callback
17 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
18 rl_dockwidget.SetWindowTitle("main_dockwidget")
19 dialog_event_callback = DialogEventCallback()
20 dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback)
21 result = rl_dockwidget.UnregisterEventCallback(dialog_register_id)
22 print(result)

UnregisterEventCallbacks ( self, kIds )

Unregister a collection of RDialogCallback from this dock widget. If unregistration of one of the callbacks fails, it will still attempt to unregister the rest.

See Also: RegisterEventCallback, UnregisterEventCallback, UnregisterEventCallbacks

Parameters

kIds [IN] Collection of dialog callback ids for unregistering - integer list

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Define RDialogCallback 1
 2 class DialogEventCallback1(RLPy.RDialogCallback):
 3    def __init__(self):
 4        RLPy.RDialogCallback.__init__(self)
 5       
 6    def OnDialogShow(self):
 7        print("[DialogEventCallback1]dialog show")
 8       
 9    def OnDialogHide(self):
10        print("[DialogEventCallback1]dialog hide")
11 
12    def OnDialogClose(self):
13        print("[DialogEventCallback1]dialog close")
14        return True
15 
16 # Define RDialogCallback 2
17 class DialogEventCallback2(RLPy.RDialogCallback):
18    def __init__(self):
19        RLPy.RDialogCallback.__init__(self)
20       
21    def OnDialogShow(self):
22        print("[DialogEventCallback2]dialog show")
23       
24    def OnDialogHide(self):
25        print("[DialogEventCallback2]dialog hide")
26 
27    def OnDialogClose(self):
28        print("[DialogEventCallback2]dialog close")
29        return True
30 
31 # Unregister RIDockWidget event callback
32 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
33 rl_dockwidget.SetWindowTitle("main_dockwidget")
34 dialog_event_callback_1 = DialogEventCallback1()
35 dialog_register_id_1 = rl_dockwidget.RegisterEventCallBack(dialog_event_callback_1)
36 dialog_event_callback_2 = DialogEventCallback2()
37 dialog_register_id_2 = rl_dockwidget.RegisterEventCallBack(dialog_event_callback_2)
38 event_handler_list = []
39 event_handler_list.append(dialog_register_id_1)
40 event_handler_list.append(dialog_register_id_2)
41 result = rl_dockwidget.UnregisterEventCallbacks(event_handler_list)
42 print(result)

UnregisterAllEventCallbacks ( self )

Unregister all RDialogCallback on this dock widget

See Also: RegisterEventCallback, UnregisterEventCallback, UnregisterEventCallbacks

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 # Define RDialogCallback 1
 2 class DialogEventCallback1(RLPy.RDialogCallback):
 3    def __init__(self):
 4        RLPy.RDialogCallback.__init__(self)
 5       
 6    def OnDialogShow(self):
 7        print("[DialogEventCallback1]dialog show")
 8       
 9    def OnDialogHide(self):
10        print("[DialogEventCallback1]dialog hide")
11 
12    def OnDialogClose(self):
13        print("[DialogEventCallback1]dialog close")
14        return True
15 
16 # Define RDialogCallback 2
17 class DialogEventCallback2(RLPy.RDialogCallback):
18    def __init__(self):
19        RLPy.RDialogCallback.__init__(self)
20       
21    def OnDialogShow(self):
22        print("[DialogEventCallback2]dialog show")
23       
24    def OnDialogHide(self):
25        print("[DialogEventCallback2]dialog hide")
26 
27    def OnDialogClose(self):
28        print("[DialogEventCallback2]dialog close")
29        return True
30 
31 # unregister RIDockWidget event callback
32 rl_dockwidget = RLPy.RUi.CreateRDockWidget()
33 rl_dockwidget.SetWindowTitle("main_dockwidget")
34 dialog_event_callback_1 = DialogEventCallback1()
35 dialog_register_id_1 = rl_dockwidget.RegisterEventCallBack(dialog_event_callback_1)
36 dialog_event_callback_2 = DialogEventCallback2()
37 dialog_register_id_2 = rl_dockwidget.RegisterEventCallBack(dialog_event_callback_2)
38 result = rl_dockwidget.UnregisterAllEventCallbacks()
39 print(result)