1 import gtk, glib, gobject
2 import traceback, tempfile, os, sys
7 Class for driving the MyPaint GUI.
15 os.system('rm -rf ' + self.tempdir)
18 self.tempdir = tempfile.mkdtemp()
19 from gui import application
20 self.app = application.Application(datapath='..', confpath=self.tempdir, filenames=[])
22 # fatal exceptions, please
23 def excepthook(exctyp, value, tb):
24 traceback.print_exception (exctyp, value, tb, None, sys.stderr)
26 sys.excepthook = excepthook
31 def wait_for_idle(self):
32 "wait until the last mypaint idle handler has finished"
33 if not self.app: self.setup()
35 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_LOW + 50)
40 def wait_for_gui(self):
41 "wait until all GUI updates are done, but don't wait for background tasks"
42 if not self.app: self.setup()
44 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_DEFAULT_IDLE - 1)
49 def wait_for_duration(self, duration):
50 if not self.app: self.setup()
52 gobject.timeout_add(int(duration*1000.0), self.signal_cb)
57 def scroll(self, N=20):
58 tdw = self.app.doc.tdw
59 dx = linspace(-30, 30, N)
60 dy = linspace(-10, 60, N)
62 tdw.scroll(int(dx[i]), int(dy[i]))
64 # jump back to the start
66 tdw.scroll(-int(dx[i]), -int(dy[i]))