1 | import pygtk |
---|
2 | pygtk.require('2.0') |
---|
3 | import gtk |
---|
4 | from abiword import Canvas |
---|
5 | |
---|
6 | |
---|
7 | class Base: |
---|
8 | def __init__(self): |
---|
9 | self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) |
---|
10 | self.vbox = gtk.VBox() |
---|
11 | self.abiword_canvas = Canvas() |
---|
12 | self.button = gtk.Button("Save") |
---|
13 | self.vbox.add(self.abiword_canvas) |
---|
14 | self.vbox.add(self.button) |
---|
15 | self.window.add(self.vbox) |
---|
16 | |
---|
17 | self.window.show_all() |
---|
18 | |
---|
19 | self.button.connect('clicked', self._button_clicked_cb) |
---|
20 | self.window.connect('destroy', gtk.main_quit) |
---|
21 | |
---|
22 | def _button_clicked_cb(self, *args, **kwargs): |
---|
23 | self.abiword_canvas.save('file:///tmp/abiword_test.pdf', |
---|
24 | 'application/pdf', '') |
---|
25 | self.abiword_canvas.save('file:///tmp/abiword_test.rtf', |
---|
26 | 'application/rtf', '') |
---|
27 | self.abiword_canvas.save('file:///tmp/abiword_test.html', |
---|
28 | 'text/html', 'html4:yes; declare-xml:no; ' |
---|
29 | 'embed-css:yes; embed-images:yes;') |
---|
30 | self.abiword_canvas.save('file:///tmp/abiword_test.txt', |
---|
31 | 'text/plain', '') |
---|
32 | |
---|
33 | def main(self): |
---|
34 | gtk.main() |
---|
35 | |
---|
36 | if __name__ == "__main__": |
---|
37 | base = Base() |
---|
38 | base.main() |
---|