Difference between revisions of "IC Python API:RLPy RIDialog"
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class is custom widget dialog. A Dialog is always a top-level widget, but if it has a...") |
Chuck (RL) (Talk | contribs) m |
||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | + | {{last_modified}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | == 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 | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | # Create RIDialog and add widget to the dialog | |
− | + | main_dlg_url = QUrl("...ui path") | |
− | + | main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget() | |
− | + | main_dlg_view.setSource(main_dlg_url) | |
− | + | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_pyside_dlg = wrapInstance(int(main_rl_dlg.GetWindow()), PySide2.QtWidgets.QDialog) | ||
+ | main_pyside_dlg.setObjectName("Main Dialog") | ||
+ | main_layout = main_pyside_dlg.layout() | ||
+ | main_layout.addWidget(main_dlg_view) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | |
− | === | + | === GetTitle ( self ) === |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | 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 | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Get RIDialog titlebar QWidget address | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_dlg_title_bar_widget = wrapInstance(int(main_rl_dlg.GetTitle()), PySide2.QtWidgets.QWidget) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === GetWindowTitle ( self ) === |
− | + | ||
− | + | Get the title-bar label text for this dialog. | |
− | + | ||
− | + | See Also: [[#SetWindowTitle ( self, strTitleName )|SetWindowTitle]] | |
− | + | ||
− | === | + | ==== Returns ==== |
− | <syntaxhighlight lang=" | + | :This dialog's titlebar label text - string |
− | RLPy. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Get RIDialog titlebar text | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg_window_title = rl_dialog.GetWindowTitle() | ||
+ | print(main_rl_dlg_window_title) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === SetWindowTitle ( self, strTitleName ) === |
− | + | ||
− | + | Set the title-bar label text for this dialog. | |
− | + | ||
− | === | + | See Also: [[#GetWindowTitle ( self )|GetWindowTitle]] |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | ==== Parameters ==== |
+ | :'''strTitleName''' [IN] Title-bar label text title-bar - string | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Set RIDialog titlebar text | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("test_dialog") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === 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 ==== |
− | <syntaxhighlight lang=" | + | :'''pWidget''' [IN] parent widget的window address |
− | RLPy. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Set RIDialog parent window address | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetParent(RLPy.RUi.GetMainWindow()) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | === | + | === Show ( self ) === |
− | + | ||
− | + | Display this dialog (make it visible). | |
− | + | ||
− | + | See Also: [[#Hide ( self )|Hide]], [[#Close ( self )|Close]] | |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | <syntaxhighlight lang="python" line='line'> |
+ | # Show RIDialog | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.Show() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === Hide ( self ) === | |
− | + | Hide this dialog but keep it in system memory. | |
− | + | ||
− | + | See Also: [[#Show ( self )|Show]], [[#Close ( self )|Close]] | |
− | + | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
− | RLPy. | + | # Hide RIDialog |
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.Show() | ||
+ | main_rl_dlg.Hide() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === Close ( self ) === | |
− | + | ||
− | === | + | Close this dialog window and release it from memory. |
− | + | ||
− | + | See Also: [[#Show ( self )|Show]], [[#Hide ( self )|Hide]] | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | <syntaxhighlight lang=" | + | # Close RIDialog |
− | RLPy. | + | main_rl_dlg = RLPy.RUi.CreateRDialog() |
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.Show() | ||
+ | main_rl_dlg.Close() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === IsVisible ( self ) === | |
− | + | ||
− | ====Returns==== | + | Check whether if this dialog is visible or not. |
− | + | ||
− | + | See Also: [[#Show ( self )|Show]], [[#Hide ( self )|Hide]], [[#Close ( self )|Close]] | |
− | + | ||
− | + | ==== Returns ==== | |
− | <syntaxhighlight lang=" | + | :This dialog's visibility - boolean |
− | RLPy. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Is RIDialog visible | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.Show() | ||
+ | is_dialog_visible = main_rl_dlg.IsVisible() | ||
+ | print(is_dialog_visible) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === 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. | |
− | === | + | |
− | <syntaxhighlight lang=" | + | See Also: [[#IsModal ( self )|IsModal]] |
− | RLPy. | + | |
+ | ==== Parameters ==== | ||
+ | :'''bModal''' [IN] Modal state of this dialog - boolean | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Set RIDialog modal status | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.SetModal(True) | ||
+ | main_rl_dlg.Show() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === IsModal ( self ) === | |
− | + | ||
− | + | Check whether if this dialog is a modal window. | |
− | === | + | |
− | <syntaxhighlight lang=" | + | See Also: [[#SetModal ( self, bModal )|SetModal]] |
− | RLPy. | + | |
+ | ==== Returns ==== | ||
+ | :Return '''True''' if this dialog is a modal, else '''False''' - boolean | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Get RIDialog modal status | ||
+ | main_rl_dlg = RLPy.RUi.CreateRDialog() | ||
+ | main_rl_dlg.SetWindowTitle("Main Dialog") | ||
+ | main_rl_dlg.SetModal(True) | ||
+ | main_rl_dlg.Show() | ||
+ | is_dialog_modal = main_rl_dlg.IsModal() | ||
+ | print(is_dialog_modal) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === 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. | |
− | === | + | |
− | <syntaxhighlight lang=" | + | ==== Returns ==== |
− | RLPy.RIDialog. | + | :The [[IC_Python_API:RLPy_RIDialog|RIDialog]] type - [[IC_Python_API:Enums#RLPy.EDialogType|RLPy.EDialogType]] |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Get normal RIDialog type | ||
+ | rl_normal_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_normal_dialog.SetWindowTitle("normal_dialog") | ||
+ | rl_normal_dialog.Show() | ||
+ | normal_dialog_type = rl_normal_dialog.GetDialogType() | ||
+ | print(normal_dialog_type) | ||
+ | |||
+ | # Get exclusive RIDialog type | ||
+ | rl_exclusive_dialog = RLPy.RUi.CreateRDialog(RLPy.EDialogType_Exclusive) | ||
+ | rl_exclusive_dialog.SetWindowTitle("exclusive_dialog") | ||
+ | rl_exclusive_dialog.Show() | ||
+ | exclusive_dialog_type = rl_exclusive_dialog.GetDialogType() | ||
+ | print(exclusive_dialog_type) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === RegisterNativeEventCallback ( self, pfCallback ) === | |
− | ''' | + | Register a [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] event with this dialog and return its id. |
− | + | ||
− | + | See Also: [[#UnregisterNativeEventCallback ( self, uId )|UnregisterNativeEventCallback]], [[#UnregisterNativeEventCallbacks ( self, kIds )|UnregisterNativeEventCallbacks]] | |
− | === | + | |
− | <syntaxhighlight lang=" | + | ==== Parameters ==== |
− | RLPy. | + | :'''pfCallback''' [IN] The designated Windows message callback event - [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] |
+ | |||
+ | ==== Returns ==== | ||
+ | :The registered [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] event id - integer | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RWinMessageCallback | ||
+ | class WinMessageCallback(RLPy.RWinMessageCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RWinMessageCallback.__init__(self) | ||
+ | |||
+ | def OnWinMsgReceieved(self, data): | ||
+ | print("window message received") | ||
+ | |||
+ | # Register RIDialog native event callback | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | native_event_callback = WinMessageCallback() | ||
+ | dialog_register_id = rl_dialog.RegisterNativeEventCallBack(native_event_callback) | ||
+ | print(dialog_register_id) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === UnregisterNativeEventCallback ( self, uId ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | + | Unregister [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] event from this dialog. | |
− | ''' | + | See Also: [[#RegisterNativeEventCallback ( self, pfCallback )|RegisterNativeEventCallback]], [[#UnregisterNativeEventCallbacks ( self, kIds )|UnregisterNativeEventCallbacks]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''uId''' [IN] [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] ids for unreggistering - integer |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | ==== Return ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RWinMessageCallback | ||
+ | class WinMessageCallback(RLPy.RWinMessageCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RWinMessageCallback.__init__(self) | ||
+ | |||
+ | def OnWinMsgReceieved(self, data): | ||
+ | print("window message received") | ||
+ | |||
+ | # Unregister RIDialog native event callback | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | native_event_callback = WinMessageCallback() | ||
+ | dialog_register_id = rl_dialog.RegisterNativeEventCallBack(native_event_callback) | ||
+ | result = rl_dialog.UnregisterNativeEventCallback(dialog_register_id) | ||
+ | print(result) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === UnregisterNativeEventCallbacks ( self, kIds ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | + | Unregister a collection of [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] from this dialog. If one of the events fails to unregister, it will not affect subsequent unregistering. | |
− | ''' | + | See Also: [[#RegisterNativeEventCallback ( self, pfCallback )|RegisterNativeEventCallback]], [[#UnregisterNativeEventCallback ( self, uId )|UnregisterNativeEventCallback]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''kIds''' [IN] The ids of the Windows message callback objects - integer list |
− | <syntaxhighlight lang=" | + | |
− | RLPy. | + | ==== Return ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RWinMessageCallback 1 | ||
+ | class WinMessageCallback1(RLPy.RWinMessageCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RWinMessageCallback.__init__(self) | ||
+ | |||
+ | def OnWinMsgReceieved(self, data): | ||
+ | print("[WinMessageCallback1]window message received") | ||
+ | |||
+ | # Define RWinMessageCallback 2 | ||
+ | class WinMessageCallback2(RLPy.RWinMessageCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RWinMessageCallback.__init__(self) | ||
+ | |||
+ | def OnWinMsgReceieved(self, data): | ||
+ | print("[WinMessageCallback2]window message received2") | ||
+ | |||
+ | # Unregister RIDialog native event callbacks | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | native_event_callback_1 = WinMessageCallback1() | ||
+ | dialog_register_id_1 = rl_dialog.RegisterNativeEventCallBack(native_event_callback_1) | ||
+ | native_event_callback_2 = WinMessageCallback2() | ||
+ | dialog_register_id_2 = rl_dialog.RegisterNativeEventCallBack(native_event_callback_2) | ||
+ | event_handler_list = [] | ||
+ | event_handler_list.append(dialog_register_id_1) | ||
+ | event_handler_list.append(dialog_register_id_2) | ||
+ | result = rl_dialog.UnregisterNativeEventCallbacks(event_handler_list) | ||
+ | print(result) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === RegisterEventCallback ( self, pfCallback ) === | |
− | + | ||
− | ==== | + | |
− | + | ||
− | + | Register a [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] to this dialog and return its id. | |
− | ''' | + | See Also: [[#UnregisterEventCallback ( self, uId )|UnregisterEventCallback]], [[#UnregisterEventCallbacks ( self, kIds )|UnregisterEventCallbacks]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''pfCallback''' [IN] The designated dialog callback event - [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RIDialog. | + | ==== Returns ==== |
+ | :The id of the registered [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] - integer | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | RLPy.RIDialog.UnregisterEventCallbacks( self, kIds ) | ||
+ | # Define RDialogCallback | ||
+ | class DialogEventCallback(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("dialog close") | ||
+ | return True | ||
+ | |||
+ | # Register RIDialog event callback | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | dialog_event_callback = DialogEventCallback() | ||
+ | dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback) | ||
+ | print(dialog_register_id) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === UnregisterEventCallback ( self, uId ) === | |
− | + | ||
− | ==== | + | |
− | + | ||
− | + | Unregister a [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] from this dialog according to its id. | |
− | '''RLPy.RStatus.Failure''' | + | See Also: [[#RegisterEventCallback ( self, pfCallback )|RegisterEventCallback]], [[#UnregisterEventCallbacks ( self, kIds )|UnregisterEventCallbacks]] |
− | </ | + | |
+ | ==== Parameters ==== | ||
+ | :'''uId''' [IN] The dialog callback id for unregistering - integer | ||
+ | |||
+ | ==== Return ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RDialogCallback | ||
+ | class DialogEventCallback(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("dialog close") | ||
+ | return True | ||
+ | |||
+ | # Unregister RIDialog event callback | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | dialog_event_callback = DialogEventCallback() | ||
+ | dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback) | ||
+ | result = rl_dialog.UnregisterEventCallback(dialog_register_id) | ||
+ | print(result) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === UnregisterEventCallbacks ( self, kIds ) === | ||
+ | |||
+ | Unregister a collection of [[IC_Python_API:RLPy_RDialogCallback|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 ( self, pfCallback )|RegisterEventCallback]], [[#UnregisterEventCallback ( self, uId )|UnregisterEventCallback]] | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :'''kIds''' [IN] [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] ids for unregistering - integer list | ||
+ | |||
+ | ==== Return ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RDialogCallback 1 | ||
+ | class DialogEventCallback1(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("[DialogEventCallback1]dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("[DialogEventCallback1]dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("[DialogEventCallback1]dialog close") | ||
+ | return True | ||
+ | |||
+ | # Define RDialogCallback 2 | ||
+ | class DialogEventCallback2(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("[DialogEventCallback2]dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("[DialogEventCallback2]dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("[DialogEventCallback2]dialog close") | ||
+ | return True | ||
+ | |||
+ | # Unregister RIDialog event callbacks | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | dialog_event_callback_1 = DialogEventCallback1() | ||
+ | dialog_register_id_1 = rl_dialog.RegisterEventCallBack(dialog_event_callback_1) | ||
+ | dialog_event_callback_2 = DialogEventCallback2() | ||
+ | dialog_register_id_2 = rl_dialog.RegisterEventCallBack(dialog_event_callback_2) | ||
+ | event_handler_list = [] | ||
+ | event_handler_list.append(dialog_register_id_1) | ||
+ | event_handler_list.append(dialog_register_id_2) | ||
+ | result = rl_dialog.UnregisterEventCallbacks(event_handler_list) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === UnregisterAllEventCallbacks ( self ) === | ||
+ | |||
+ | Unregister all event callbacks from this dialog. | ||
+ | |||
+ | See Also: [[#RegisterEventCallback ( self, pfCallback )|RegisterEventCallback]], [[#UnregisterEventCallback ( self, uId )|UnregisterEventCallback]], [[#UnregisterEventCallbacks ( self, kIds )|UnregisterEventCallbacks]] | ||
+ | |||
+ | ==== Return ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # Define RDialogCallback 1 | ||
+ | class DialogEventCallback1(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("[DialogEventCallback1]dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("[DialogEventCallback1]dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("[DialogEventCallback1]dialog close") | ||
+ | return True | ||
+ | |||
+ | # Define RDialogCallback 2 | ||
+ | class DialogEventCallback2(RLPy.RDialogCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.RDialogCallback.__init__(self) | ||
+ | |||
+ | def OnDialogShow(self): | ||
+ | print("[DialogEventCallback2]dialog show") | ||
+ | |||
+ | def OnDialogHide(self): | ||
+ | print("[DialogEventCallback2]dialog hide") | ||
+ | |||
+ | def OnDialogClose(self): | ||
+ | print("[DialogEventCallback2]dialog close") | ||
+ | return True | ||
+ | |||
+ | # Unregister RIDialog all event callbacks | ||
+ | rl_dialog = RLPy.RUi.CreateRDialog() | ||
+ | rl_dialog.SetWindowTitle("main_dialog") | ||
+ | dialog_event_callback_1 = DialogEventCallback1() | ||
+ | dialog_register_id_1 = rl_dialog.RegisterEventCallBack(dialog_event_callback_1) | ||
+ | dialog_event_callback_2 = DialogEventCallback2() | ||
+ | dialog_register_id_2 = rl_dialog.RegisterEventCallBack(dialog_event_callback_2) | ||
+ | result = rl_dialog.UnregisterAllEventCallbacks() | ||
+ | print(result) | ||
+ | </syntaxhighlight> |
Revision as of 19:51, 12 May 2020
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/12/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
- Return 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
Return
- 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
Return
- 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
Return
- 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
Return
- 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
Return
- 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)