IC Python API:RLPy RIDialog
Contents
- 1 Description
- 2 Member Functions
- 2.1 GetWindow ( self )
- 2.2 GetTitle ( self )
- 2.3 GetWindowTitle ( self )
- 2.4 SetWindowTitle ( self, strTitleName )
- 2.5 SetParent ( self, pWidget )
- 2.6 Show ( self )
- 2.7 Hide ( self )
- 2.8 Close ( self )
- 2.9 IsVisible ( self )
- 2.10 SetModal ( self, bModal )
- 2.11 IsModal ( self )
- 2.12 GetDialogType ( self )
- 2.13 RegisterNativeEventCallback ( self, pfCallback )
- 2.14 UnregisterNativeEventCallback ( self, uId )
- 2.15 UnregisterNativeEventCallbacks ( self, kIds )
- 2.16 RegisterEventCallback ( self, pfCallback )
- 2.17 UnregisterEventCallback ( self, uId )
- 2.18 UnregisterEventCallbacks ( self, kIds )
- 2.19 UnregisterAllEventCallbacks ( self )
- Main article: Modules.
- Last modified: 05/13/2020
Description
Provides dialog UI related functions such as creating dialog windows and dialog related properties. It also allows the registration and unregistration of dialog callback events.
Member Functions
GetWindow ( self )
Get the QWidget address of this dialog, which can be used to create a PySide representation and later accommodate a Qt ui or qml file.
Returns
- This dialog's QWidget address - QWidget address
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)
GetTitle ( self )
Get this dialog's title-bar QWidget address, which can be used to apply PySide operations.
Returns
- The titlebar QWidget address of this dialog - QWidget address
1 # Get RIDialog titlebar QWidget address
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_dlg_title_bar_widget = wrapInstance(int(main_rl_dlg.GetTitle()), PySide2.QtWidgets.QWidget)
GetWindowTitle ( self )
Get the title-bar label text for this dialog.
See Also: SetWindowTitle
Returns
- This dialog's titlebar label text - 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)
SetWindowTitle ( self, strTitleName )
Set the title-bar label text for this dialog.
See Also: GetWindowTitle
Parameters
- strTitleName [IN] Title-bar label text title-bar - string
1 # Set RIDialog titlebar text
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("test_dialog")
SetParent ( self, pWidget )
Set the parent widget for this dialog according to the input window address. When the parent widget is closed, its child widget is also closed. Currently, only the main window is supported as the parent widget.
Parameters
- pWidget [IN] parent widget的window address
1 # Set RIDialog parent window address
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetParent(RLPy.RUi.GetMainWindow())
Show ( self )
Display this dialog (make it visible).
1 # Show RIDialog
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.Show()
Hide ( self )
Hide this dialog but keep it in system memory.
1 # Hide RIDialog
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.Show()
5 main_rl_dlg.Hide()
Close ( self )
Close this dialog window and release it from memory.
1 # Close RIDialog
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.Show()
5 main_rl_dlg.Close()
IsVisible ( self )
Check whether if this dialog is visible or not.
Returns
- This dialog's visibility - boolean
1 # Is RIDialog visible
2 main_rl_dlg = RLPy.RUi.CreateRDialog()
3 main_rl_dlg.SetWindowTitle("Main Dialog")
4 main_rl_dlg.Show()
5 is_dialog_visible = main_rl_dlg.IsVisible()
6 print(is_dialog_visible)
SetModal ( self, bModal )
Set the modal state for this dialog. A modal dialog forces the application to focus on it, whereupon only operations within the dialog are allowed, until it is closed.
See Also: IsModal
Parameters
- bModal [IN] Modal state of this dialog - boolean
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()
IsModal ( self )
Check whether if this dialog is a modal window.
See Also: SetModal
Returns
- True if this dialog is a modal, else False - boolean
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)
GetDialogType ( self )
Get the type of this dialog, which is either normal or exclusive. Multiple instances of normal dialog windows can exists at the same time, while there can only be one instance of exclusive dialog at any given time.
Returns
- The RIDialog type - RLPy.EDialogType
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)
RegisterNativeEventCallback ( self, pfCallback )
Register a RWinMessageCallback event with this dialog and return its id.
See Also: UnregisterNativeEventCallback, UnregisterNativeEventCallbacks
Parameters
- pfCallback [IN] The designated Windows message callback event - RWinMessageCallback
Returns
- The registered RWinMessageCallback event id - 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 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)
UnregisterNativeEventCallback ( self, uId )
Unregister RWinMessageCallback event from this dialog.
See Also: RegisterNativeEventCallback, UnregisterNativeEventCallbacks
Parameters
- uId [IN] RWinMessageCallback ids for unreggistering - 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 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)
UnregisterNativeEventCallbacks ( self, kIds )
Unregister a collection of RWinMessageCallback from this dialog. If one of the events fails to unregister, it will not affect subsequent unregistering.
See Also: RegisterNativeEventCallback, UnregisterNativeEventCallback
Parameters
- kIds [IN] The ids of the Windows message callback objects - 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 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)
RegisterEventCallback ( self, pfCallback )
Register a RDialogCallback to this dialog and return its id.
See Also: UnregisterEventCallback, UnregisterEventCallbacks
Parameters
- pfCallback [IN] The designated dialog callback event - RDialogCallback
Returns
- The id of the registered RDialogCallback - integer
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)
UnregisterEventCallback ( self, uId )
Unregister a RDialogCallback from this dialog according to its id.
See Also: RegisterEventCallback, UnregisterEventCallbacks
Parameters
- uId [IN] The dialog callback id 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 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)
UnregisterEventCallbacks ( self, kIds )
Unregister a collection of RDialogCallback from this dialog according to the given ids. If one of the events fails to unregister, it will not affect subsequent unregistering.
See Also: RegisterEventCallback, UnregisterEventCallback
Parameters
- kIds [IN] RDialogCallback 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 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)
UnregisterAllEventCallbacks ( self )
Unregister all event callbacks from this dialog.
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 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)