Ticket #2795: abiword_export_test.py

File abiword_export_test.py, 1.2 KB (added by humitos, 12 years ago)

Exportation test with all the supported types by Write

Line 
1import pygtk
2pygtk.require('2.0')
3import gtk
4from abiword import Canvas
5
6
7class 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
36if __name__ == "__main__":
37    base = Base()
38    base.main()