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

Contents of /trunk/pygtk/canvas/blockinstance.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1968 - (show annotations) (download) (as text)
Mon Dec 1 08:13:10 2008 UTC (13 years, 7 months ago) by jpye
File MIME type: text/x-python
File size: 924 byte(s)
Adding lines to export, but not done yet.
1 from blocktype import *
2
3 blocknameindex = {}
4
5 class BlockInstance:
6 """
7 Instance of a block of a particular type. This block will have
8 associated with it a particular name, and perhaps eventually some
9 specified values of its defined parameters.
10 """
11
12 def __init__(self,blocktype,name=None):
13 self.blocktype = blocktype;
14 n = str(blocktype.type.getName())
15 if not blocknameindex.has_key(n):
16 blocknameindex[n] = 0
17 blocknameindex[n] += 1
18 print "Block index for %s is %d" % (n, blocknameindex[n])
19 if name is None:
20 name = self.get_default_name()
21 self.name = name
22
23 def get_default_name(self):
24 n = str(self.blocktype.type.getName())
25 print blocknameindex
26 print "the name is:",n
27 if not blocknameindex.has_key(n):
28 print "the key '%s' is not in blocknameindex" % n
29
30 return "%s%s" % (n, blocknameindex[n])
31
32 def __str__(self):
33 return "\t%s IS_A %s;\n" % (self.name, self.blocktype.type.getName())
34

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