PyQt compatible Python wrapping using SIP
authorBrandon King <kingb@caltech.edu>
Thu, 12 Apr 2007 22:31:03 +0000 (22:31 +0000)
committerBrandon King <kingb@caltech.edu>
Thu, 12 Apr 2007 22:31:03 +0000 (22:31 +0000)
  * First successful attempt at wrapping a mussagl Qt Widget in a way
that makes it compatible with PyQt.
  * Currently Wrapped:
    * MussaSetupDialog

qui/mussa_setup_dialog/MussaSetupDialog.sip [new file with mode: 0644]
sip/configure.py [new file with mode: 0644]
sip/mussamod.sip [new file with mode: 0644]

diff --git a/qui/mussa_setup_dialog/MussaSetupDialog.sip b/qui/mussa_setup_dialog/MussaSetupDialog.sip
new file mode 100644 (file)
index 0000000..b0386b8
--- /dev/null
@@ -0,0 +1,17 @@
+// MussaSetupDialog Sip Wrapper
+
+class MussaSetupDialog : QDialog
+{
+%TypeHeaderCode
+#include "../qui/mussa_setup_dialog/MussaSetupDialog.hpp"
+%End
+
+public:
+  MussaSetupDialog(QWidget *parent /TransferThis/ = 0, Qt::WFlags f = 0);
+  void accept();
+  void reject();
+
+private:
+  MussaSetupDialog(const MussaSetupDialog &);
+
+};
diff --git a/sip/configure.py b/sip/configure.py
new file mode 100644 (file)
index 0000000..f24d3be
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+import os
+import sipconfig
+from PyQt4 import pyqtconfig
+
+# The name of the SIP build file generated by SIP and used by the build
+# system.
+build_file = "mussamod.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
+
+# 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", ".", "-b", build_file, "-I", config.pyqt_sip_dir, qt_sip_flags, "mussamod.sip"]))
+
+# We are going to install the SIP specification file for this module and
+# its configuration module.
+installs = []
+
+installs.append(["mussamod.sip", os.path.join(config.default_sip_dir, "mussa")])
+
+#installs.append(["mussaconfig.py", config.default_mod_dir])
+
+# 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 = pyqtconfig.QtGuiModuleMakefile(
+          configuration=config,
+          build_file=build_file,
+          installs=installs
+      )
+
+# 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).
+makefile.LFLAGS.append("-L../build/qui")
+makefile.LFLAGS.append("-L../build/alg")
+makefile.extra_include_dirs.append("..")
+makefile.extra_libs = ["mussa_qui", "mussa_core",
+                       "boost_filesystem",
+                       "boost_serialization",
+                       "boost_program_options"]
+
+# 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.
+#  "mussa_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.
+#  "mussa_sip_flags":  qt_sip_flags
+#  }
+
+# This creates the quit_buttonconfig.py module from the quit_buttonconfig.py.in
+# template and the dictionary.
+#sipconfig.create_config_module("mussaconfig.py", "mussaconfig.py.in", content)
diff --git a/sip/mussamod.sip b/sip/mussamod.sip
new file mode 100644 (file)
index 0000000..172e768
--- /dev/null
@@ -0,0 +1,9 @@
+// Mussa SIP Wrapper
+%Module mussagl 0
+
+%Import QtGui/QtGuimod.sip
+%Import QtCore/QtCoremod.sip
+
+%Include ../qui/mussa_setup_dialog/MussaSetupDialog.sip
+
+