f.write(s)
f.close()
-env.Command('mypaint', 'mypaint.in.py', [burn_python_version, Chmod('$TARGET', 0755)])
+env.Command('mypaint', 'mypaintinit.py', [burn_python_version, Chmod('$TARGET', 0755)])
env.Alias('install', env['prefix'])
def install(dst, pattern):
from lib import brush
class Application: # singleton
- def __init__(self, datapath, confpath, filenames, profile):
+ def __init__(self, datapath, confpath, filenames):
self.confpath = confpath
self.datapath = datapath
#open the first file, no matter how many that has been specified
fn = filenames[0].replace('file:///', '/') # some filebrowsers do this
self.drawWindow.open_file(fn)
- if profile:
- self.drawWindow.start_profiling()
gobject.idle_add(at_application_start)
MYPAINT_VERSION="0.7.0+git"
import os, re, math
-from time import time
from glob import glob
import gtk
self.tdw.visualize_rendering = action.get_active()
def no_double_buffering_cb(self, action):
self.tdw.set_double_buffered(not action.get_active())
-
- def start_profiling(self):
- def autopaint():
- import pylab
- events = pylab.load('painting30sec.dat.gz')
- events[:,0] *= 0.3
- events = list(events)
- t0 = time()
- t_old = 0.0
- for t, x, y, pressure in events:
- sleeptime = t-(time()-t0)
- if sleeptime > 0.001:
- yield sleeptime
- dtime = t - t_old
- t_old = t
- self.doc.stroke_to(dtime, x, y, pressure)
- print 'replay done.'
- print self.repaints, 'repaints'
- gtk.main_quit()
- yield 10.0
-
- import gobject
- p = autopaint()
- def timer_cb():
- gobject.timeout_add(int(p.next()*1000.0), timer_cb)
-
- self.repaints = 0
- oldfunc=self.tdw.repaint
- def count_repaints(*args, **kwargs):
- self.repaints += 1
- return oldfunc(*args, **kwargs)
- self.tdw.repaint = count_repaints
- timer_cb()
-
- self.tdw.rotate(46.0/360*2*math.pi)
def undo_cb(self, action):
self.doc.undo()
from optparse import OptionParser
# main entry, called from the "mypaint" script
-def main(datapath, confpath):
+class Main():
+ def __init__(self, datapath, confpath, standalone=True):
- parser = OptionParser('usage: %prog [options] [FILE]')
- parser.add_option('-c', '--config', metavar='DIR', default=confpath,
- help='use this config directory instead of ~/.mypaint/')
- parser.add_option('-p', '--profile', action='store_true', default = False,
- help='(debug only; simulate some strokes and quit)')
- options, args = parser.parse_args()
+ parser = OptionParser('usage: %prog [options] [FILE]')
+ parser.add_option('-c', '--config', metavar='DIR', default=confpath,
+ help='use this config directory instead of ~/.mypaint/')
+ options, args = parser.parse_args()
- print 'confpath =', options.config
- app = application.Application(datapath, options.config, args, options.profile)
+ print 'confpath =', options.config
+ self.app = application.Application(datapath, options.config, args)
- # Recent gtk versions don't allow changing those menu shortcuts by
- # default. <rant>Sigh. This very useful feature used to be the
- # default behaviour even in the GIMP some time ago. I guess
- # assigning a keyboard shortcut without a complicated dialog
- # clicking marathon must have totally upset the people coming from
- # windows.</rant>
- gtksettings = gtk.settings_get_default()
- gtksettings.set_property('gtk-can-change-accels', True)
+ # Recent gtk versions don't allow changing those menu shortcuts by
+ # default. <rant>Sigh. This very useful feature used to be the
+ # default behaviour even in the GIMP some time ago. I guess
+ # assigning a keyboard shortcut without a complicated dialog
+ # clicking marathon must have totally upset the people coming from
+ # windows.</rant>
+ gtksettings = gtk.settings_get_default()
+ gtksettings.set_property('gtk-can-change-accels', True)
- import gtkexcepthook
- gtk.main()
+ import gtkexcepthook
+ if standalone:
+ gtk.main()
+++ /dev/null
-# This file is part of MyPaint.
-# Copyright (C) 2007-2009 by Martin Renold <martinxyz@gmx.ch>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-"""
-This script does all the platform dependent stuff. Its main task is
-to figure out where the python modules are.
-"""
-
-# This helps on slow PCs where the python overhead dominates.
-# (30% higher framerate measured on 533MHz CPU; startup slowdown below 20%)
-# Note: python -O -O does not help.
-try:
- import psyco
- psyco.full()
-except ImportError:
- pass
-
-import sys, os
-join = os.path.join
-
-lib_shared='share/mypaint/'
-# note: some distros use lib64 instead, they have to edit this...
-lib_compiled='lib/mypaint/'
-
-scriptdir=os.path.dirname(sys.argv[0])
-
-# this script is installed as $prefix/bin. We just need $prefix to continue.
-#pwd=os.getcwd() # why????
-#dir_install=os.path.normpath(join(pwd,scriptdir)) # why????
-dir_install=scriptdir # same, except maybe if scriptdir is relative...
-
-if os.path.basename(dir_install) == 'bin':
- prefix=os.path.dirname(dir_install)
- libpath=join(prefix, lib_shared)
- libpath_compiled = join(prefix, lib_compiled)
- sys.path.insert(0, libpath)
- sys.path.insert(0, libpath_compiled)
-else:
- # we are not installed
- prefix=None
- libpath='.'
- # checking for import error below
-
-try: # just for a nice error message
- from lib import mypaintlib
-except ImportError:
- print
- print "We are not correctly installed or compiled!"
- print 'script: "%s"' % sys.argv[0]
- if prefix:
- print 'deduced prefix: "%s"' % prefix
- print 'lib_shared: "%s"' % libpath
- print 'lib_compiled: "%s"' % libpath_compiled
- print
- raise
-
-datapath = libpath
-if not os.path.isdir(join(datapath, 'brushes')):
- print 'Default brush collection not found! It should have been here:'
- print datapath
- raise sys.exit(1)
-
-homepath = os.path.expanduser('~')
-if homepath == '~':
- confpath = join(prefix, 'UserData')
-else:
- confpath = join(homepath, '.mypaint/')
-
-from gui import main
-main.main(datapath, confpath)
-
--- /dev/null
+# This file is part of MyPaint.
+# Copyright (C) 2007-2009 by Martin Renold <martinxyz@gmx.ch>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+"""
+This script does all the platform dependent stuff. Its main task is
+to figure out where the python modules are.
+"""
+
+def get_paths():
+ import sys, os
+ join = os.path.join
+
+ lib_shared='share/mypaint/'
+ # note: some distros use lib64 instead, they have to edit this...
+ lib_compiled='lib/mypaint/'
+
+ scriptdir=os.path.dirname(sys.argv[0])
+
+ # this script is installed as $prefix/bin. We just need $prefix to continue.
+ #pwd=os.getcwd() # why????
+ #dir_install=os.path.normpath(join(pwd,scriptdir)) # why????
+ dir_install=scriptdir # same, except maybe if scriptdir is relative...
+
+ if os.path.basename(dir_install) == 'bin':
+ prefix=os.path.dirname(dir_install)
+ libpath=join(prefix, lib_shared)
+ libpath_compiled = join(prefix, lib_compiled)
+ sys.path.insert(0, libpath)
+ sys.path.insert(0, libpath_compiled)
+ else:
+ # we are not installed
+ prefix=None
+ libpath='.'
+ # checking for import error below
+
+ try: # just for a nice error message
+ from lib import mypaintlib
+ except ImportError:
+ print
+ print "We are not correctly installed or compiled!"
+ print 'script: "%s"' % sys.argv[0]
+ if prefix:
+ print 'deduced prefix: "%s"' % prefix
+ print 'lib_shared: "%s"' % libpath
+ print 'lib_compiled: "%s"' % libpath_compiled
+ print
+ raise
+
+ datapath = libpath
+ if not os.path.isdir(join(datapath, 'brushes')):
+ print 'Default brush collection not found! It should have been here:'
+ print datapath
+ raise sys.exit(1)
+
+ homepath = os.path.expanduser('~')
+ if homepath == '~':
+ confpath = join(prefix, 'UserData')
+ else:
+ confpath = join(homepath, '.mypaint/')
+
+ return datapath, confpath
+
+def psyco_opt():
+ # This helps on slow PCs where the python overhead dominates.
+ # (30% higher framerate measured on 533MHz CPU; startup slowdown below 20%)
+ # Note: python -O -O does not help.
+ import psyco
+ psyco.full()
+ print 'Psyco being used'
+
+
+if __name__ == '__main__':
+ try:
+ psyco_opt()
+ except ImportError:
+ pass
+ datapath, confpath = get_paths()
+ from gui import main
+ main.Main(datapath, confpath)
--- /dev/null
+
+def renderperf():
+ import gtk
+ from time import time
+ import pylab
+
+ #moved out from gui/drawwindow.py class Window
+ def start_profiling(inst): #where inst = instance of drawwindow.Window
+ def autopaint():
+ events = pylab.load('painting30sec.dat.gz')
+ events[:,0] *= 0.3
+ events = list(events)
+ t0 = time()
+ t_old = 0.0
+ for t, x, y, pressure in events:
+ sleeptime = t-(time()-t0)
+ if sleeptime > 0.001:
+ yield sleeptime
+ dtime = t - t_old
+ t_old = t
+ inst.doc.stroke_to(dtime, x, y, pressure)
+ print 'replay done.'
+ print inst.repaints, 'repaints'
+ gtk.main_quit()
+ yield 10.0
+
+ import gobject
+ p = autopaint()
+ def timer_cb():
+ gobject.timeout_add(int(p.next()*1000.0), timer_cb)
+
+ inst.repaints = 0
+ oldfunc=inst.tdw.repaint
+ def count_repaints(*args, **kwargs):
+ inst.repaints += 1
+ return oldfunc(*args, **kwargs)
+ inst.tdw.repaint = count_repaints
+ timer_cb()
+
+ import math
+ inst.tdw.rotate(46.0/360*2*math.pi)
+
+
+ from gui import main
+ import mypaintinit
+ data, conf = mypaintinit.get_paths()
+ conf = '/tmp/randomdir228283' #fresh config
+ maininst = main.Main(data, conf, standalone = False)
+ start_profiling(maininst.app.drawWindow)
+ gtk.main()
+
+def strokeperf():
+ #from library
+ raise NotImplementedError
+
+def startuptime():
+ #take a similar approach as renderperf() ?
+ raise NotImplementedError
+
+if __name__ == '__main__':
+ renderperf()