Module pywraps :: Class GraphViewer
[frames] | no frames]

Class GraphViewer

This class wraps the user graphing facility provided by the graph.hpp file

Instance Methods
 
__init__(self, title, close_open=False)
Constructs the GraphView object.
 
AddNode(self, obj)
Creates a node associated with the given object and returns the node id
 
AddEdge(self, src_node, dest_node)
Creates an edge between two given node ids
 
Clear(self)
Clears all the nodes and edges
 
__getitem__(self, idx)
Returns a reference to the object associated with this node id
 
Count(self)
Returns the node count
 
Close(self)
Closes the graph.
 
Refresh(self)
Refreshes the graph.
 
Show(self)
Shows an existing graph or creates a new one
 
Select(self, node_id)
Selects a node on the graph
 
AddCommand(self, title, hotkey)
Adds a menu command to the graph.
 
OnRefresh(self)
Event called when the graph is refreshed or first created.
 
OnGetText(self, node_id)
Triggered when the graph viewer wants the text and color for a given node.
 
OnActivate(self)
Triggered when the graph window gets the focus
 
OnDeactivate(self)
Triggered when the graph window loses the focus
 
OnSelect(self, node_id)
Triggered when a node is being selected
 
OnHint(self, node_id)
Triggered when the graph viewer wants to retrieve hint text associated with a given node
 
OnClose(self)
Triggered when the graph viewer window is being closed
 
OnClick(self, node_id)
Triggered when a node is clicked
 
OnDblClick(self, node_id)
Triggerd when a node is double-clicked.
 
OnCommand(self, cmd_id)
Triggered when a menu command is selected through the menu or its hotkey
Method Details

__init__(self, title, close_open=False)
(Constructor)

 

Constructs the GraphView object. Please do not remove or rename the private fields

Parameters:
  • title - The title of the graph window
  • close_open - Should it attempt to close an existing graph (with same title) before creating this graph?

Close(self)

 

Closes the graph. It is possible to call Show() again (which will recreate the graph)

Refresh(self)

 

Refreshes the graph. This causes the OnRefresh() to be called

Show(self)

 

Shows an existing graph or creates a new one

Returns:
Boolean

AddCommand(self, title, hotkey)

 

Adds a menu command to the graph. Call this command after the graph is shown (with Show()). Once a command is added, a command id is returned. The commands are handled inside the OnCommand() handler

Returns:
0 on failure or the command id

OnRefresh(self)

 

Event called when the graph is refreshed or first created. From this event you are supposed to create nodes and edges. This callback is mandatory.

Returns:
Returning True tells the graph viewer to use the items. Otherwise old items will be used.

Note: ***It is important to clear previous nodes before adding nodes.***

OnGetText(self, node_id)

 

Triggered when the graph viewer wants the text and color for a given node. This callback is triggered one time for a given node (the value will be cached and used later without calling Python). When you call refresh then again this callback will be called for each node.

This callback is mandatory.

Returns:
Return a string to describe the node text or return a tuple (node_text, node_color) to describe both text and color

OnActivate(self)

 

Triggered when the graph window gets the focus

Returns:
None

OnDeactivate(self)

 

Triggered when the graph window loses the focus

Returns:
None

OnSelect(self, node_id)

 

Triggered when a node is being selected

Returns:
Return True to allow the node to be selected or False to disallow node selection change

OnHint(self, node_id)

 

Triggered when the graph viewer wants to retrieve hint text associated with a given node

Returns:
None if no hint is avail or a string designating the hint

OnClose(self)

 

Triggered when the graph viewer window is being closed

Returns:
None

OnClick(self, node_id)

 

Triggered when a node is clicked

Returns:
False to ignore the click and True otherwise

OnDblClick(self, node_id)

 

Triggerd when a node is double-clicked.

Returns:
False to ignore the click and True otherwise

OnCommand(self, cmd_id)

 

Triggered when a menu command is selected through the menu or its hotkey

Returns:
None