/[ascend]/trunk/pygtk/canvas/blockconnecttool.py
ViewVC logotype

Annotation of /trunk/pygtk/canvas/blockconnecttool.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1979 - (hide annotations) (download) (as text)
Sat Jan 10 00:21:37 2009 UTC (13 years, 7 months ago) by jpye
File MIME type: text/x-python
File size: 948 byte(s)
Basic MODEL export functionality now in place for canvas.
Still needs lots of cleaning up though.

1 jpye 1979
2     from gaphas.tool import ConnectHandleTool
3    
4     class BlockConnectTool(ConnectHandleTool):
5     """
6     This class makes the necessary changes to the application-layer data
7     when a handle is connected to a port, or disconnected.
8    
9     The `ConnectorTool` will also be making use of this class.
10     """
11     def post_connect(self, line, handle, item, port):
12     assert(line.lineinstance is not None)
13     assert(port.portinstance is not None)
14    
15     if handle is line._handles[0]:
16     line.lineinstance.fromport = port.portinstance
17     elif handle is line._handles[-1]:
18     line.lineinstance.toport = port.portinstance
19     else:
20     raise RuntimeError("Invalid handle, neither start nor end")
21    
22     def disconnect(self, view, line, handle):
23     super(BlockConnectTool,self).disconnect(view, line, handle)
24     assert(line.lineinstance is not None)
25     if handle is line._handles[0]:
26     line.lineinstance.fromport = None
27     elif handle is line._handles[-1]:
28     line.lineinstance.toport = None
29    
30    

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22