... | ... |
@@ -146,44 +146,7 @@ If no input file is given then it will read the dot graph from the standard inpu |
146 | 146 |
Embedding |
147 | 147 |
--------- |
148 | 148 |
|
149 |
- #!/usr/bin/env python |
|
150 |
- |
|
151 |
- import gtk |
|
152 |
- import gtk.gdk |
|
153 |
- |
|
154 |
- import xdot |
|
155 |
- |
|
156 |
- class MyDotWindow(xdot.DotWindow): |
|
157 |
- |
|
158 |
- def __init__(self): |
|
159 |
- xdot.DotWindow.__init__(self) |
|
160 |
- self.widget.connect('clicked', self.on_url_clicked) |
|
161 |
- |
|
162 |
- def on_url_clicked(self, widget, url, event): |
|
163 |
- dialog = gtk.MessageDialog( |
|
164 |
- parent = self, |
|
165 |
- buttons = gtk.BUTTONS_OK, |
|
166 |
- message_format="%s clicked" % url) |
|
167 |
- dialog.connect('response', lambda dialog, response: dialog.destroy()) |
|
168 |
- dialog.run() |
|
169 |
- return True |
|
170 |
- |
|
171 |
- dotcode = """ |
|
172 |
- digraph G { |
|
173 |
- Hello [URL="http://en.wikipedia.org/wiki/Hello"] |
|
174 |
- World [URL="http://en.wikipedia.org/wiki/World"] |
|
175 |
- Hello -> World |
|
176 |
- } |
|
177 |
- """ |
|
178 |
- |
|
179 |
- def main(): |
|
180 |
- window = MyDotWindow() |
|
181 |
- window.set_dotcode(dotcode) |
|
182 |
- window.connect('destroy', gtk.main_quit) |
|
183 |
- gtk.main() |
|
184 |
- |
|
185 |
- if __name__ == '__main__': |
|
186 |
- main() |
|
149 |
+See included `example.py` script for an example of how to embedded xdot.py into another application. |
|
187 | 150 |
|
188 | 151 |
[](http://wiki.jrfonseca.googlecode.com/git/xdot-sample.png) |
189 | 152 |
|