GUIbridge Class Reference

Class for providing a bridge between the GUI thread and other threads. More...

List of all members.

Public Member Functions

def __init__
 This is the constructor of the GUIbridge class.
def shutdown
 This method is used to shut the GUI bridge down.
def isGUIthread
 Returns True if this method is being called from the GUI thread.
def createGUI
 Method used for instantiating a GUI from a non-GUI thread.
def execGUImethodNR
 Method used for executing a GUI function from a non-GUI thread.
def execGUImethod
 Method used for executing a GUI function from a non-GUI thread.
def execGUImethod2
def handleCustomEvent

Static Public Attributes

tuple GUI_CMD_INST = QEvent.Type(QEvent.User + 1)
tuple GUI_CMD_FUNC = QEvent.Type(QEvent.User + 2)
tuple GUI_CMD_FUNC_NR = QEvent.Type(QEvent.User + 3)

Private Attributes

 __respQueue


Detailed Description

Class for providing a bridge between the GUI thread and other threads.

This bridge is needed whenever a non-GUI thread needs to interact with the GUI. The GUI is handled by the 'GUI thread'. A 'GUI thread' is defined to be the one in which the Qt QApplication class's exec_loop() method is executed. There can be only one GUI thread in a program.

The solution to the problem is handled by sending a message (an 'event', in Qt terms) from the non-GUI thread to the GUI thread. The message contains information on how it is to be handled. In some cases, this handling produces a result that must be sent back to the initiating non-GUI thread. The requests and responses are passed around via queues. Separate queues are maintained for the different non-GUI threads so that responses don't end up handed off to the wrong thread.

Definition at line 28 of file guiBridges.py.


Member Function Documentation

def __init__   self,
  guiThread
 

This is the constructor of the GUIbridge class.

It must be called from the GUI thread.

Definition at line 34 of file guiBridges.py.

def createGUI   self,
  qObject,
  obj,
  args,
  kwargs
 

Method used for instantiating a GUI from a non-GUI thread.

Parameters:
qObject - The Qt object that will receive the customEvent callback
obj - The GUI object class type to create
args - Arguments for the object class constructor
kwargs - Keyword arguments for the object class constructor
Returns:
An instance of the requested GUI object class

Definition at line 56 of file guiBridges.py.

def execGUImethod   self,
  qObject,
  func,
  args,
  kwargs
 

Method used for executing a GUI function from a non-GUI thread.

Use this method when a response is expected from the function and when it is appropriate to wait for it (no deadlock arises)

Parameters:
qObject - The Qt object that will receive the customEvent callback
func - The GUI function or method to call
args - Arguments for the function or method
kwargs - Keyword arguments for the function or method
Returns:
The called GUI function's return value

Definition at line 95 of file guiBridges.py.

def execGUImethod2   self,
  qObject,
  func,
  args,
  kwargs
 

Definition at line 119 of file guiBridges.py.

def execGUImethodNR   self,
  qObject,
  func,
  args,
  kwargs
 

Method used for executing a GUI function from a non-GUI thread.

Use this method when no (useful) response is expected or when waiting for one could cause a deadlock. Any response from the function is lost.

Parameters:
qObject - The Qt object that will receive the customEvent callback
func - The GUI function or method to call
args - Arguments for the function or method
kwargs - Keyword arguments for the function or method

Definition at line 77 of file guiBridges.py.

def handleCustomEvent   self,
  e
 

Definition at line 135 of file guiBridges.py.

def isGUIthread   self  ) 
 

Returns True if this method is being called from the GUI thread.

Definition at line 51 of file guiBridges.py.

def shutdown   self  ) 
 

This method is used to shut the GUI bridge down.

Definition at line 46 of file guiBridges.py.


Member Data Documentation

__respQueue [private]
 

Definition at line 126 of file guiBridges.py.

tuple GUI_CMD_FUNC = QEvent.Type(QEvent.User + 2) [static]
 

Definition at line 31 of file guiBridges.py.

tuple GUI_CMD_FUNC_NR = QEvent.Type(QEvent.User + 3) [static]
 

Definition at line 32 of file guiBridges.py.

tuple GUI_CMD_INST = QEvent.Type(QEvent.User + 1) [static]
 

Definition at line 30 of file guiBridges.py.


The documentation for this class was generated from the following file:
Generated on Thu Apr 27 20:53:02 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO