Browse code

Minor tweaks in antecipation for Python 3 migration.

Jose Fonseca authored on 16/10/2015 22:14:12
Showing 1 changed files

  • xdot.py index 08300d8..8a218f2 100755
... ...
@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/env python
2 2
 #
3
-# Copyright 2008 Jose Fonseca
3
+# Copyright 2008-2015 Jose Fonseca
4 4
 #
5 5
 # This program is free software: you can redistribute it and/or modify it
6 6
 # under the terms of the GNU Lesser General Public License as published
... ...
@@ -167,7 +167,7 @@ class TextShape(Shape):
167 167
             layout.set_font_description(font)
168 168
 
169 169
             # set text
170
-            layout.set_text(text, len(text))
170
+            layout.set_text(text, -1)
171 171
 
172 172
             # cache it
173 173
             self.layout = layout
... ...
@@ -1197,6 +1197,8 @@ class XDotParser(DotParser):
1197 1197
         self.shapes = []
1198 1198
         self.node_by_name = {}
1199 1199
         self.top_graph = True
1200
+        self.width = 0
1201
+        self.height = 0
1200 1202
 
1201 1203
     def handle_graph(self, attrs):
1202 1204
         if self.top_graph:
... ...
@@ -1618,7 +1620,7 @@ class DotWidget(Gtk.DrawingArea):
1618 1620
     def reload(self):
1619 1621
         if self.openfilename is not None:
1620 1622
             try:
1621
-                fp = file(self.openfilename, 'rt')
1623
+                fp = open(self.openfilename, 'rt')
1622 1624
                 self.set_dotcode(fp.read(), self.openfilename)
1623 1625
                 fp.close()
1624 1626
             except IOError:
... ...
@@ -2065,7 +2067,7 @@ class DotWindow(Gtk.Window):
2065 2067
 
2066 2068
     def open_file(self, filename):
2067 2069
         try:
2068
-            fp = file(filename, 'rt')
2070
+            fp = open(filename, 'rt')
2069 2071
             self.set_dotcode(fp.read(), filename)
2070 2072
             fp.close()
2071 2073
         except IOError as ex: