1 import gtk, glib, gobject
2 import traceback, tempfile, os, sys
7 Class for driving the MyPaint GUI.
12 sys.argv_unicode = sys.argv # FileHandler.save_file passes this to gtk.recent_manager
16 os.system('rm -rf ' + self.tempdir)
19 self.tempdir = tempfile.mkdtemp()
20 from gui import application
21 os.system('cp -a brushes ' + self.tempdir)
22 self.app = application.Application(datapath=u'..',
23 extradata='../desktop',
24 confpath=unicode(self.tempdir),
27 # ignore mouse movements during testing (creating extra strokes)
28 def motion_ignore_cb(*junk1, **junk2):
30 self.app.doc.tdw.motion_notify_cb = motion_ignore_cb
32 # fatal exceptions, please
33 def excepthook(exctyp, value, tb):
34 traceback.print_exception (exctyp, value, tb, None, sys.stderr)
36 sys.excepthook = excepthook
41 def wait_for_idle(self):
42 "wait until the last mypaint idle handler has finished"
43 if not self.app: self.setup()
45 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_LOW + 50)
50 def wait_for_gui(self):
51 "wait until all GUI updates are done, but don't wait for background tasks"
52 if not self.app: self.setup()
54 gobject.idle_add(self.signal_cb, priority=gobject.PRIORITY_DEFAULT_IDLE - 1)
59 def wait_for_duration(self, duration):
60 if not self.app: self.setup()
62 gobject.timeout_add(int(duration*1000.0), self.signal_cb)
67 def scroll(self, N=20):
68 tdw = self.app.doc.tdw
69 dx = linspace(-30, 30, N)
70 dy = linspace(-10, 60, N)
72 tdw.scroll(int(dx[i]), int(dy[i]))
74 # jump back to the start
76 tdw.scroll(-int(dx[i]), -int(dy[i]))