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 os.system('cp -a brushes ' + self.tempdir)
21 self.app = application.Application(datapath=u'..', confpath=unicode(self.tempdir), filenames=[])
23 # fatal exceptions, please
24 def excepthook(exctyp, value, tb):
25 traceback.print_exception (exctyp, value, tb, None, sys.stderr)
27 sys.excepthook = excepthook
32 def wait_for_idle(self):
33 "wait until the last mypaint idle handler has finished"
34 if not self.app: self.setup()
36 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_LOW + 50)
41 def wait_for_gui(self):
42 "wait until all GUI updates are done, but don't wait for background tasks"
43 if not self.app: self.setup()
45 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_DEFAULT_IDLE - 1)
50 def wait_for_duration(self, duration):
51 if not self.app: self.setup()
53 gobject.timeout_add(int(duration*1000.0), self.signal_cb)
58 def scroll(self, N=20):
59 tdw = self.app.doc.tdw
60 dx = linspace(-30, 30, N)
61 dy = linspace(-10, 60, N)
63 tdw.scroll(int(dx[i]), int(dy[i]))
65 # jump back to the start
67 tdw.scroll(-int(dx[i]), -int(dy[i]))