... | ... |
@@ -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 |
... | ... |
@@ -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__': |
... | ... |
@@ -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() |
... | ... |
@@ -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 |
... | ... |
@@ -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, |
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() |