Browse code

Make internal imports more explicit

Peter Hill authored on 02/07/2016 10:30:50 • Jose Fonseca committed on 10/07/2016 08:40:15
Showing 1 changed files
... ...
@@ -13,18 +13,19 @@
13 13
 # You should have received a copy of the GNU Lesser General Public License
14 14
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 15
 #
16
-BOLD = 1
17
-ITALIC = 2
18
-UNDERLINE = 4
19
-SUPERSCRIPT = 8
20
-SUBSCRIPT = 16
21
-STRIKE_THROUGH = 32
22
-OVERLINE = 64
23 16
 
24 17
 
25 18
 class Pen:
26 19
     """Store pen attributes."""
27 20
 
21
+    BOLD = 1
22
+    ITALIC = 2
23
+    UNDERLINE = 4
24
+    SUPERSCRIPT = 8
25
+    SUBSCRIPT = 16
26
+    STRIKE_THROUGH = 32
27
+    OVERLINE = 64
28
+
28 29
     def __init__(self):
29 30
         # set default attributes
30 31
         self.color = (0.0, 0.0, 0.0, 1.0)
Browse code

Fix most flake8 errors

Peter Hill authored on 02/07/2016 10:27:27 • Jose Fonseca committed on 10/07/2016 08:40:15
Showing 1 changed files
... ...
@@ -21,6 +21,7 @@ SUBSCRIPT = 16
21 21
 STRIKE_THROUGH = 32
22 22
 OVERLINE = 64
23 23
 
24
+
24 25
 class Pen:
25 26
     """Store pen attributes."""
26 27
 
Browse code

Cleaner splitting into separate modules

Peter Hill authored on 02/07/2016 09:45:05 • Jose Fonseca committed on 10/07/2016 08:40:15
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,54 @@
1
+# Copyright 2008-2015 Jose Fonseca
2
+#
3
+# This program is free software: you can redistribute it and/or modify it
4
+# under the terms of the GNU Lesser General Public License as published
5
+# by the Free Software Foundation, either version 3 of the License, or
6
+# (at your option) any later version.
7
+#
8
+# This program is distributed in the hope that it will be useful,
9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
+# GNU Lesser General Public License for more details.
12
+#
13
+# You should have received a copy of the GNU Lesser General Public License
14
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
+#
16
+BOLD = 1
17
+ITALIC = 2
18
+UNDERLINE = 4
19
+SUPERSCRIPT = 8
20
+SUBSCRIPT = 16
21
+STRIKE_THROUGH = 32
22
+OVERLINE = 64
23
+
24
+class Pen:
25
+    """Store pen attributes."""
26
+
27
+    def __init__(self):
28
+        # set default attributes
29
+        self.color = (0.0, 0.0, 0.0, 1.0)
30
+        self.fillcolor = (0.0, 0.0, 0.0, 1.0)
31
+        self.linewidth = 1.0
32
+        self.fontsize = 14.0
33
+        self.fontname = "Times-Roman"
34
+        self.bold = False
35
+        self.italic = False
36
+        self.underline = False
37
+        self.superscript = False
38
+        self.subscript = False
39
+        self.strikethrough = False
40
+        self.overline = False
41
+
42
+        self.dash = ()
43
+
44
+    def copy(self):
45
+        """Create a copy of this pen."""
46
+        pen = Pen()
47
+        pen.__dict__ = self.__dict__.copy()
48
+        return pen
49
+
50
+    def highlighted(self):
51
+        pen = self.copy()
52
+        pen.color = (1, 0, 0, 1)
53
+        pen.fillcolor = (1, .8, .8, 1)
54
+        return pen