1   
 2  import sys, os 
 3  scripterng_path = os.path.dirname(os.path.abspath(__file__)) 
 4  sys.path.insert(0, scripterng_path) 
 5  print >> sys.stderr, "%s added to PYTHONPATH" % scripterng_path 
 6   
 7   
 8  try: 
 9      from PyQt4.QtCore import PYQT_VERSION_STR,  QObject,  QCoreApplication 
10      from PyQt4.QtGui import qApp,  QMenu 
11  except ImportError: 
12      print >> sys.stderr, "Python cannot find the Qt4 bindings." 
13      print >> sys.stderr, "Please make sure, that the needed packages are installed." 
14      print >> sys.stderr, "On Ubuntu and Debian(-like) distribubutions you have to install python-qt4" 
15      raise 
16  try: 
17      from PyQt4 import QtScript 
18  except ImportError, e: 
19      print >> sys.stderr, "You seem to have Qt4 bindings without QtScript support." 
20      print >> sys.stderr, "This is currently a requirement." 
21      print >> sys.stderr, "Please make sure you have also libqt4-script installed." 
22      raise 
23   
24   
25  import excepthook 
26  excepthook.install() 
27   
28   
29   
30  if float(PYQT_VERSION_STR[:3]) < 4.4: 
31      print >> sys.stderr, "Your installed PyQt4 is older than version 4.4" 
32      print >> sys.stderr, "A newer version is needed. Please upgrade your packages." 
33      raise ImportError, "PyQt4 not new enough" 
34   
35   
36  from scripterng_hooks import MenuHooks 
37  from mikro import create_pyqt_object, Error as MiKroError 
38   
39   
40   
41  import __builtin__ 
42  __builtin__.ScripterNG = create_pyqt_object(qApp).ScripterNG 
43  ScripterNG.qt.setParent(None) 
44   
45  __builtin__.app = ScripterNG  
46  __builtin__.i18n = lambda s: unicode(QCoreApplication.translate("ScripterNG", s)) 
47  ScripterNG.Error = MiKroError 
48  ScripterNG.path = scripterng_path 
49   
50   
51   
53      """ 
54      ScripterNG menu item in mainWindow menubar 
55      """ 
56   
63   
64   
66          for path in [scripterng_path, os.path.expanduser("~/.scribus/scripterng/")]: 
67              autoload_path = os.path.join(path, "autoload") 
68              if not os.path.exists(autoload_path): 
69                  continue 
70              sys.path.insert(0, autoload_path) 
71              from scribusscript import load_scripts 
72              self.autoload_scripts = scripts = load_scripts(autoload_path) 
73              for sd in scripts: 
74                  try: 
75                      sd.install() 
76                  except: 
77                      excepthook.show_current_error(i18n("Error installing %r") % sd.name) 
 78   
79   
82   
83   
 86           
87   
90   
91  ScripterNG.connect("createMenu(QMainWindow*)", createMenu) 
92