IC8 Python API:RLPy RIDialog

From Reallusion Wiki!
Jump to: navigation, search
Main article: iC8 Modules.
Last modified: 02/2/2023

Description

This class is custom widget dialog. A Dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget.

 1 class DialogEventCallback(RLPy.RDialogCallback):
 2     def __init__(self):
 3         RLPy.RDialogCallback.__init__(self)
 4         
 5     def OnDialogShow(self):
 6         print("dialog show")
 7         
 8     def OnDialogHide(self):
 9         print("dialog hide")
10     def OnDialogClose(self):
11         print("dialog close")
12         return True
13    
14 rl_dialog = RLPy.RUi.CreateRDialog()
15 rl_dialog.SetWindowTitle("main_dialog")
16 print(rl_dialog.GetWindowTitle())       # main_dialog
17    
18 # register dialog event
19 dialog_event_callback = DialogEventCallback()
20 dialog_register_id = rl_dialog.RegisterEventCallback(dialog_event_callback)
21    
22 # use id to unregister
23 rl_dialog.UnregisterEventCallback(dialog_register_id)
24    
25 rl_dialog.Show()
26 rl_dialog.IsVisble() # True
27 rl_dialog.Hide()
28 rl_dialog.IsVisble() # False

Class Methods

RLPy.RIDialog.GetDialogType(self)

Return current dialog type.

Returns

dialog type - RLPy.EDialogType

  • RLPy.EDialogType_Normal
  • RLPy.EDialogType_Exclusive
 1 # Get normal RIDialog type
 2 rl_normal_dialog = RLPy.RUi.CreateRDialog()
 3 rl_normal_dialog.SetWindowTitle("normal_dialog")
 4 rl_normal_dialog.Show()
 5 normal_dialog_type = rl_normal_dialog.GetDialogType()
 6 print(normal_dialog_type)
 7 
 8 # Get exclusive RIDialog type
 9 rl_exclusive_dialog = RLPy.RUi.CreateRDialog(RLPy.EDialogType_Exclusive)
10 rl_exclusive_dialog.SetWindowTitle("exclusive_dialog")
11 rl_exclusive_dialog.Show()
12 exclusive_dialog_type = rl_exclusive_dialog.GetDialogType()
13 print(exclusive_dialog_type)

RLPy.RIDialog.GetTitle(self)

Get title bar widget's address.

Returns

Address of the title bar widget - QWidget

1 rl_dialog = RLPy.RUi.CreateRDialog()
2 rl_dialog.SetWindowTitle("main_dialog")
3 print(rl_dialog.GetWindowTitle())       # main_dialog

RLPy.RIDialog.GetWindow(self)

Get dialog's itself address.

Returns

a pointer to the dialog - QWidget

 1 # Create RIDialog and add widget to the dialog
 2 main_dlg_url = QUrl("...ui path")
 3 main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget()
 4 main_dlg_view.setSource(main_dlg_url)
 5 
 6 main_rl_dlg = RLPy.RUi.CreateRDialog()
 7 main_pyside_dlg = wrapInstance(int(main_rl_dlg.GetWindow()), PySide2.QtWidgets.QDialog)
 8 main_pyside_dlg.setObjectName("Main Dialog")
 9 main_layout = main_pyside_dlg.layout()
10 main_layout.addWidget(main_dlg_view)

RLPy.RIDialog.GetWindowTitle(self)

Get title bar Name.

Returns

Title bar name - string

1 # Get RIDialog titlebar text
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg_window_title = rl_dialog.GetWindowTitle()
4 print(main_rl_dlg_window_title)

RLPy.RIDialog.IsModal(self)

Return if dialog is modal or modeless.

Returns

Trueif dialog is modal Falseif dialog is modeless

1 # Get RIDialog modal status
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.SetModal(True)
5 main_rl_dlg.Show()
6 is_dialog_modal = main_rl_dlg.IsModal()
7 print(is_dialog_modal)

RLPy.RIDialog.RegisterEventCallback(self, pfCallback )

Dialog event callback.

Parameters

pfCallback[IN] dialog event callback pointer - RLPy.RDialogCallback

Returns

Dialog Event callBack id - int

 1 RLPy.RIDialog.UnregisterEventCallbacks( self, kIds )
 2 # Define RDialogCallback
 3 class DialogEventCallback(RLPy.RDialogCallback):
 4    def __init__(self):
 5        RLPy.RDialogCallback.__init__(self)
 6       
 7    def OnDialogShow(self):
 8        print("dialog show")
 9       
10    def OnDialogHide(self):
11        print("dialog hide")
12 
13    def OnDialogClose(self):
14        print("dialog close")
15        return True
16 
17 # Register RIDialog event callback
18 rl_dialog = RLPy.RUi.CreateRDialog()
19 rl_dialog.SetWindowTitle("main_dialog")
20 dialog_event_callback = DialogEventCallback()
21 dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback)
22 print(dialog_register_id)

RLPy.RIDialog.RegisterNativeEventCallback(self, pfCallback )

Windows event callback.

Parameters

pfCallback[IN] Window message callback pointer - RLPy.RWinMessageCallback

Returns

Windows Event callBack id - int

 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 RIDialog native event callback
10 rl_dialog = RLPy.RUi.CreateRDialog()
11 rl_dialog.SetWindowTitle("main_dialog")
12 native_event_callback = WinMessageCallback()
13 dialog_register_id = rl_dialog.RegisterNativeEventCallBack(native_event_callback)
14 print(dialog_register_id)

RLPy.RIDialog.SetModal(self, bModal )

Set dialog modal or modeless.

Parameters

bModal[IN] True is modal or False is modeless - bool
1 # Set RIDialog modal status
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.SetModal(True)
5 main_rl_dlg.Show()

RLPy.RIDialog.SetParent(self, pWidget )

Set the parent of the dialog.

Parameters

pWidget[IN] Widget pointer - QWidget
1 # Set RIDialog parent window address
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetParent(RLPy.RUi.GetMainWindow())

RLPy.RIDialog.SetWindowTitle(self, strTitleName )

Set dialog title name.

Parameters

strTitleName[IN] title name - string
1 # Set RIDialog titlebar text
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("test_dialog")

RLPy.RIDialog.UnregisterAllEventCallbacks(self)

Unregister all dialog event callback.

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
 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 RIDialog all event callbacks
32 rl_dialog = RLPy.RUi.CreateRDialog()
33 rl_dialog.SetWindowTitle("main_dialog")
34 dialog_event_callback_1 = DialogEventCallback1()
35 dialog_register_id_1 = rl_dialog.RegisterEventCallBack(dialog_event_callback_1)
36 dialog_event_callback_2 = DialogEventCallback2()
37 dialog_register_id_2 = rl_dialog.RegisterEventCallBack(dialog_event_callback_2)
38 result = rl_dialog.UnregisterAllEventCallbacks()
39 print(result)

RLPy.RIDialog.UnregisterEventCallback(self, uId )

Unregister dialog event callback with Id.

Parameters

uId[IN] callback id - int

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
 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 RIDialog event callback
17 rl_dialog = RLPy.RUi.CreateRDialog()
18 rl_dialog.SetWindowTitle("main_dialog")
19 dialog_event_callback = DialogEventCallback()
20 dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback)
21 result = rl_dialog.UnregisterEventCallback(dialog_register_id)
22 print(result)

RLPy.RIDialog.UnregisterEventCallbacks(self, kIds )

Unregister dialog event callback with Ids.

Parameters

kIds[IN] callback ids - int

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
 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 RIDialog event callbacks
32 rl_dialog = RLPy.RUi.CreateRDialog()
33 rl_dialog.SetWindowTitle("main_dialog")
34 dialog_event_callback_1 = DialogEventCallback1()
35 dialog_register_id_1 = rl_dialog.RegisterEventCallBack(dialog_event_callback_1)
36 dialog_event_callback_2 = DialogEventCallback2()
37 dialog_register_id_2 = rl_dialog.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_dialog.UnregisterEventCallbacks(event_handler_list)

RLPy.RIDialog.UnregisterNativeEventCallback(self, uId )

Unregister windows event callback with Id.

Parameters

uId[IN] callback id - int

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
 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 RIDialog native event callback
10 rl_dialog = RLPy.RUi.CreateRDialog()
11 rl_dialog.SetWindowTitle("main_dialog")
12 native_event_callback = WinMessageCallback()
13 dialog_register_id = rl_dialog.RegisterNativeEventCallBack(native_event_callback)
14 result = rl_dialog.UnregisterNativeEventCallback(dialog_register_id)
15 print(result)

RLPy.RIDialog.UnregisterNativeEventCallbacks(self, kIds )

Unregister windows event callback with Ids.

Parameters

kIds[IN] callback ids - int

Returns

RLPy.RStatus.Success - Succeed
RLPy.RStatus.Failure - Fail
 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 RIDialog native event callbacks
18 rl_dialog = RLPy.RUi.CreateRDialog()
19 rl_dialog.SetWindowTitle("main_dialog")
20 native_event_callback_1 = WinMessageCallback1()
21 dialog_register_id_1 = rl_dialog.RegisterNativeEventCallBack(native_event_callback_1)
22 native_event_callback_2 = WinMessageCallback2()
23 dialog_register_id_2 = rl_dialog.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_dialog.UnregisterNativeEventCallbacks(event_handler_list)
28 print(result)