Difference between revisions of "IC Python API:RLPy RIDialog"

From Reallusion Wiki!
Jump to: navigation, search
(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...")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
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. <syntaxhighlight lang="Python">
+
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):
+
== Description ==
   print("dialog close")
+
 
   return True
+
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.
+
 
rl_dialog = RLPy.RUi.CreateRDialog()
+
== Member Functions ==
rl_dialog.SetWindowTitle("main_dialog")
+
 
print(rl_dialog.GetWindowTitle()) # main_dialog
+
=== GetWindow ( self ) ===
+
 
# register dialog event
+
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.
dialog_event_callback = DialogEventCallback()
+
 
dialog_register_id = rl_dialog.RegisterEventCallBack(dialog_event_callback)
+
==== Returns ====
+
:This dialog's QWidget address - QWidget address
# use id to unregister
+
 
rl_dialog.UnregisterEventCallback(dialog_register_id)
+
<syntaxhighlight lang="python" line='line'>
+
# Create RIDialog and add widget to the dialog
rl_dialog.Show()
+
main_dlg_url = QUrl("...ui path")
rl_dialog.IsVisble() # True
+
main_dlg_view = PySide2.QtQuickWidgets.QQuickWidget()
rl_dialog.Hide()
+
main_dlg_view.setSource(main_dlg_url)
rl_dialog.IsVisble() # False
+
 
 +
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>
==Member Functions==
+
 
===GetDialogType===
+
=== GetTitle ( self ) ===
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.GetDialogType ( 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
 +
 
 +
<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>
Return current dialog type.
+
 
====Returns====
+
=== GetWindowTitle ( self ) ===
<div style="margin-left: 2em;">Dialog type - RLPy.EDialogType
+
 
*'''RLPy.EDialogType_Normal'''
+
Get the title-bar label text for this dialog.
*'''RLPy.EDialogType_Exclusive'''
+
 
</div>
+
See Also: [[#SetWindowTitle ( self, strTitleName )|SetWindowTitle]]
-----
+
 
===GetTitle===
+
==== Returns ====
<syntaxhighlight lang="Python">
+
:This dialog's titlebar label text - string
RLPy.RIDialog.GetTitle ( self )
+
 
 +
<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>
Get title bar widget's address.
+
 
====Returns====
+
=== SetWindowTitle ( self, strTitleName ) ===
<div style="margin-left: 2em;">Address of the title bar widget - QWidget
+
 
</div>
+
Set the title-bar label text for this dialog.
-----
+
 
===GetWindow===
+
See Also: [[#GetWindowTitle ( self )|GetWindowTitle]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.GetWindow ( self )
+
==== 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>
Get dialog's itself address.
+
 
====Returns====
+
=== SetParent ( self, pWidget ) ===
<div style="margin-left: 2em;">A pointer to the dialog - QWidget
+
 
</div>
+
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.
-----
+
 
===GetWindowTitle===
+
==== Parameters ====
<syntaxhighlight lang="Python">
+
:'''pWidget''' [IN] parent widget的window address
RLPy.RIDialog.GetWindowTitle ( self )
+
 
 +
<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>
Get title bar Name.
+
 
====Returns====
+
=== Show ( self ) ===
<div style="margin-left: 2em;">Title bar name - string
+
 
</div>
+
Display this dialog (make it visible).
-----
+
 
===IsModal===
+
See Also: [[#Hide ( self )|Hide]], [[#Close ( self )|Close]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.IsModal ( self )
+
<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>
Return if dialog is modal or modeless.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''True''' if dialog is modal
+
=== Hide ( self ) ===
  
'''False''' if dialog is modeless
+
Hide this dialog but keep it in system memory.
</div>
+
 
-----
+
See Also: [[#Show ( self )|Show]], [[#Close ( self )|Close]]
===RegisterEventCallback===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RIDialog.RegisterEventCallback ( self, pfCallback )
+
# Hide RIDialog
 +
main_rl_dlg = RLPy.RUi.CreateRDialog()
 +
main_rl_dlg.SetWindowTitle("Main Dialog")
 +
main_rl_dlg.Show()
 +
main_rl_dlg.Hide()
 
</syntaxhighlight>
 
</syntaxhighlight>
Dialog event callback.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pfCallback''' [IN] dialog event callback pointer - RLPy.RDialogCallback
+
=== Close ( self ) ===
</div>
+
 
====Returns====
+
Close this dialog window and release it from memory.
<div style="margin-left: 2em;">Dialog Event callBack id - int
+
 
</div>
+
See Also: [[#Show ( self )|Show]], [[#Hide ( self )|Hide]]
-----
+
 
===RegisterNativeEventCallback===
+
<syntaxhighlight lang="python" line='line'>
<syntaxhighlight lang="Python">
+
# Close RIDialog
RLPy.RIDialog.RegisterNativeEventCallback ( self, pfCallback )
+
main_rl_dlg = RLPy.RUi.CreateRDialog()
 +
main_rl_dlg.SetWindowTitle("Main Dialog")
 +
main_rl_dlg.Show()
 +
main_rl_dlg.Close()
 
</syntaxhighlight>
 
</syntaxhighlight>
Windows event callback.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pfCallback''' [IN] Window message callback pointer - RLPy.RWinMessageCallback
+
=== IsVisible ( self ) ===
</div>
+
 
====Returns====
+
Check whether if this dialog is visible or not.
<div style="margin-left: 2em;">Windows Event callBack id - int
+
 
</div>
+
See Also: [[#Show ( self )|Show]], [[#Hide ( self )|Hide]], [[#Close ( self )|Close]]
-----
+
 
===SetModal===
+
==== Returns ====
<syntaxhighlight lang="Python">
+
:This dialog's visibility - boolean
RLPy.RIDialog.SetModal ( self, bModal )
+
 
 +
<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>
Set dialog modal or modeless.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''bModal''' [IN] True is modal or False is modeless - bool
+
=== SetModal ( self, bModal ) ===
</div>
+
 
-----
+
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.
===SetParent===
+
 
<syntaxhighlight lang="Python">
+
See Also: [[#IsModal ( self )|IsModal]]
RLPy.RIDialog.SetParent ( self, pWidget )
+
 
 +
==== 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>
Set the parent of the dialog.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pWidget''' [IN] Widget pointer - QWidget
+
=== IsModal ( self ) ===
</div>
+
 
-----
+
Check whether if this dialog is a modal window.
===SetWindowTitle===
+
 
<syntaxhighlight lang="Python">
+
See Also: [[#SetModal ( self, bModal )|SetModal]]
RLPy.RIDialog.SetWindowTitle ( self, strTitleName )
+
 
 +
==== 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>
Set dialog title name.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''strTitleName''' [IN] title name - string
+
=== GetDialogType ( self ) ===
</div>
+
 
-----
+
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.
===UnregisterAllEventCallbacks===
+
 
<syntaxhighlight lang="Python">
+
==== Returns ====
RLPy.RIDialog.UnregisterAllEventCallbacks ( self )
+
: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>
Unregister all dialog event callback.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''RLPy.RStatus.Success''' Success
+
=== RegisterNativeEventCallback ( self, pfCallback ) ===
  
'''RLPy.RStatus.Failure''' Fail
+
Register a [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] event with this dialog and return its id.
</div>
+
 
-----
+
See Also: [[#UnregisterNativeEventCallback ( self, uId )|UnregisterNativeEventCallback]], [[#UnregisterNativeEventCallbacks ( self, kIds )|UnregisterNativeEventCallbacks]]
===UnregisterEventCallback===
+
 
<syntaxhighlight lang="Python">
+
==== Parameters ====
RLPy.RIDialog.UnregisterEventCallback ( self, uId )
+
:'''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>
Unregister dialog event callback with Id.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''uId''' [IN] callback id - int
+
=== UnregisterNativeEventCallback ( self, uId ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Unregister [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] event from this dialog.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#RegisterNativeEventCallback ( self, pfCallback )|RegisterNativeEventCallback]], [[#UnregisterNativeEventCallbacks ( self, kIds )|UnregisterNativeEventCallbacks]]
</div>
+
 
-----
+
==== Parameters ====
===UnregisterEventCallbacks===
+
:'''uId''' [IN] [[IC_Python_API:RLPy_RWinMessageCallback|RWinMessageCallback]] ids for unreggistering - integer
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.UnregisterEventCallbacks ( self, kIds )
+
==== 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>
Unregister dialog event callback with Ids.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kIds''' [IN] callback ids - int
+
=== UnregisterNativeEventCallbacks ( self, kIds ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
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.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#RegisterNativeEventCallback ( self, pfCallback )|RegisterNativeEventCallback]], [[#UnregisterNativeEventCallback ( self, uId )|UnregisterNativeEventCallback]]
</div>
+
 
-----
+
==== Parameters ====
===UnregisterNativeEventCallback===
+
:'''kIds''' [IN] The ids of the Windows message callback objects - integer list
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.UnregisterNativeEventCallback ( self, uId )
+
==== 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>
Unregister windows event callback with Id.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''uId''' [IN] callback id - int
+
=== RegisterEventCallback ( self, pfCallback ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Register a [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] to this dialog and return its id.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#UnregisterEventCallback ( self, uId )|UnregisterEventCallback]], [[#UnregisterEventCallbacks ( self, kIds )|UnregisterEventCallbacks]]
</div>
+
 
-----
+
==== Parameters ====
===UnregisterNativeEventCallbacks===
+
:'''pfCallback''' [IN] The designated dialog callback event - [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIDialog.UnregisterNativeEventCallbacks ( self, kIds )
+
==== 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>
Unregister windows event callback with Ids.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kIds''' [IN] callback ids - int
+
=== UnregisterEventCallback ( self, uId ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Unregister a [[IC_Python_API:RLPy_RDialogCallback|RDialogCallback]] from this dialog according to its id.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#RegisterEventCallback ( self, pfCallback )|RegisterEventCallback]], [[#UnregisterEventCallbacks ( self, kIds )|UnregisterEventCallbacks]]
</div>
+
 
 +
==== 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 20:51, 12 May 2020

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).

See Also: Hide, Close

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.

See Also: Show, Close

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.

See Also: Show, Hide

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.

See Also: Show, Hide, Close

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)