jan: thuban/Thuban/Model label.py,1.2,1.2.4.1

cvs@intevation.de cvs at intevation.de
Thu Feb 17 00:21:13 CET 2005


Author: jan

Update of /thubanrepository/thuban/Thuban/Model
In directory doto:/tmp/cvs-serv9036

Modified Files:
      Tag: thuban-1-0-branch
	label.py 
Log Message:
Added import of _.
(Label, Label.__init__): Improved/added doc string.
(LabelLayer, LabelLayer.__init__, LabelLayer.Labels,
LabelLayer.RemoveLabel, LabelLayer.ClearLabels):
Improved/added doc string.
(LabelLayer.AddLabel): Use already defined names for
align strings and improved doc string.
(LabelLayer.TreeInfo): New. Return the object data for
the tree view.


Index: label.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/label.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- label.py	30 Jul 2002 14:15:39 -0000	1.2
+++ label.py	16 Feb 2005 23:21:11 -0000	1.2.4.1
@@ -7,6 +7,8 @@
 
 __version__ = "$Revision$"
 
+from Thuban import _
+
 from messages import CHANGED
 
 from base import TitledObject, Modifiable
@@ -20,7 +22,13 @@
 
 class Label:
 
+    """This class repesents a single label that is
+    defined by its coordinate, the text as well
+    as vertical and horizontal alignment concerning
+    the coordinate."""
+
     def __init__(self, x, y, text, halign, valign):
+        """Initialize the label with the given parameters."""
         self.x = x
         self.y = y
         self.text = text
@@ -30,23 +38,49 @@
 
 class LabelLayer(TitledObject, Modifiable):
 
+    """This represent a layer holding a number of labels."""
+
     def __init__(self, title):
+        """Initialize the LabeleLayer with an empty
+        list of labels and set the title to "title".
+        """
         TitledObject.__init__(self, title)
         Modifiable.__init__(self)
         self.labels = []
 
     def Labels(self):
+        """Return a list of all labels."""
         return self.labels
 
-    def AddLabel(self, x, y, text, halign = "left", valign="center"):
+    def AddLabel(self, x, y, text, halign = ALIGN_LEFT,
+                 valign = ALIGN_CENTER):
+        """Add a label at position (x,y) with contents "text".
+
+        This will emit a CHANGED signal.
+        """
         self.labels.append(Label(x, y, text, halign, valign))
         self.changed(CHANGED)
 
     def RemoveLabel(self, index):
+        """Remove the label specified by index.
+
+        This will emit a CHANGED signal.
+        """
         del self.labels[index]
         self.changed(CHANGED)
 
     def ClearLabels(self):
-        """Remove all labels"""
+        """Remove all labels.
+
+        This will emit a CHANGED signal.
+        """
         del self.labels[:]
         self.changed(CHANGED)
+
+    def TreeInfo(self):
+        """Return a tuple of (title, tupel) describing the contents
+        of the object in a tree-structure.
+        """
+        items = []
+        items.append(_("Number of labels: %d") % len(self.labels))
+        return (_("Label Layer: %s") % self.title, items)





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)