예제 #1
0
def check_for_qt4():
    try:
        from PyQt4 import pyqtconfig
    except ImportError:
        print_status("Qt4", "no")
        return False
    else:
        print_status(
            "Qt4", "Qt: %s, PyQt4: %s" %
            (convert_qt_version(pyqtconfig.Configuration().qt_version),
             pyqtconfig.Configuration().pyqt_version_str))
        return True
예제 #2
0
파일: sip.py 프로젝트: hsoft/pluginbuilder
    def config(self):
        if self.packages is not None:
            return self.packages

        import sipconfig, os

        from PyQt4 import pyqtconfig
        cfg = pyqtconfig.Configuration()
        qtdir = cfg.qt_lib_dir
        if not os.path.exists(qtdir):
            # half-broken installation? ignore.
            raise ImportError()

        # Qt is GHETTO!
        dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')

        if qtdir not in dyld_library_path:
            dyld_library_path.insert(0, qtdir)
            os.environ['DYLD_LIBRARY_PATH'] = ':'.join(dyld_library_path)

        sipdir = cfg.default_sip_dir
        self.packages = set([
            fn for fn in os.listdir(sipdir)
            if os.path.isdir(os.path.join(sipdir, fn))
        ])

        self.warn = cfg.qt_edition == 'free'
        return self.packages
예제 #3
0
def doit():
    global opt_static
    global opt_debug
    # The name of the SIP build file generated by SIP and used by the build
    # system.
    build_file = "qvarianttest.sbf"

    # Get the PyQt configuration information.
    config = pyqtconfig.Configuration()
    config.pyqt_modules = ['QtCore']

    cmd = " ".join([
        config.sip_bin, "-c", "sipQVariantTest", "-b",
        "sipQVariantTest/" + build_file, "-I", config.pyqt_sip_dir,
        config.pyqt_sip_flags, "qvarianttest.sip"
    ])
    ret = os.system(cmd)

    if ret:
        sys.exit(ret % 255)

    makefile = QVariantTestModuleMakefile(configuration=config,
                                          build_file=build_file,
                                          static=opt_static,
                                          debug=opt_debug,
                                          dir="sipQVariantTest")

    sipconfig.ParentMakefile(configuration=config,
                             subdirs=["sipQVariantTest"]).generate()

    # Generate the Makefile itself.
    makefile.generate()
예제 #4
0
def generate(env):
    """Add Builders and construction variables for SIP to an Environment."""

    c_file, cxx_file = SCons.Tool.createCFileBuilders(env)

    cxx_file.suffix[".sip"] = sipSuffixEmitter

    cxx_file.add_action(".sip", SipAction)
    cxx_file.add_emitter(".sip", _sipEmitter)
    flags = []
    try:
        from PyQt4 import pyqtconfig

        config = pyqtconfig.Configuration()
        flags = config.pyqt_sip_flags.split() + ["-I" + config.pyqt_sip_dir]
    except ImportError:
        import sipconfig

        config = sipconfig.Configuration()

    env["SIP"] = config.sip_bin
    env["SIPFLAGS"] = flags
    env[
        "SIPCOM"
    ] = '$SIP $SIPFLAGS -s ${TARGET.suffix} -c ${SIPOUTPUTDIR and SIPOUTPUTDIR or "."} -c ${TARGET.dir} $SOURCES'
    env["SIPCOMSTR"] = "$SIPCOM"
    env["BUILDERS"]["Sip"] = cxx_file
예제 #5
0
	def compile_ui(self, ui_file):
		pyqt_configuration = pyqtconfig.Configuration()
		pyuic_exe = find_executable('pyuic4', pyqt_configuration.default_bin_dir)
		if not pyuic_exe:
			# Search on the $Path.
			pyuic_exe = find_executable('pyuic4')
		cmd = [pyuic_exe, ui_file, '-o']
		cmd.append(py_file_name(ui_file))
		os.system(' '.join(cmd))
예제 #6
0
    def compileUI(self, ui_file):
        pyqt_configuration = pyqtconfig.Configuration()
        pyuic_exe = find_executable('pyuic4', pyqt_configuration.default_bin_dir)
        if not pyuic_exe:
            pyuic_exe = find_executable('pyuic4')

        cmd = [pyuic_exe, ui_file, '-o']
        cmd.append(py_file_name(ui_file))
        cmd.append("-g \"yali\"")
        os.system(' '.join(cmd))
예제 #7
0
    def pyqtconfig(self):
        if not hasattr(self, '_pyqtconfig'):
            try:
                from PyQt4 import pyqtconfig

                self._pyqtconfig = pyqtconfig.Configuration()
            except ImportError:
                self._pyqtconfig = None

        return self._pyqtconfig
예제 #8
0
    def config(self):
        if self.packages is not None:
            print("packages", self.packages)
            return self.packages

        import sipconfig, os

        try:
            from PyQt4 import pyqtconfig

            cfg = pyqtconfig.Configuration()
            qtdir = cfg.qt_lib_dir
            sipdir = os.path.dirname(cfg.pyqt_mod_dir)
            self.plugin_dir = os.path.join(cfg.qt_dir, 'plugins')
        except ImportError:
            from PyQt5.QtCore import QLibraryInfo

            qtdir = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
            self.plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
            sipdir = os.path.dirname(sipconfig.__file__)

        if not os.path.exists(qtdir):
            print("sip: Qtdir %r does not exist"%(qtdir))
            # half-broken installation? ignore.
            raise ImportError

        # Qt is GHETTO!
        dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')

        if qtdir not in dyld_library_path:
            dyld_library_path.insert(0, qtdir)
            os.environ['DYLD_LIBRARY_PATH'] = ':'.join(dyld_library_path)

        self.packages = set()

        for fn in os.listdir(sipdir):
            fullpath = os.path.join(sipdir, fn)
            if os.path.isdir(fullpath):
                self.packages.add(fn)
                if fn in ('PyQt4', 'PyQt5'):
                    # PyQt4 and later has a nested structure, also import
                    # subpackage to ensure everything get seen.
                    for sub in os.listdir(fullpath):
                        if ".py" not in sub:
                            self.packages.add('%s.%s'%(fn, sub.replace(".so","")))

        # Causes a python3-related syntax error (metaclass keyword),
        # and you probably don't need it:
        #if "PyQt4.uic" in self.packages and sys.version_info.major != 3:
        #    print("WARNING: PyQt uic module found.")
        #    print("avoid python3 metaclass syntax errors by adding 'PyQt4.uic' to your excludes option.")
        print("sip: packages: %s"%(self.packages,))

        return self.packages
예제 #9
0
파일: sip.py 프로젝트: mrclary/py2app
    def config(self):
        if self.packages is not None:
            print("packages", self.packages)
            return self.packages

        import os

        import sipconfig

        try:
            from PyQt4 import pyqtconfig

            cfg = pyqtconfig.Configuration()
            qtdir = cfg.qt_lib_dir
            sipdir = os.path.dirname(cfg.pyqt_mod_dir)
            self.plugin_dir = os.path.join(cfg.qt_dir, "plugins")
        except ImportError:
            from PyQt5.QtCore import QLibraryInfo

            qtdir = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
            self.plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
            sipdir = os.path.dirname(sipconfig.__file__)

        if not os.path.exists(qtdir):
            print("sip: Qtdir %r does not exist" % (qtdir))
            # half-broken installation? ignore.
            raise ImportError

        # Qt is GHETTO!
        # This looks wrong, setting DYLD_LIBRARY_PATH should not be needed!
        dyld_library_path = os.environ.get("DYLD_LIBRARY_PATH", "").split(":")

        if qtdir not in dyld_library_path:
            dyld_library_path.insert(0, qtdir)
            os.environ["DYLD_LIBRARY_PATH"] = ":".join(dyld_library_path)

        self.packages = set()

        for fn in os.listdir(sipdir):
            fullpath = os.path.join(sipdir, fn)
            if os.path.isdir(fullpath):
                self.packages.add(fn)
                if fn in ("PyQt4", "PyQt5"):
                    # PyQt4 and later has a nested structure, also import
                    # subpackage to ensure everything get seen.
                    for sub in os.listdir(fullpath):
                        if ".py" not in sub:
                            self.packages.add("{}.{}".format(
                                fn, sub.replace(".so", "")))

        print(f"sip: packages: {self.packages}")

        return self.packages
예제 #10
0
    def config(self):
        if self.packages is not None:
            print("packages", self.packages)
            return self.packages

        import sipconfig
        import os

        try:
            from PyQt4 import pyqtconfig

            cfg = pyqtconfig.Configuration()
            qtdir = cfg.qt_lib_dir
            sipdir = os.path.dirname(cfg.pyqt_mod_dir)
            self.plugin_dir = os.path.join(cfg.qt_dir, 'plugins')
        except ImportError:
            from PyQt5.QtCore import QLibraryInfo

            qtdir = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
            self.plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
            sipdir = os.path.dirname(sipconfig.__file__)

        if not os.path.exists(qtdir):
            print("sip: Qtdir %r does not exist" % (qtdir))
            # half-broken installation? ignore.
            raise ImportError

        # Qt is GHETTO!
        dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')

        if qtdir not in dyld_library_path:
            dyld_library_path.insert(0, qtdir)
            os.environ['DYLD_LIBRARY_PATH'] = ':'.join(dyld_library_path)

        self.packages = set()

        for fn in os.listdir(sipdir):
            fullpath = os.path.join(sipdir, fn)
            if os.path.isdir(fullpath):
                self.packages.add(fn)
                if fn in ('PyQt4', 'PyQt5'):
                    # PyQt4 and later has a nested structure, also import
                    # subpackage to ensure everything get seen.
                    for sub in os.listdir(fullpath):
                        if ".py" not in sub:
                            self.packages.add('%s.%s' %
                                              (fn, sub.replace(".so", "")))

        print("sip: packages: %s" % (self.packages, ))

        return self.packages
예제 #11
0
    def config(self):
        if self.packages is not None:
            return self.packages

        import sipconfig, os
        try:
            set
        except NameError:
            from sets import Set as set

        ##old version for PyQt/Qt 3
        # cfg = sipconfig.Configuration()
        # qtdir = cfg.qt_lib_dir

        ##new version for PyQt 4
        from PyQt4 import pyqtconfig
        cfg = pyqtconfig.Configuration()
        qtdir = cfg.qt_lib_dir
        if not os.path.exists(qtdir):
            # half-broken installation? ignore.
            raise ImportError

        # Qt is GHETTO!
        dyld_library_path = os.environ.get('DYLD_LIBRARY_PATH', '').split(':')

        if qtdir not in dyld_library_path:
            dyld_library_path.insert(0, qtdir)
            os.environ['DYLD_LIBRARY_PATH'] = ':'.join(dyld_library_path)

        sipdir = os.path.dirname(cfg.pyqt_mod_dir)
        self.packages = set()
        self.plugin_dir = os.path.join(cfg.qt_dir, 'plugins')

        for fn in os.listdir(sipdir):
            fullpath = os.path.join(sipdir, fn)
            if os.path.isdir(fullpath):
                self.packages.add(fn)
                if fn == 'PyQt4':
                    # PyQt4 has a nested structure, also import
                    # subpackage to ensure everything get seen.
                    for sub in os.listdir(fullpath):
                        if ".py" not in sub:
                            self.packages.add('%s.%s'%(fn, sub.replace(".so","")))                            

        # Causes a python3-related syntax error (metaclass keyword),
        # and you probably don't need it:
        #if "PyQt4.uic" in self.packages and sys.version_info.major != 3:
        #    print("WARNING: PyQt uic module found.")
        #    print("avoid python3 metaclass syntax errors by adding 'PyQt4.uic' to your excludes option.")

        return self.packages
예제 #12
0
    def compile_ui(self, ui_file):
        pyqt_configuration = pyqtconfig.Configuration()
        pyuic_exe = find_executable('pyuic4',
                                    pyqt_configuration.default_bin_dir)
        if not pyuic_exe:
            # Search on the $Path.
            pyuic_exe = find_executable('pyuic4')
        if not pyuic_exe:
            return

        cmd = [pyuic_exe, ui_file, '-o']
        print cmd
        cmd.append(py_file_name(ui_file))
        spawn(cmd)
예제 #13
0
def get_pyqt4_configuration():
    required = 'At least PyQt-4.1 and its development tools are required.'
    try:
        import PyQt4.pyqtconfig as pyqtconfig
    except ImportError:
        raise Die, required
    if 0x040100 > pyqtconfig._pkg_config['pyqt_version']:
        raise Die, required
    try:
        configuration = pyqtconfig.Configuration()
    except AttributeError:
        raise Die, (
            'Check if SIP and PyQt or PyQt4 have been installed properly.')
    return configuration
예제 #14
0
    def initialize_sip_extension(self):
        if pyqtconfig_qt4 is None:
            raise RuntimeError("PyQt4 dev is not installed. Can't build " \
                               "pixmaptools extension")
        # Get the PyQt configuration information.
        config = pyqtconfig_qt4.Configuration()
        qt_sip_flags = config.pyqt_sip_flags

        #Local include
        include_dirs = [os.path.dirname(os.path.realpath(__file__))]
        #Extra include for numpy
        include_dirs += [numpy.get_include()]
        #Extra include for pyqt
        include_dirs += [config.qt_inc_dir]
        include_dirs += [
            os.path.join(config.qt_inc_dir, x) for x in ['QtCore', 'QtGui']
        ]
        include_dirs.append(base_path)

        extra_compile_args = pyqtconfig_qt4._default_macros['CXXFLAGS'].split()
        extra_compile_args += pyqtconfig_qt4._default_macros[
            'CXXFLAGS_THREAD'].split()
        extra_compile_args += pyqtconfig_qt4._default_macros[
            'CXXFLAGS_WARN_ON'].split()

        extra_link_args = pyqtconfig_qt4._default_macros['LFLAGS'].split()

        library_dirs = pyqtconfig_qt4._default_macros['LIBDIR_QT'].split()
        extra_libs = ['QtCore', 'QtGui']
        sources = [
            'pixmaptools_io.cpp', 'pixmaptools_lut.cpp', 'pixmaptools_stat.cpp'
        ]
        if major == 4 and minor < 12:
            sources.append('pixmaptools_before_4_12.sip')
        else:
            sources.append('pixmaptools.sip')
        ext = Extension(
            "bliss.data.routines.pixmaptools.qt4",
            sources=[os.path.join(base_path, x) for x in sources],
            include_dirs=include_dirs,
            extra_compile_args=extra_compile_args,
            extra_link_args=extra_link_args,
            library_dirs=library_dirs,
            libraries=extra_libs,
            language='c++',
        )

        sip_flags = ' '.join(('-I', config.pyqt_sip_dir, qt_sip_flags))
        return ext, sip_flags
예제 #15
0
파일: setup.py 프로젝트: xiaomailong/szarp
	def __init__( self , dist ) :
		build.__init__(self,dist)

		# Search for pyuic4 in python bin dir, then in the $Path.
		try:
			from PyQt4 import pyqtconfig
		except ImportError:
			pyuic_exe = None
		else:
			pyqt_configuration = pyqtconfig.Configuration()
			pyuic_exe = find_executable('pyuic4', pyqt_configuration.default_bin_dir)
		if not pyuic_exe: pyuic_exe = find_executable('pyuic4')
		if not pyuic_exe: pyuic_exe = find_executable('pyuic4.bat')
		if not pyuic_exe: print "Unable to find pyuic4 executable"; return

		self.pyuic_exe = pyuic_exe
예제 #16
0
    def __init__(self):
        QtGui.QDialog.__init__(self)

        self.ui = Ui_prefDialog()
        self.ui.setupUi(self)

        settings = QtCore.QSettings('vcs', 'qct')

        self.signoff = settings.value('signoff', QtCore.QVariant('')).toString()

        settings.beginGroup('fileList')
        self.showIgnored = settings.value('showIgnored', QtCore.QVariant(False)).toBool()
        self.wrapList = settings.value('wrapping', QtCore.QVariant(False)).toBool()
        settings.endGroup()
        
        settings.beginGroup('tools')
        self.diffTool = settings.value('diffTool', QtCore.QVariant('')).toString()
        self.histTool = settings.value('histTool', QtCore.QVariant('')).toString()
        self.editTool = settings.value('editTool', QtCore.QVariant('')).toString()
        self.twowayTool = settings.value('twowayTool', QtCore.QVariant('')).toString()
        settings.endGroup()

        # Disable wrap feature for Qt < 4.2
        try:
            from PyQt4 import pyqtconfig
        except ImportError:
            # The Windows installed PyQt4 does not support pyqtconfig, but
            # does support wrapping, etc.  So we will leave this feature
            # enabled if we fail to import pyqtconfig.
            # self.ui.wrapListCheckBox.setEnabled(False)
            pass
        else:
            pyqtconfig = pyqtconfig.Configuration()
            if pyqtconfig.qt_version < 0x40200:
                self.wrapList = False
                self.ui.wrapListCheckBox.setEnabled(False)
                self.ui.wrapListCheckBox.setToolTip(QtGui.QApplication.translate("wrapListCheckBox",
                    "This feature requires Qt >= 4.2", None, QtGui.QApplication.UnicodeUTF8))

        self.ui.ignoredButton.setChecked(self.showIgnored)
        self.ui.wrapListCheckBox.setChecked(self.wrapList)
        self.ui.diffToolEdit.setText(self.diffTool)
        self.ui.histToolEdit.setText(self.histTool)
        self.ui.mergeToolEdit.setText(self.twowayTool)
        self.ui.editToolEdit.setText(self.editTool)
        self.ui.signoffTextEdit.setPlainText(self.signoff)
예제 #17
0
    def __init__(self, qmakePath):
        self.__qmakePath = qmakePath

        qtVersion = self.qmakeVariable('QT_VERSION')
        self.__hasQt4 = qtVersion.startswith('4.')
        self.__hasQt5 = qtVersion.startswith('5.')

        if self.__hasQt5:
            from PyQt5.QtCore import PYQT_CONFIGURATION
            self.__sipFlags = PYQT_CONFIGURATION['sip_flags']
        elif self.__hasQt4:
            try:
                from PyQt4.QtCore import PYQT_CONFIGURATION
                self.__sipFlags = PYQT_CONFIGURATION['sip_flags']
            except ImportError:
                from PyQt4 import pyqtconfig
                config = pyqtconfig.Configuration()
                self.__sipFlags = config.pyqt_sip_flags
        else:
            raise Exception('Qt version 4 or 5 is required!')
예제 #18
0
def main(argv):
    """Create the configuration module module.

    argv is the list of command line arguments.
    """
    global pyqt

    # Check SIP is new enough.
    if "preview" not in pyqt.sip_version_str and "snapshot" not in pyqt.sip_version_str:
        if pyqt.sip_version < sip_min_version:
            sipconfig.error("This version of QScintilla requires SIP v%s or later" % sipconfig.version_to_string(sip_min_version))

    # Parse the command line.
    global opts

    p = create_optparser()
    opts, args = p.parse_args()

    if args:
        p.print_help()
        sys.exit(2)

    # Provide defaults for platform-specific options.
    if sys.platform == 'win32':
        opts.prot_is_public = False

    if opts.not_dll:
        global qsci_define
        qsci_define = ""

    # Set the version of PyQt explicitly.
    global qt_data_dir

    if opts.pyqt_major == 4:
        if pyqt4 is None:
            sipconfig.error("PyQt v4 was specified with the -p argument but doesn't seem to be installed.")
        else:
            pyqt = pyqt4.Configuration()
            qt_data_dir = pyqt.qt_data_dir
    elif opts.pyqt_major == 3:
        if pyqt3 is None:
            sipconfig.error("PyQt v3 was specified with the -p argument but doesn't seem to be installed.")
        else:
            pyqt = pyqt3.Configuration()
            qt_data_dir = pyqt.qt_dir
    elif opts.pyqt_major >= 0:
        sipconfig.error("Specify either 3 or 4 with the -p argument.")

    # Now we know which version of PyQt to use we can set defaults for those
    # arguments that weren't specified.
    if opts.qscimoddir is None:
        opts.qscimoddir = pyqt.pyqt_mod_dir

    if opts.qsciincdir is None:
        opts.qsciincdir = pyqt.qt_inc_dir

    if opts.qscilibdir is None:
        opts.qscilibdir = pyqt.qt_lib_dir

    if opts.qscisipdir is None:
        opts.qscisipdir = pyqt.pyqt_sip_dir

    if opts.qscidir is None:
        opts.qscidir = os.path.join(qt_data_dir, "qsci")

    # Check for QScintilla.
    check_qscintilla()

    # Tell the user what's been found.
    inform_user()

    # Generate the code.
    generate_code()
예제 #19
0
except ImportError:
    sys.stderr.write("Unable to import sipconfig.  Please make sure SIP is installed.\n")
    sys.exit(1)

try:
    import PyQt4.pyqtconfig as pyqt4
except:
    pyqt4 = None

try:
    import pyqtconfig as pyqt3
except:
    pyqt3 = None

if pyqt4 is not None:
    pyqt = pyqt4.Configuration()
    qt_data_dir = pyqt.qt_data_dir
elif pyqt3 is not None:
    pyqt = pyqt3.Configuration()
    qt_data_dir = pyqt.qt_dir
else:
    sipconfig.error("Unable to find either PyQt v3 or v4.")


# This must be kept in sync with Python/configure.py, qscintilla.pro,
# example-Qt4Qt5/application.pro and designer-Qt4Qt5/designer.pro.
QSCI_API_MAJOR = 12


# Initialise the globals.
sip_min_version = 0x040c00
예제 #20
0
파일: setup.py 프로젝트: cjh1/uvcdat
    from distutils import sysconfig

    vcs_so = '%s/vcs/_vcs.so' % sysconfig.get_python_lib()
    vcs_inc = '%s/vcs/Include' % sysconfig.get_python_lib()

    ## vcs_so = '/Users/hvo/src/uvcdat/cdatBuild/lib/python2.7/site-packages/vcs/_vcs.so'
    ## vcs_inc = '/Users/hvo/src/uvcdat/cdat/Packages/vcs/Include'

    print "so is at:",vcs_so,vcs_inc
    # The name of the SIP build file generated by SIP and used by the build
    # system.
    build_file = "pyqtscripting.sbf"

    # Get the PyQt configuration information.
    config = pyqtconfig.Configuration()

    # Get the extra SIP flags needed by the imported qt module.  Note that
    # this normally only includes those flags (-x and -t) that relate to SIP's
    # versioning system.
    qt_sip_flags = config.pyqt_sip_flags

    os.system("rm -rf cdatwrap")
    os.mkdir("cdatwrap")
    os.system("touch cdatwrap/__init__.py")

    # Run SIP to generate the code.  Note that we tell SIP where to find the qt
    # module's specification files using the -I flag.
    os.system(" ".join([ \
        config.sip_bin, \
        "-c", "cdatwrap", \
예제 #21
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setWindowTitle(
            QCoreApplication.translate("PythonConsole", "Python Console"))

        self.settings = QSettings()

        self.options = optionsDialog(self)

        self.shell = ShellScintilla(self)
        self.setFocusProxy(self.shell)
        self.shellOut = ShellOutputScintilla(self)
        self.tabEditorWidget = EditorTabWidget(self)

        ##------------ UI -------------------------------

        self.splitterEditor = QSplitter(self)
        self.splitterEditor.setOrientation(Qt.Horizontal)
        self.splitterEditor.setHandleWidth(6)
        self.splitterEditor.setChildrenCollapsible(True)
        self.splitter = QSplitter(self.splitterEditor)
        self.splitter.setOrientation(Qt.Vertical)
        self.splitter.setHandleWidth(3)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.addWidget(self.shellOut)
        self.splitter.addWidget(self.shell)
        #self.splitterEditor.addWidget(self.tabEditorWidget)

        self.splitterObj = QSplitter(self.splitterEditor)
        self.splitterObj.setHandleWidth(3)
        self.splitterObj.setOrientation(Qt.Horizontal)
        #self.splitterObj.setSizes([0, 0])
        #self.splitterObj.setStretchFactor(0, 1)

        self.widgetEditor = QWidget(self.splitterObj)
        self.widgetFind = QWidget(self)

        self.listClassMethod = QTreeWidget(self.splitterObj)
        self.listClassMethod.setColumnCount(2)
        objInspLabel = QCoreApplication.translate("PythonConsole",
                                                  "Object Inspector")
        self.listClassMethod.setHeaderLabels([objInspLabel, ''])
        self.listClassMethod.setColumnHidden(1, True)
        self.listClassMethod.setAlternatingRowColors(True)

        #self.splitterEditor.addWidget(self.widgetEditor)
        #self.splitterObj.addWidget(self.listClassMethod)
        #self.splitterObj.addWidget(self.widgetEditor)

        # Hide side editor on start up
        self.splitterObj.hide()
        self.listClassMethod.hide()
        # Hide search widget on start up
        self.widgetFind.hide()

        sizes = self.splitter.sizes()
        self.splitter.setSizes(sizes)

        ##----------------Restore Settings------------------------------------

        self.restoreSettingsConsole()

        ##------------------Toolbar Editor-------------------------------------

        ## Action for Open File
        openFileBt = QCoreApplication.translate("PythonConsole", "Open file")
        self.openFileButton = QAction(self)
        self.openFileButton.setCheckable(False)
        self.openFileButton.setEnabled(True)
        self.openFileButton.setIcon(
            QgsApplication.getThemeIcon("console/iconOpenConsole.png"))
        self.openFileButton.setMenuRole(QAction.PreferencesRole)
        self.openFileButton.setIconVisibleInMenu(True)
        self.openFileButton.setToolTip(openFileBt)
        self.openFileButton.setText(openFileBt)
        ## Action for Save File
        saveFileBt = QCoreApplication.translate("PythonConsole", "Save")
        self.saveFileButton = QAction(self)
        self.saveFileButton.setCheckable(False)
        self.saveFileButton.setEnabled(False)
        self.saveFileButton.setIcon(
            QgsApplication.getThemeIcon("console/iconSaveConsole.png"))
        self.saveFileButton.setMenuRole(QAction.PreferencesRole)
        self.saveFileButton.setIconVisibleInMenu(True)
        self.saveFileButton.setToolTip(saveFileBt)
        self.saveFileButton.setText(saveFileBt)
        ## Action for Save File As
        saveAsFileBt = QCoreApplication.translate("PythonConsole",
                                                  "Save As...")
        self.saveAsFileButton = QAction(self)
        self.saveAsFileButton.setCheckable(False)
        self.saveAsFileButton.setEnabled(True)
        self.saveAsFileButton.setIcon(
            QgsApplication.getThemeIcon("console/iconSaveAsConsole.png"))
        self.saveAsFileButton.setMenuRole(QAction.PreferencesRole)
        self.saveAsFileButton.setIconVisibleInMenu(True)
        self.saveAsFileButton.setToolTip(saveAsFileBt)
        self.saveAsFileButton.setText(saveAsFileBt)
        ## Action Cut
        cutEditorBt = QCoreApplication.translate("PythonConsole", "Cut")
        self.cutEditorButton = QAction(self)
        self.cutEditorButton.setCheckable(False)
        self.cutEditorButton.setEnabled(True)
        self.cutEditorButton.setIcon(
            QgsApplication.getThemeIcon("console/iconCutEditorConsole.png"))
        self.cutEditorButton.setMenuRole(QAction.PreferencesRole)
        self.cutEditorButton.setIconVisibleInMenu(True)
        self.cutEditorButton.setToolTip(cutEditorBt)
        self.cutEditorButton.setText(cutEditorBt)
        ## Action Copy
        copyEditorBt = QCoreApplication.translate("PythonConsole", "Copy")
        self.copyEditorButton = QAction(self)
        self.copyEditorButton.setCheckable(False)
        self.copyEditorButton.setEnabled(True)
        self.copyEditorButton.setIcon(
            QgsApplication.getThemeIcon("console/iconCopyEditorConsole.png"))
        self.copyEditorButton.setMenuRole(QAction.PreferencesRole)
        self.copyEditorButton.setIconVisibleInMenu(True)
        self.copyEditorButton.setToolTip(copyEditorBt)
        self.copyEditorButton.setText(copyEditorBt)
        ## Action Paste
        pasteEditorBt = QCoreApplication.translate("PythonConsole", "Paste")
        self.pasteEditorButton = QAction(self)
        self.pasteEditorButton.setCheckable(False)
        self.pasteEditorButton.setEnabled(True)
        self.pasteEditorButton.setIcon(
            QgsApplication.getThemeIcon("console/iconPasteEditorConsole.png"))
        self.pasteEditorButton.setMenuRole(QAction.PreferencesRole)
        self.pasteEditorButton.setIconVisibleInMenu(True)
        self.pasteEditorButton.setToolTip(pasteEditorBt)
        self.pasteEditorButton.setText(pasteEditorBt)
        ## Action Run Script (subprocess)
        runScriptEditorBt = QCoreApplication.translate("PythonConsole",
                                                       "Run script")
        self.runScriptEditorButton = QAction(self)
        self.runScriptEditorButton.setCheckable(False)
        self.runScriptEditorButton.setEnabled(True)
        self.runScriptEditorButton.setIcon(
            QgsApplication.getThemeIcon("console/iconRunScriptConsole.png"))
        self.runScriptEditorButton.setMenuRole(QAction.PreferencesRole)
        self.runScriptEditorButton.setIconVisibleInMenu(True)
        self.runScriptEditorButton.setToolTip(runScriptEditorBt)
        self.runScriptEditorButton.setText(runScriptEditorBt)
        ## Action Run Script (subprocess)
        commentEditorBt = QCoreApplication.translate("PythonConsole",
                                                     "Comment")
        self.commentEditorButton = QAction(self)
        self.commentEditorButton.setCheckable(False)
        self.commentEditorButton.setEnabled(True)
        self.commentEditorButton.setIcon(
            QgsApplication.getThemeIcon(
                "console/iconCommentEditorConsole.png"))
        self.commentEditorButton.setMenuRole(QAction.PreferencesRole)
        self.commentEditorButton.setIconVisibleInMenu(True)
        self.commentEditorButton.setToolTip(commentEditorBt)
        self.commentEditorButton.setText(commentEditorBt)
        ## Action Run Script (subprocess)
        uncommentEditorBt = QCoreApplication.translate("PythonConsole",
                                                       "Uncomment")
        self.uncommentEditorButton = QAction(self)
        self.uncommentEditorButton.setCheckable(False)
        self.uncommentEditorButton.setEnabled(True)
        self.uncommentEditorButton.setIcon(
            QgsApplication.getThemeIcon(
                "console/iconUncommentEditorConsole.png"))
        self.uncommentEditorButton.setMenuRole(QAction.PreferencesRole)
        self.uncommentEditorButton.setIconVisibleInMenu(True)
        self.uncommentEditorButton.setToolTip(uncommentEditorBt)
        self.uncommentEditorButton.setText(uncommentEditorBt)
        ## Action for Object browser
        objList = QCoreApplication.translate("PythonConsole",
                                             "Object Inspector")
        self.objectListButton = QAction(self)
        self.objectListButton.setCheckable(True)
        self.objectListButton.setEnabled(
            self.settings.value("pythonConsole/enableObjectInsp",
                                False).toBool())
        self.objectListButton.setIcon(
            QgsApplication.getThemeIcon("console/iconClassBrowserConsole.png"))
        self.objectListButton.setMenuRole(QAction.PreferencesRole)
        self.objectListButton.setIconVisibleInMenu(True)
        self.objectListButton.setToolTip(objList)
        self.objectListButton.setText(objList)
        ## Action for Find text
        findText = QCoreApplication.translate("PythonConsole", "Find Text")
        self.findTextButton = QAction(self)
        self.findTextButton.setCheckable(True)
        self.findTextButton.setEnabled(True)
        self.findTextButton.setIcon(
            QgsApplication.getThemeIcon("console/iconSearchEditorConsole.png"))
        self.findTextButton.setMenuRole(QAction.PreferencesRole)
        self.findTextButton.setIconVisibleInMenu(True)
        self.findTextButton.setToolTip(findText)
        self.findTextButton.setText(findText)

        ##----------------Toolbar Console-------------------------------------

        ## Action Show Editor
        showEditor = QCoreApplication.translate("PythonConsole", "Show editor")
        self.showEditorButton = QAction(self)
        self.showEditorButton.setEnabled(True)
        self.showEditorButton.setCheckable(True)
        self.showEditorButton.setIcon(
            QgsApplication.getThemeIcon("console/iconShowEditorConsole.png"))
        self.showEditorButton.setMenuRole(QAction.PreferencesRole)
        self.showEditorButton.setIconVisibleInMenu(True)
        self.showEditorButton.setToolTip(showEditor)
        self.showEditorButton.setText(showEditor)
        ## Action for Clear button
        clearBt = QCoreApplication.translate("PythonConsole", "Clear console")
        self.clearButton = QAction(self)
        self.clearButton.setCheckable(False)
        self.clearButton.setEnabled(True)
        self.clearButton.setIcon(
            QgsApplication.getThemeIcon("console/iconClearConsole.png"))
        self.clearButton.setMenuRole(QAction.PreferencesRole)
        self.clearButton.setIconVisibleInMenu(True)
        self.clearButton.setToolTip(clearBt)
        self.clearButton.setText(clearBt)
        ## Action for settings
        optionsBt = QCoreApplication.translate("PythonConsole", "Settings")
        self.optionsButton = QAction(self)
        self.optionsButton.setCheckable(False)
        self.optionsButton.setEnabled(True)
        self.optionsButton.setIcon(
            QgsApplication.getThemeIcon("console/iconSettingsConsole.png"))
        self.optionsButton.setMenuRole(QAction.PreferencesRole)
        self.optionsButton.setIconVisibleInMenu(True)
        self.optionsButton.setToolTip(optionsBt)
        self.optionsButton.setText(optionsBt)
        ## Action menu for class
        actionClassBt = QCoreApplication.translate("PythonConsole",
                                                   "Import Class")
        self.actionClass = QAction(self)
        self.actionClass.setCheckable(False)
        self.actionClass.setEnabled(True)
        self.actionClass.setIcon(
            QgsApplication.getThemeIcon("console/iconClassConsole.png"))
        self.actionClass.setMenuRole(QAction.PreferencesRole)
        self.actionClass.setIconVisibleInMenu(True)
        self.actionClass.setToolTip(actionClassBt)
        self.actionClass.setText(actionClassBt)
        ## Import Sextante class
        loadSextanteBt = QCoreApplication.translate("PythonConsole",
                                                    "Import Sextante class")
        self.loadSextanteButton = QAction(self)
        self.loadSextanteButton.setCheckable(False)
        self.loadSextanteButton.setEnabled(True)
        self.loadSextanteButton.setIcon(
            QgsApplication.getThemeIcon("console/iconSextanteConsole.png"))
        self.loadSextanteButton.setMenuRole(QAction.PreferencesRole)
        self.loadSextanteButton.setIconVisibleInMenu(True)
        self.loadSextanteButton.setToolTip(loadSextanteBt)
        self.loadSextanteButton.setText(loadSextanteBt)
        ## Import QtCore class
        loadQtCoreBt = QCoreApplication.translate("PythonConsole",
                                                  "Import PyQt.QtCore class")
        self.loadQtCoreButton = QAction(self)
        self.loadQtCoreButton.setCheckable(False)
        self.loadQtCoreButton.setEnabled(True)
        self.loadQtCoreButton.setIcon(
            QgsApplication.getThemeIcon("console/iconQtCoreConsole.png"))
        self.loadQtCoreButton.setMenuRole(QAction.PreferencesRole)
        self.loadQtCoreButton.setIconVisibleInMenu(True)
        self.loadQtCoreButton.setToolTip(loadQtCoreBt)
        self.loadQtCoreButton.setText(loadQtCoreBt)
        ## Import QtGui class
        loadQtGuiBt = QCoreApplication.translate("PythonConsole",
                                                 "Import PyQt.QtGui class")
        self.loadQtGuiButton = QAction(self)
        self.loadQtGuiButton.setCheckable(False)
        self.loadQtGuiButton.setEnabled(True)
        self.loadQtGuiButton.setIcon(
            QgsApplication.getThemeIcon("console/iconQtGuiConsole.png"))
        self.loadQtGuiButton.setMenuRole(QAction.PreferencesRole)
        self.loadQtGuiButton.setIconVisibleInMenu(True)
        self.loadQtGuiButton.setToolTip(loadQtGuiBt)
        self.loadQtGuiButton.setText(loadQtGuiBt)
        ## Action for Run script
        runBt = QCoreApplication.translate("PythonConsole", "Run command")
        self.runButton = QAction(self)
        self.runButton.setCheckable(False)
        self.runButton.setEnabled(True)
        self.runButton.setIcon(
            QgsApplication.getThemeIcon("console/iconRunConsole.png"))
        self.runButton.setMenuRole(QAction.PreferencesRole)
        self.runButton.setIconVisibleInMenu(True)
        self.runButton.setToolTip(runBt)
        self.runButton.setText(runBt)
        ## Help action
        helpBt = QCoreApplication.translate("PythonConsole", "Help")
        self.helpButton = QAction(self)
        self.helpButton.setCheckable(False)
        self.helpButton.setEnabled(True)
        self.helpButton.setIcon(
            QgsApplication.getThemeIcon("console/iconHelpConsole.png"))
        self.helpButton.setMenuRole(QAction.PreferencesRole)
        self.helpButton.setIconVisibleInMenu(True)
        self.helpButton.setToolTip(helpBt)
        self.helpButton.setText(helpBt)

        self.toolBar = QToolBar()
        self.toolBar.setEnabled(True)
        self.toolBar.setFocusPolicy(Qt.NoFocus)
        self.toolBar.setContextMenuPolicy(Qt.DefaultContextMenu)
        self.toolBar.setLayoutDirection(Qt.LeftToRight)
        self.toolBar.setIconSize(QSize(24, 24))
        self.toolBar.setOrientation(Qt.Vertical)
        self.toolBar.setMovable(True)
        self.toolBar.setFloatable(True)
        self.toolBar.addAction(self.clearButton)
        self.toolBar.addAction(self.actionClass)
        self.toolBar.addAction(self.runButton)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.showEditorButton)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.optionsButton)
        self.toolBar.addAction(self.helpButton)

        if sys.platform.startswith('win'):
            bkgrcolor = ['170', '170', '170']
            bordercl = ['125', '125', '125']
        else:
            bkgrcolor = ['200', '200', '200']
            bordercl = ['155', '155', '155']

        self.toolBarEditor = QToolBar()
        self.toolBarEditor.setStyleSheet(
            'QToolBar{background-color: rgb(%s, %s, %s' % tuple(bkgrcolor) +
            ');\
                                          border-right: 1px solid rgb(%s, %s, %s'
            % tuple(bordercl) + ');}')
        self.toolBarEditor.setEnabled(False)
        self.toolBarEditor.setFocusPolicy(Qt.NoFocus)
        self.toolBarEditor.setContextMenuPolicy(Qt.DefaultContextMenu)
        self.toolBarEditor.setLayoutDirection(Qt.LeftToRight)
        self.toolBarEditor.setIconSize(QSize(18, 18))
        self.toolBarEditor.setOrientation(Qt.Vertical)
        self.toolBarEditor.setMovable(True)
        self.toolBarEditor.setFloatable(True)
        self.toolBarEditor.addAction(self.openFileButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.saveFileButton)
        self.toolBarEditor.addAction(self.saveAsFileButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.findTextButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.cutEditorButton)
        self.toolBarEditor.addAction(self.copyEditorButton)
        self.toolBarEditor.addAction(self.pasteEditorButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.commentEditorButton)
        self.toolBarEditor.addAction(self.uncommentEditorButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.objectListButton)
        self.toolBarEditor.addSeparator()
        self.toolBarEditor.addAction(self.runScriptEditorButton)

        ## Menu Import Class
        self.classMenu = QMenu()
        self.classMenu.addAction(self.loadSextanteButton)
        self.classMenu.addAction(self.loadQtCoreButton)
        self.classMenu.addAction(self.loadQtGuiButton)
        cM = self.toolBar.widgetForAction(self.actionClass)
        cM.setMenu(self.classMenu)
        cM.setPopupMode(QToolButton.InstantPopup)

        self.widgetButton = QWidget()
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.widgetButton.sizePolicy().hasHeightForWidth())
        self.widgetButton.setSizePolicy(sizePolicy)

        self.widgetButtonEditor = QWidget(self.widgetEditor)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.widgetButtonEditor.sizePolicy().hasHeightForWidth())
        self.widgetButtonEditor.setSizePolicy(sizePolicy)

        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.shellOut.sizePolicy().hasHeightForWidth())
        self.shellOut.setSizePolicy(sizePolicy)

        self.shellOut.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.shell.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        ##------------ Layout -------------------------------

        self.mainLayout = QGridLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        self.mainLayout.addWidget(self.widgetButton, 0, 0, 1, 1)
        self.mainLayout.addWidget(self.splitterEditor, 0, 1, 1, 1)

        self.layoutEditor = QGridLayout(self.widgetEditor)
        self.layoutEditor.setMargin(0)
        self.layoutEditor.setSpacing(0)
        self.layoutEditor.addWidget(self.widgetButtonEditor, 0, 0, 2, 1)
        self.layoutEditor.addWidget(self.tabEditorWidget, 0, 1, 1, 1)
        self.layoutEditor.addWidget(self.widgetFind, 1, 1, 1, 1)

        self.toolBarLayout = QGridLayout(self.widgetButton)
        self.toolBarLayout.setMargin(0)
        self.toolBarLayout.setSpacing(0)
        self.toolBarLayout.addWidget(self.toolBar)
        self.toolBarEditorLayout = QGridLayout(self.widgetButtonEditor)
        self.toolBarEditorLayout.setMargin(0)
        self.toolBarEditorLayout.setSpacing(0)
        self.toolBarEditorLayout.addWidget(self.toolBarEditor)

        ## Layout for the find widget
        self.layoutFind = QGridLayout(self.widgetFind)
        self.layoutFind.setContentsMargins(0, 0, 0, 0)
        self.lineEditFind = QgsFilterLineEdit()
        placeHolderTxt = QCoreApplication.translate("PythonConsole",
                                                    "Enter text to find...")

        if pyqtconfig.Configuration().qt_version >= 0x40700:
            self.lineEditFind.setPlaceholderText(placeHolderTxt)
        else:
            self.lineEditFind.setToolTip(placeHolderTxt)
        self.findNextButton = QToolButton()
        self.findNextButton.setEnabled(False)
        toolTipfindNext = QCoreApplication.translate("PythonConsole",
                                                     "Find Next")
        self.findNextButton.setToolTip(toolTipfindNext)
        self.findNextButton.setIcon(
            QgsApplication.getThemeIcon(
                "console/iconSearchNextEditorConsole.png"))
        self.findNextButton.setIconSize(QSize(24, 24))
        self.findNextButton.setAutoRaise(True)
        self.findPrevButton = QToolButton()
        self.findPrevButton.setEnabled(False)
        toolTipfindPrev = QCoreApplication.translate("PythonConsole",
                                                     "Find Previous")
        self.findPrevButton.setToolTip(toolTipfindPrev)
        self.findPrevButton.setIcon(
            QgsApplication.getThemeIcon(
                "console/iconSearchPrevEditorConsole.png"))
        self.findPrevButton.setIconSize(QSize(24, 24))
        self.findPrevButton.setAutoRaise(True)
        self.caseSensitive = QCheckBox()
        caseSensTr = QCoreApplication.translate("PythonConsole",
                                                "Case Sensitive")
        self.caseSensitive.setText(caseSensTr)
        self.wholeWord = QCheckBox()
        wholeWordTr = QCoreApplication.translate("PythonConsole", "Whole Word")
        self.wholeWord.setText(wholeWordTr)
        self.wrapAround = QCheckBox()
        self.wrapAround.setChecked(True)
        wrapAroundTr = QCoreApplication.translate("PythonConsole",
                                                  "Wrap Around")
        self.wrapAround.setText(wrapAroundTr)
        self.layoutFind.addWidget(self.lineEditFind, 0, 1, 1, 1)
        self.layoutFind.addWidget(self.findPrevButton, 0, 2, 1, 1)
        self.layoutFind.addWidget(self.findNextButton, 0, 3, 1, 1)
        self.layoutFind.addWidget(self.caseSensitive, 0, 4, 1, 1)
        self.layoutFind.addWidget(self.wholeWord, 0, 5, 1, 1)
        self.layoutFind.addWidget(self.wrapAround, 0, 6, 1, 1)

        ##------------ Add first Tab in Editor -------------------------------

        #self.tabEditorWidget.newTabEditor(tabName='first', filename=None)

        ##------------ Signal -------------------------------

        self.findTextButton.toggled.connect(self.findTextEditor)
        self.objectListButton.toggled.connect(self.toggleObjectListWidget)
        self.commentEditorButton.triggered.connect(self.commentCode)
        self.uncommentEditorButton.triggered.connect(self.uncommentCode)
        self.runScriptEditorButton.triggered.connect(self.runScriptEditor)
        self.cutEditorButton.triggered.connect(self.cutEditor)
        self.copyEditorButton.triggered.connect(self.copyEditor)
        self.pasteEditorButton.triggered.connect(self.pasteEditor)
        self.showEditorButton.toggled.connect(self.toggleEditor)
        self.clearButton.triggered.connect(self.shellOut.clearConsole)
        self.optionsButton.triggered.connect(self.openSettings)
        self.loadSextanteButton.triggered.connect(self.sextante)
        self.loadQtCoreButton.triggered.connect(self.qtCore)
        self.loadQtGuiButton.triggered.connect(self.qtGui)
        self.runButton.triggered.connect(self.shell.entered)
        self.openFileButton.triggered.connect(self.openScriptFile)
        self.saveFileButton.triggered.connect(self.saveScriptFile)
        self.saveAsFileButton.triggered.connect(self.saveAsScriptFile)
        self.helpButton.triggered.connect(self.openHelp)
        self.connect(self.options.buttonBox, SIGNAL("accepted()"),
                     self.prefChanged)
        self.connect(self.listClassMethod,
                     SIGNAL('itemClicked(QTreeWidgetItem*, int)'),
                     self.onClickGoToLine)
        self.lineEditFind.returnPressed.connect(self._findText)
        self.findNextButton.clicked.connect(self._findNext)
        self.findPrevButton.clicked.connect(self._findPrev)
        self.lineEditFind.textChanged.connect(self._textFindChanged)
예제 #22
0
#!/usr/bin/env python2.7
# This file is part of KDevelop
# Copyright 2011 by Victor Varvariuc <*****@*****.**>, Sven Brauch <*****@*****.**>

import os, sys, subprocess
from xml.dom import minidom, NotFoundErr

import sipconfig
from PyQt4 import pyqtconfig

config = pyqtconfig.Configuration() # Get the PyQt configuration information.

def convertSipToXML(inFilePath, outFilePath):
    if not os.path.exists(outFilePath):
        command = [config.sip_bin, '-m', outFilePath, '-I', config.pyqt_sip_dir, '-I', config.pyqt_sip_dir+'/python3-PyKDE4']
        command.extend(config.pyqt_sip_flags.split())
        command.append(inFilePath)

        print('\nConverting sip to xml:\n%s' % ' '.join(command))
        try:
            print subprocess.check_output(command, stderr = subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            print('There was an error when running the command:')
            print(e.output)

        print('Opening and parsing XML document...')
        # replace the invalid "&"s which are used by pykde to indicate shortcuts
        # they would need to be escaped, but oh well
        f = open(outFilePath, 'r')
        data = f.read()
        f.close()
예제 #23
0
def doit():
	global opt_static
	global opt_debug
	# The name of the SIP build file generated by SIP and used by the build
	# system.
	build_file = "stone.sbf"

	# Get the PyQt configuration information.
	config = pyqtconfig.Configuration()
	config.pyqt_modules = ['QtCore','QtXml','QtNetwork','QtSql']
	config.__dict__["AR"] = "ar r"
    
	sipOutputDir = "sipStone"
	if opt_static == 1:
		sipOutputDir += "Static"
	
	path = os.path.dirname(os.path.abspath(__file__))
	
	try:
		os.mkdir(os.path.join(path,sipOutputDir))
	except: pass
        
	makefileName = "sipMakefile"
	if opt_static == 1:
		makefileName += "Static"

	# Get the extra SIP flags needed by the imported qt module.  Note that
	# this normally only includes those flags (-x and -t) that relate to SIP's
	# versioning system.
	#print config.__dict__

	# Run SIP to generate the code.  Note that we tell SIP where to find the qt
	# module's specification files using the -I flag.
	#config.pyqt_sip_dir = "/usr/share/sip/PyQt4"
	#config.pyqt_sip_dir = "c:\\python24\\sip\\PyQt4\\"
	if sys.platform=="win32":
		sip_bin = "..\\sip\\sipgen\\sip.exe"
	else: 
		sip_bin = config.sip_bin
	cmd = " ".join([sip_bin, "-e", "-k", "-c", sipOutputDir, "-b", sipOutputDir+"/"+build_file, "-I", config.pyqt_sip_dir, config.pyqt_sip_flags, "sip/blurqt.sip"])
	ret = os.system(cmd)
	
	if ret:
		sys.exit(ret%255)
        
	# We are going to install the SIP specification file for this module and
	# its configuration module.

	# Create the Makefile.  The QtModuleMakefile class provided by the
	# pyqtconfig module takes care of all the extra preprocessor, compiler and
	# linker flags needed by the Qt library.
	makefile = StoneModuleMakefile(
		configuration=config,
		build_file=build_file,
		static=opt_static,
		debug=opt_debug,
		# Use the sip mod directory instead in order to adhere to the DESTDIR settings
		install_dir=os.path.join(config.sip_mod_dir,"blur"),
#       install_dir=os.path.join(config.default_mod_dir,"blur"),
		dir=sipOutputDir
	)
	installs = []
	sipfiles = []
	scriptfiles = []

	scriptfilesprefix = "../../../python/blur"
	for s in glob.glob(scriptfilesprefix + "/*.py"):
		if sys.platform == "win32":
			scriptfilesprefix = scriptfilesprefix.replace("/","\\")
		scriptfiles.append(os.path.join(scriptfilesprefix, os.path.basename(s)))

	installs.append([scriptfiles, os.path.join(config.sip_mod_dir, "blur")])

	for s in glob.glob("sip/*.sip"):
		sipfiles.append(os.path.join("sip", os.path.basename(s)))

	# installs.append([sipfiles, os.path.join(config.sip_mod_dir, "blur")])
	installs.append([sipfiles, os.path.join(config.default_sip_dir, "blur")])

	# Use the sip mod directory instead in order to adhere to the DESTDIR settings
	installs.append(["stoneconfig.py", config.sip_mod_dir])
#   installs.append(["stoneconfig.py", config.default_mod_dir])

	if opt_static == 0:
		if os.name == 'nt':
			installs.append(["stone.dll", os.path.join(config.default_mod_dir, "blur")])

	sipconfig.ParentMakefile(
		configuration=config,
		installs=installs,
		subdirs=[sipOutputDir],
        makefile=makefileName
	).generate()

	# Add the library we are wrapping.  The name doesn't include any platform
	# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
	# ".dll" extension on Windows).
	if sys.platform == "win32":
		makefile.extra_libs = ["stone","QtSql4","QtXml4","QtNetwork4"]
	elif sys.platform == "darwin":
		makefile.extra_libs = ["stone"]
	else:
		makefile.extra_libs = ["stone","QtSql","QtXml","QtNetwork"]
		
	makefile.extra_include_dirs = ["../include"]
	makefile.extra_lib_dirs.append( ".." );

	# Generate the Makefile itself.
	makefile.generate()

	# Now we create the configuration module.  This is done by merging a Python
	# dictionary (whose values are normally determined dynamically) with a
	# (static) template.
	content = {
		# Publish where the SIP specifications for this module will be
		# installed.
		"stone_sip_dir":    config.default_sip_dir,

		# Publish the set of SIP flags needed by this module.  As these are the
		# same flags needed by the qt module we could leave it out, but this
		# allows us to change the flags at a later date without breaking
		# scripts that import the configuration module.
		"stone_sip_flags":  config.pyqt_sip_flags
	}

	# This creates the helloconfig.py module from the helloconfig.py.in
	# template and the dictionary.
	sipconfig.create_config_module("stoneconfig.py", "stoneconfig.py.in", content)
예제 #24
0
def doit():
    global opt_static
    global opt_debug
    # The name of the SIP build file generated by SIP and used by the build
    # system.
    build_file = "epa.sbf"

    # Get the PyQt configuration information.
    config = pyqtconfig.Configuration()
    config.pyqt_modules = ['QtCore', 'QtXml', 'QtNetwork', 'QtSql']
    config.__dict__["AR"] = "ar r"

    # Get the extra SIP flags needed by the imported qt module.  Note that
    # this normally only includes those flags (-x and -t) that relate to SIP's
    # versioning system.
    #print config.__dict__

    # Run SIP to generate the code.  Note that we tell SIP where to find the qt
    # module's specification files using the -I flag.
    #config.pyqt_sip_dir = "/usr/share/sip/PyQt4"
    #config.pyqt_sip_dir = "c:\\python24\\sip\\PyQt4\\"
    cmd = " ".join([
        config.sip_bin, "-c", "sipEpa", "-b", "sipEpa/" + build_file, "-I",
        config.pyqt_sip_dir, config.pyqt_sip_flags, "sip/blurqt.sip"
    ])
    ret = os.system(cmd)

    if ret:
        sys.exit(ret % 255)

    # We are going to install the SIP specification file for this module and
    # its configuration module.

    # Create the Makefile.  The QtModuleMakefile class provided by the
    # pyqtconfig module takes care of all the extra preprocessor, compiler and
    # linker flags needed by the Qt library.
    makefile = EpaModuleMakefile(configuration=config,
                                 build_file=build_file,
                                 static=opt_static,
                                 debug=opt_debug,
                                 install_dir=os.path.join(
                                     config.default_mod_dir, "blur"),
                                 dir="sipEpa")
    installs = []
    sipfiles = []

    for s in glob.glob("sip/*.sip"):
        sipfiles.append(os.path.join("sip", os.path.basename(s)))

    installs.append([sipfiles, os.path.join(config.default_sip_dir, "blur")])

    installs.append(["epaconfig.py", config.default_mod_dir])

    sipconfig.ParentMakefile(configuration=config,
                             installs=installs,
                             subdirs=["sipEpa"]).generate()

    # Add the library we are wrapping.  The name doesn't include any platform
    # specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
    # ".dll" extension on Windows).
    if sys.platform == "win32":
        makefile.extra_libs = ["epa", "QtSql4", "QtXml4", "QtNetwork4"]
    elif sys.platform == "darwin":
        makefile.extra_libs = ["epa"]
    else:
        makefile.extra_libs = ["epa", "QtSql", "QtXml", "QtNetwork"]

    makefile.extra_include_dirs = ["../include"]
    makefile.extra_lib_dirs.append("..")

    # Generate the Makefile itself.
    makefile.generate()

    # Now we create the configuration module.  This is done by merging a Python
    # dictionary (whose values are normally determined dynamically) with a
    # (static) template.
    content = {
        # Publish where the SIP specifications for this module will be
        # installed.
        "epa_sip_dir": config.default_sip_dir,

        # Publish the set of SIP flags needed by this module.  As these are the
        # same flags needed by the qt module we could leave it out, but this
        # allows us to change the flags at a later date without breaking
        # scripts that import the configuration module.
        "epa_sip_flags": config.pyqt_sip_flags
    }

    # This creates the helloconfig.py module from the helloconfig.py.in
    # template and the dictionary.
    sipconfig.create_config_module("epaconfig.py", "epaconfig.py.in", content)
예제 #25
0
def doit():
	global opt_static
	global opt_debug
	global opt_generate_code
	
	# The name of the SIP build file generated by SIP and used by the build
	# system.
	build_file = "absubmit.sbf"

	# Get the PyQt configuration information.
	config = pyqtconfig.Configuration()
	config.pyqt_modules = []
	config.__dict__["AR"] = "ar r"

	# Get the extra SIP flags needed by the imported qt module.  Note that
	# this normally only includes those flags (-x and -t) that relate to SIP's
	# versioning system.
#	qt_sip_flags = config.pyqt_qt_sip_flags

	# Run SIP to generate the code.  Note that we tell SIP where to find the qt
	# module's specification files using the -I flag.
	#config.pyqt_sip_dir = "/usr/share/sip/PyQt4"
	#config.pyqt_sip_dir = "c:\\python24\\sip\\PyQt4\\"
	print config.default_sip_dir
	qt_sip_flags = config.pyqt_sip_flags
	if opt_generate_code:
		if sys.platform=="win32":
				sip_bin = "..\\sip\\sipgen\\sip.exe"
		else:
				sip_bin = config.sip_bin
		if not os.path.exists("sipAbsubmit"):
				os.mkdir("sipAbsubmit")
		ret = os.system(" ".join([sip_bin, "-k", "-c", "sipAbsubmit", "-b", "sipAbsubmit/" + build_file, "-I", config.pyqt_sip_dir, "-I", config.default_sip_dir, "-I", config.sip_mod_dir, config.pyqt_sip_flags, "sip/absubmit.sip"]))
		if ret:
			sys.exit(ret%255)
	
	# Create the Makefile.  The QtModuleMakefile class provided by the
	# pyqtconfig module takes care of all the extra preprocessor, compiler and
	# linker flags needed by the Qt library.
	makefile = AbsubmitModuleMakefile(
		configuration=config,
		build_file=build_file,
		static=opt_static,
		debug=opt_debug,
		# Use the sip mod dir to adhere to the DESTDIR env var
		install_dir=os.path.join(config.sip_mod_dir,"blur"),
#		install_dir=os.path.join(config.default_mod_dir,"blur"),
		dir="sipAbsubmit"
	)

	installs = []
	sipfiles = []

	for s in glob.glob("sip/*.sip"):
		sipfiles.append(os.path.join("sip", os.path.basename(s)))

	installs.append([sipfiles, os.path.join(config.default_sip_dir, "blur")])

	# Use the sip mod dir to adhere to the DESTDIR env var
	#installs.append(["absubmitconfig.py", config.sip_mod_dir])
	#installs.append(["absubmitconfig.py", config.default_mod_dir])

	sipconfig.ParentMakefile(
		configuration=config,
		installs=installs,
		subdirs=["sipAbsubmit"]
	).generate()

	# Add the library we are wrapping.  The name doesn't include any platform
	# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
	# ".dll" extension on Windows).
	if sys.platform == "win32":
		makefile.extra_libs = ["absubmit","classes","stone","QtSql4","QtXml4","QtNetwork4","Mpr"]
	elif sys.platform == "darwin":
		makefile.extra_libs = ["absubmit","classes","stone","absubmit"]
	else:
		makefile.extra_libs = ["absubmit","classes","stone","QtSql","QtXml","QtNetwork","absubmit"]

	makefile.extra_include_dirs = ["../.out","../../stone/include","../include","../../classes/autocore","../../classes"]
	makefile.extra_lib_dirs.append( ".." );
	makefile.extra_lib_dirs.append( "../../stone" );
	makefile.extra_lib_dirs.append( "../../classes" );
	

	# Generate the Makefile itself.
	makefile.generate()

	# Now we create the configuration module.  This is done by merging a Python
	# dictionary (whose values are normally determined dynamically) with a
	# (static) template.
	content = {
		# Publish where the SIP specifications for this module will be
		# installed.
		"stone_sip_dir":    config.default_sip_dir,

		# Publish the set of SIP flags needed by this module.  As these are the
		# same flags needed by the qt module we could leave it out, but this
		# allows us to change the flags at a later date without breaking
		# scripts that import the configuration module.
		"stone_sip_flags":  qt_sip_flags
	}
예제 #26
0
    backend = options.backend.lower()
    if backend.startswith("gtk"):
        import gtk
        import gobject
        print("# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \
            (gtk.pygtk_version, gtk.gtk_version,
             gobject.pygobject_version, gobject.glib_version))
    elif backend.startswith("qt4"):
        import PyQt4.pyqtconfig
        print("# PyQt4 version: %s, Qt version %x" % \
            (PyQt4.pyqtconfig.Configuration().pyqt_version_str,
             PyQt4.pyqtconfig.Configuration().qt_version))
    elif backend.startswith("qt"):
        import pyqtconfig
        print("# pyqt version: %s, qt version: %x" % \
            (pyqtconfig.Configuration().pyqt_version_str,
             pyqtconfig.Configuration().qt_version))
    elif backend.startswith("wx"):
        import wx
        print("# wxPython version: %s" % wx.__version__)
    elif backend.startswith("tk"):
        import Tkinter
        print("# Tkinter version: %s, Tk version: %s, Tcl version: %s" %
              (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion))

    print('# Averaging over loops %d to %d' % (indStart, indEnd))
    print('# Memory went from %dk to %dk' % (start, end))
    print('# Average memory consumed per loop: %1.4fk bytes\n' %
          ((end - start) / float(indEnd - indStart)))

if options.cycles:
예제 #27
0
 def _pyqt_sip_dir(self):
     """ Retrieve PyQt include dir for sip  """        
     cfg = pyqtconfig.Configuration()
     return cfg.pyqt_sip_dir
예제 #28
0
 def _pyqt_sip_flags(self):
     """ Retrieve PyQt flag for sip  """
     cfg = pyqtconfig.Configuration()
     return cfg.pyqt_sip_flags.split()
예제 #29
0
 def _qt_inc_dir(self):
     """ Retrieve Qt include dir """
     cfg = pyqtconfig.Configuration()
     return [cfg.qt_inc_dir]+map(lambda x : pj(cfg.qt_inc_dir,x), cfg.pyqt_modules.split())
예제 #30
0
 def _qt_lib_dir(self):
     """ Retrieve qt lib dir for compiler """        
     cfg = pyqtconfig.Configuration()
     return [cfg.qt_lib_dir]