Browse code

Fix sample.

Jose Fonseca authored on 01/12/2018 16:59:12
Showing 1 changed files
... ...
@@ -41,7 +41,7 @@ class MyDotWindow(xdot.DotWindow):
41 41
         return True
42 42
 
43 43
 
44
-dotcode = """
44
+dotcode = b"""
45 45
 digraph G {
46 46
   Hello [URL="http://en.wikipedia.org/wiki/Hello"]
47 47
   World [URL="http://en.wikipedia.org/wiki/World"]
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
... ...
@@ -33,9 +33,9 @@ class MyDotWindow(xdot.DotWindow):
33 33
 
34 34
     def on_url_clicked(self, widget, url, event):
35 35
         dialog = Gtk.MessageDialog(
36
-                parent = self, 
37
-                buttons = Gtk.ButtonsType.OK,
38
-                message_format="%s clicked" % url)
36
+            parent=self,
37
+            buttons=Gtk.ButtonsType.OK,
38
+            message_format="%s clicked" % url)
39 39
         dialog.connect('response', lambda dialog, response: dialog.destroy())
40 40
         dialog.run()
41 41
         return True
Browse code

Assert required versions of gi libraries for test script too.

Jose Fonseca authored on 29/04/2016 22:56:09
Showing 1 changed files
... ...
@@ -17,6 +17,9 @@
17 17
 #
18 18
 
19 19
 
20
+import gi
21
+gi.require_version('Gtk', '3.0')
22
+
20 23
 from gi.repository import Gtk
21 24
 
22 25
 import xdot
Browse code

Apply 2to3.

Jose Fonseca authored on 16/10/2015 23:26:44
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/env python3
2 2
 #
3 3
 # Copyright 2008 Jose Fonseca
4 4
 #
Browse code

Port to GTK3.

Timo Vanwynsberghe authored on 03/04/2013 20:57:08 • Jose Fonseca committed on 14/07/2015 21:19:23
Showing 1 changed files
... ...
@@ -17,8 +17,7 @@
17 17
 #
18 18
 
19 19
 
20
-import gtk
21
-import gtk.gdk
20
+from gi.repository import Gtk
22 21
 
23 22
 import xdot
24 23
 
... ...
@@ -27,12 +26,12 @@ class MyDotWindow(xdot.DotWindow):
27 26
 
28 27
     def __init__(self):
29 28
         xdot.DotWindow.__init__(self)
30
-        self.widget.connect('clicked', self.on_url_clicked)
29
+        self.dotwidget.connect('clicked', self.on_url_clicked)
31 30
 
32 31
     def on_url_clicked(self, widget, url, event):
33
-        dialog = gtk.MessageDialog(
32
+        dialog = Gtk.MessageDialog(
34 33
                 parent = self, 
35
-                buttons = gtk.BUTTONS_OK,
34
+                buttons = Gtk.ButtonsType.OK,
36 35
                 message_format="%s clicked" % url)
37 36
         dialog.connect('response', lambda dialog, response: dialog.destroy())
38 37
         dialog.run()
... ...
@@ -51,8 +50,8 @@ digraph G {
51 50
 def main():
52 51
     window = MyDotWindow()
53 52
     window.set_dotcode(dotcode)
54
-    window.connect('destroy', gtk.main_quit)
55
-    gtk.main()
53
+    window.connect('delete-event', Gtk.main_quit)
54
+    Gtk.main()
56 55
 
57 56
 
58 57
 if __name__ == '__main__':
Browse code

Convert tabs to spaces.

Jose.R.Fonseca authored on 13/07/2008 01:24:03
Showing 1 changed files
... ...
@@ -25,35 +25,35 @@ import xdot
25 25
 
26 26
 class MyDotWindow(xdot.DotWindow):
27 27
 
28
-	def __init__(self):
29
-		xdot.DotWindow.__init__(self)
30
-		self.widget.connect('clicked', self.on_url_clicked)
28
+    def __init__(self):
29
+        xdot.DotWindow.__init__(self)
30
+        self.widget.connect('clicked', self.on_url_clicked)
31 31
 
32
-	def on_url_clicked(self, widget, url, event):
33
-		dialog = gtk.MessageDialog(
34
-				parent = self, 
35
-				buttons = gtk.BUTTONS_OK,
36
-				message_format="%s clicked" % url)
37
-		dialog.connect('response', lambda dialog, response: dialog.destroy())
38
-		dialog.run()
39
-		return True
32
+    def on_url_clicked(self, widget, url, event):
33
+        dialog = gtk.MessageDialog(
34
+                parent = self, 
35
+                buttons = gtk.BUTTONS_OK,
36
+                message_format="%s clicked" % url)
37
+        dialog.connect('response', lambda dialog, response: dialog.destroy())
38
+        dialog.run()
39
+        return True
40 40
 
41 41
 
42 42
 dotcode = """
43 43
 digraph G {
44 44
   Hello [URL="http://en.wikipedia.org/wiki/Hello"]
45 45
   World [URL="http://en.wikipedia.org/wiki/World"]
46
-	Hello -> World
46
+    Hello -> World
47 47
 }
48 48
 """
49 49
 
50 50
 
51 51
 def main():
52
-	window = MyDotWindow()
53
-	window.set_dotcode(dotcode)
54
-	window.connect('destroy', gtk.main_quit)
55
-	gtk.main()
52
+    window = MyDotWindow()
53
+    window.set_dotcode(dotcode)
54
+    window.connect('destroy', gtk.main_quit)
55
+    gtk.main()
56 56
 
57 57
 
58 58
 if __name__ == '__main__':
59
-	main()
59
+    main()
Browse code

Add copyright header.

Jose.R.Fonseca authored on 13/07/2008 01:05:47
Showing 1 changed files
... ...
@@ -1,4 +1,20 @@
1 1
 #!/usr/bin/env python
2
+#
3
+# Copyright 2008 Jose Fonseca
4
+#
5
+# This program is free software: you can redistribute it and/or modify it
6
+# under the terms of the GNU Lesser General Public License as published
7
+# by the Free Software Foundation, either version 3 of the License, or
8
+# (at your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful,
11
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+# GNU Lesser General Public License for more details.
14
+#
15
+# You should have received a copy of the GNU Lesser General Public License
16
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+#
2 18
 
3 19
 
4 20
 import gtk
Browse code

Use signals.

Jose.R.Fonseca authored on 03/01/2008 12:39:18
Showing 1 changed files
... ...
@@ -11,11 +11,9 @@ class MyDotWindow(xdot.DotWindow):
11 11
 
12 12
 	def __init__(self):
13 13
 		xdot.DotWindow.__init__(self)
14
+		self.widget.connect('clicked', self.on_url_clicked)
14 15
 
15
-	def get_name(self, name):
16
-		return 'My Dot Window'
17
-
18
-	def on_url_clicked(self, url, event):
16
+	def on_url_clicked(self, widget, url, event):
19 17
 		dialog = gtk.MessageDialog(
20 18
 				parent = self, 
21 19
 				buttons = gtk.BUTTONS_OK,
Browse code

Simple example.

Jose.R.Fonseca authored on 22/12/2007 12:01:04
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,45 @@
1
+#!/usr/bin/env python
2
+
3
+
4
+import gtk
5
+import gtk.gdk
6
+
7
+import xdot
8
+
9
+
10
+class MyDotWindow(xdot.DotWindow):
11
+
12
+	def __init__(self):
13
+		xdot.DotWindow.__init__(self)
14
+
15
+	def get_name(self, name):
16
+		return 'My Dot Window'
17
+
18
+	def on_url_clicked(self, url, event):
19
+		dialog = gtk.MessageDialog(
20
+				parent = self, 
21
+				buttons = gtk.BUTTONS_OK,
22
+				message_format="%s clicked" % url)
23
+		dialog.connect('response', lambda dialog, response: dialog.destroy())
24
+		dialog.run()
25
+		return True
26
+
27
+
28
+dotcode = """
29
+digraph G {
30
+  Hello [URL="http://en.wikipedia.org/wiki/Hello"]
31
+  World [URL="http://en.wikipedia.org/wiki/World"]
32
+	Hello -> World
33
+}
34
+"""
35
+
36
+
37
+def main():
38
+	window = MyDotWindow()
39
+	window.set_dotcode(dotcode)
40
+	window.connect('destroy', gtk.main_quit)
41
+	gtk.main()
42
+
43
+
44
+if __name__ == '__main__':
45
+	main()