Commit 0f2569ca authored by Pierre Kraemer's avatar Pierre Kraemer

add PythonQt library

parent 58b5895c
......@@ -3,7 +3,7 @@
#include "ui_window.h"
#include "PythonQt/PythonQt.h"
#include "PythonQt.h"
#include "types.h"
class QVBoxLayout;
......
#include <QSplashScreen>
#include "PythonQt/PythonQt.h"
#include "PythonQt/PythonQtScriptingConsole.h"
#include "PythonQt.h"
#include "gui/PythonQtScriptingConsole.h"
#include "window.h"
int main(int argc, char* argv[])
......
......@@ -51,6 +51,9 @@ IF (WITH_NUMERICAL)
ENDIF (WITH_NUMERICAL)
add_subdirectory(PythonQt PythonQt/build)
IF(WIN32)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "" FORCE)
......
cmake_minimum_required(VERSION 2.8)
#-----------------------------------------------------------------------------
# See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details
#
SET(project_policies
CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
CMP0002 # NEW: Logical target names must be globally unique.
CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths.
CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace.
CMP0005 # NEW: Preprocessor definition values are now escaped automatically.
CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
CMP0007 # NEW: List command no longer ignores empty elements.
CMP0008 # NEW: Libraries linked by full-path must have a valid library file name.
CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default.
CMP0010 # NEW: Bad variable reference syntax is an error.
CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP.
CMP0012 # NEW: if() recognizes numbers and boolean constants.
CMP0013 # NEW: Duplicate binary directories are not allowed.
CMP0014 # NEW: Input directories must have CMakeLists.txt
)
FOREACH(policy ${project_policies})
IF(POLICY ${policy})
CMAKE_POLICY(SET ${policy} NEW)
ENDIF()
ENDFOREACH()
#-----------------------------------------------------------------------------
project(PythonQt)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Python libraries
find_package(PythonLibs REQUIRED)
include_directories("${PYTHON_INCLUDE_DIR}")
add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
#-----------------------------------------------------------------------------
# Build options
foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
OPTION(PythonQt_Wrap_Qt${qtlib} "Make all of Qt${qtlib} available in python" OFF)
endforeach()
option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF)
if(PythonQt_DEBUG)
add_definitions(-DPYTHONQT_DEBUG)
else()
remove_definitions(-DPYTHONQT_DEBUG)
endif()
#-----------------------------------------------------------------------------
# Setup Qt
set(minimum_required_qt_version "4.6.2")
find_package(Qt4)
if(QT4_FOUND)
set(found_qt_version ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version})
message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.")
endif()
# Enable required qt module
foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
string(TOUPPER ${qtlib} qtlib_uppercase)
if (NOT ${QT_QT${qtlib_uppercase}_FOUND})
message(FATAL_ERROR "QT_QT${${qtlib_uppercase} *not* FOUND - Try to disable PythonQt_Wrap_Qt${qtlib}")
endif()
set(QT_USE_QT${qtlib_uppercase} ${PythonQt_Wrap_Qt${qtlib}})
endforeach()
include(${QT_USE_FILE})
else()
message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
endif()
#-----------------------------------------------------------------------------
# Sources
set(sources
src/PythonQtClassInfo.cpp
src/PythonQtClassWrapper.cpp
src/PythonQtConversion.cpp
src/PythonQt.cpp
src/PythonQtImporter.cpp
src/PythonQtInstanceWrapper.cpp
src/PythonQtMethodInfo.cpp
src/PythonQtMisc.cpp
src/PythonQtObjectPtr.cpp
src/PythonQtQFileImporter.cpp
src/PythonQtSignalReceiver.cpp
src/PythonQtSlot.cpp
src/PythonQtSignal.cpp
src/PythonQtStdDecorators.cpp
src/PythonQtStdIn.cpp
src/PythonQtStdOut.cpp
src/gui/PythonQtScriptingConsole.cpp
generated_cpp/PythonQt_QtBindings.cpp
generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp
generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin_init.cpp
generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp
generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin_init.cpp
)
#-----------------------------------------------------------------------------
# List headers. This is list is used for the install command.
set(headers
src/PythonQtClassInfo.h
src/PythonQtClassWrapper.h
src/PythonQtConversion.h
src/PythonQtCppWrapperFactory.h
src/PythonQtDoc.h
src/PythonQt.h
src/PythonQtImporter.h
src/PythonQtImportFileInterface.h
src/PythonQtInstanceWrapper.h
src/PythonQtMethodInfo.h
src/PythonQtMisc.h
src/PythonQtObjectPtr.h
src/PythonQtQFileImporter.h
src/PythonQtSignalReceiver.h
src/PythonQtSlot.h
src/PythonQtSignal.h
src/PythonQtStdDecorators.h
src/PythonQtStdIn.h
src/PythonQtStdOut.h
src/PythonQtSystem.h
src/PythonQtVariants.h
src/PythonQtPythonInclude.h
generated_cpp/PythonQt_QtBindings.h
)
#-----------------------------------------------------------------------------
# Headers that should run through moc
set(moc_sources
src/PythonQt.h
src/PythonQtSignalReceiver.h
src/PythonQtStdDecorators.h
src/gui/PythonQtScriptingConsole.h
generated_cpp/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h
generated_cpp/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h
)
#-----------------------------------------------------------------------------
# Add extra sources
foreach(qtlib core gui network opengl sql svg uitools webkit xml xmlpatterns)
if (${PythonQt_Wrap_Qt${qtlib}})
ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qtlib})
set(file_prefix generated_cpp/com_trolltech_qt_${qtlib}/com_trolltech_qt_${qtlib})
foreach(index RANGE 0 10)
# Source files
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.cpp)
list(APPEND sources ${file_prefix}${index}.cpp)
endif()
# Headers that should run through moc
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
list(APPEND moc_sources ${file_prefix}${index}.h)
endif()
endforeach()
list(APPEND sources ${file_prefix}_init.cpp)
endif()
endforeach()
#-----------------------------------------------------------------------------
# UI files
set(ui_sources )
#-----------------------------------------------------------------------------
# Resources
set(qrc_sources )
#-----------------------------------------------------------------------------
# Do wrapping
qt4_wrap_cpp(gen_moc_sources ${moc_sources})
qt4_wrap_ui(gen_ui_sources ${ui_sources})
qt4_add_resources(gen_qrc_sources ${qrc_sources})
#-----------------------------------------------------------------------------
# Build the library
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_library(PythonQt SHARED
${sources}
${gen_moc_sources}
${gen_ui_sources}
${gen_qrc_sources}
)
set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
#
# That should solve linkage error on Mac when the project is used in a superbuild setup
# See http://blog.onesadcookie.com/2008/01/installname-magic.html
#
set_target_properties(PythonQt PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
)
target_link_libraries(PythonQt
${PYTHON_LIBRARY}
${QT_LIBRARIES}
)
#-----------------------------------------------------------------------------
# Install library (on windows, put the dll in 'bin' and the archive in 'lib')
install(TARGETS PythonQt
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES ${headers} DESTINATION include/PythonQt)
This diff is collapsed.
PythonQt
--------
PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://qt.nokia.com).
It offers an easy way to embed the Python scripting language into
your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
Licensing of PythonQt
---------------------
PythonQt is distributed under the LGPL 2.1 license.
Licensing of Generator
----------------------
The build system of PythonQt makes use of a patched version of the LGPL'ed QtScript generator, located in the "generator" directory.
See the LICENSE.LGPL file in the generator subdirectory for details.
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
See http://qt.gitorious.org/qt-labs/qtscriptgenerator for the original project.
The PythonQt wrappers generated by the generator are distributed under the LGPL as well.
The generated wrappers are pre-generated and checked-in for Qt 4.6.1, so you only need to build and run the
generator when you want to build additional wrappers or you want to upgrade/downgrade to another Qt version, but this requires updating the typesystems as well.
Documentation
-------------
More documentation is available at:
http://pythonqt.sourceforge.net/
/*
*
* Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
* 28359 Bremen, Germany or:
*
* http://www.mevis.de
*
*/
#include "PythonQt_QtAll.h"
#include "PythonQt.h"
void PythonQt_init_QtGui(PyObject*);
void PythonQt_init_QtSvg(PyObject*);
void PythonQt_init_QtSql(PyObject*);
void PythonQt_init_QtNetwork(PyObject*);
void PythonQt_init_QtCore(PyObject*);
void PythonQt_init_QtWebKit(PyObject*);
void PythonQt_init_QtOpenGL(PyObject*);
void PythonQt_init_QtXml(PyObject*);
void PythonQt_init_QtXmlPatterns(PyObject*);
void PythonQt_init_QtUiTools(PyObject*);
void PythonQt_init_QtPhonon(PyObject*);
namespace PythonQt_QtAll
{
PYTHONQT_QTALL_EXPORT void init() {
PythonQt_init_QtCore(0);
PythonQt_init_QtNetwork(0);
PythonQt_init_QtGui(0);
PythonQt_init_QtXml(0);
PythonQt_init_QtSvg(0);
PythonQt_init_QtSql(0);
PythonQt_init_QtWebKit(0);
PythonQt_init_QtOpenGL(0);
PythonQt_init_QtUiTools(0);
// Does not compile yet:
// PythonQt_init_QtXmlPatterns(0);
// PythonQt_init_QtPhonon(0);
};
};
#ifndef _PYTHONQT_QTALL_H
#define _PYTHONQT_QTALL_H
/*
*
* Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
* 28359 Bremen, Germany or:
*
* http://www.mevis.de
*
*/
#ifdef WIN32
#ifdef PYTHONQT_QTALL_EXPORTS
#define PYTHONQT_QTALL_EXPORT __declspec(dllexport)
#else
#define PYTHONQT_QTALL_EXPORT __declspec(dllimport)
#endif
#else
#define PYTHONQT_QTALL_EXPORT
#endif
namespace PythonQt_QtAll
{
//! initialize the Qt binding
PYTHONQT_QTALL_EXPORT void init();
};
#endif
TARGET = PythonQt_QtAll
TEMPLATE = lib
DESTDIR = ../../lib
include ( ../../build/common.prf )
include ( ../../build/PythonQt.prf )
CONFIG += dll qt
DEFINES += PYTHONQT_QTALL_EXPORTS
HEADERS += \
PythonQt_QtAll.h
SOURCES += \
PythonQt_QtAll.cpp
CONFIG += uitools
QT += webkit gui svg sql network xml xmlpatterns opengl
#QT += phonon
include (../../generated_cpp/com_trolltech_qt_core/com_trolltech_qt_core.pri)
include (../../generated_cpp/com_trolltech_qt_gui/com_trolltech_qt_gui.pri)
include (../../generated_cpp/com_trolltech_qt_svg/com_trolltech_qt_svg.pri)
include (../../generated_cpp/com_trolltech_qt_sql/com_trolltech_qt_sql.pri)
include (../../generated_cpp/com_trolltech_qt_network/com_trolltech_qt_network.pri)
include (../../generated_cpp/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri)
include (../../generated_cpp/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri)
include (../../generated_cpp/com_trolltech_qt_xml/com_trolltech_qt_xml.pri)
include (../../generated_cpp/com_trolltech_qt_uitools/com_trolltech_qt_uitools.pri)
#include (../../generated_cpp/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri)
#include (../../generated_cpp/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri)
TEMPLATE = subdirs
SUBDIRS = PythonQt_QtAll
#include "PythonQt_QtBindings.h"
#include "PythonQt.h"
void PythonQt_init_QtGui(PyObject*);
void PythonQt_init_QtSvg(PyObject*);
void PythonQt_init_QtSql(PyObject*);
void PythonQt_init_QtNetwork(PyObject*);
void PythonQt_init_QtCore(PyObject*);
void PythonQt_init_QtWebKit(PyObject*);
void PythonQt_init_QtOpenGL(PyObject*);
void PythonQt_init_QtXml(PyObject*);
void PythonQt_init_QtXmlPatterns(PyObject*);
void PythonQt_init_QtUiTools(PyObject*);
void PythonQt_init_QtPhonon(PyObject*);
PYTHONQT_EXPORT void PythonQt_init_QtBindings()
{
#ifdef PYTHONQT_WRAP_Qtcore
PythonQt_init_QtCore(0);
#endif
#ifdef PYTHONQT_WRAP_Qtgui
PythonQt_init_QtGui(0);
#endif
#ifdef PYTHONQT_WRAP_Qtnetwork
PythonQt_init_QtNetwork(0);
#endif
#ifdef PYTHONQT_WRAP_Qtopengl
PythonQt_init_QtOpenGL(0);
#endif
#ifdef PYTHONQT_WRAP_Qtsql
PythonQt_init_QtSql(0);
#endif
#ifdef PYTHONQT_WRAP_Qtsvg
PythonQt_init_QtSvg(0);
#endif
#ifdef PYTHONQT_WRAP_Qtuitools
PythonQt_init_QtUiTools(0);
#endif
#ifdef PYTHONQT_WRAP_Qtwebkit
PythonQt_init_QtWebKit(0);
#endif
#ifdef PYTHONQT_WRAP_Qtxml
PythonQt_init_QtXml(0);
#endif
#ifdef PYTHONQT_WRAP_Qtxmlpatterns
PythonQt_init_QtXmlPatterns(0);
#endif
#ifdef PYTHONQT_WRAP_Qtphonon
PythonQt_init_QtPhonon(0);
#endif
};
#ifndef _PYTHONQT_QTBINDINGS_H
#define _PYTHONQT_QTBINDINGS_H
#include "PythonQtSystem.h"
/// Initialize Qt bindings enabled at configuration time
PYTHONQT_EXPORT void PythonQt_init_QtBindings();
#endif
HEADERS += \
$$PWD/com_trolltech_qt_core0.h \
$$PWD/com_trolltech_qt_core1.h \
$$PWD/com_trolltech_qt_core2.h \
SOURCES += \
$$PWD/com_trolltech_qt_core0.cpp \
$$PWD/com_trolltech_qt_core1.cpp \
$$PWD/com_trolltech_qt_core2.cpp \
$$PWD/com_trolltech_qt_core_init.cpp
HEADERS += \
$$PWD/com_trolltech_qt_core_builtin0.h \
SOURCES += \
$$PWD/com_trolltech_qt_core_builtin0.cpp \
$$PWD/com_trolltech_qt_core_builtin_init.cpp
#include <PythonQt.h>
#include "com_trolltech_qt_core_builtin0.h"
void PythonQt_init_QtCoreBuiltin(PyObject* module) {
PythonQt::priv()->registerCPPClass("QBitArray", "", "QtCore", PythonQtCreateObject<PythonQtWrapper_QBitArray>, NULL, module, PythonQt::Type_And|PythonQt::Type_NonZero|PythonQt::Type_InplaceXor|PythonQt::Type_InplaceOr|PythonQt::Type_Xor|PythonQt::Type_RichCompare|PythonQt::Type_Or|PythonQt::Type_InplaceAnd|PythonQt::Type_Invert);
PythonQt::priv()->registerCPPClass("QByteArray", "", "QtCore", PythonQtCreateObject<PythonQtWrapper_QByteArray>, NULL, module, PythonQt::Type_NonZero|PythonQt::Type_InplaceAdd|PythonQt::Type_RichCompare|PythonQt::Type_Add);
PythonQt::priv()->registerCPPClass("QDate", "", "QtCore", PythonQtCreateObject<PythonQtWrapper_QDate>, NULL, module, PythonQt::Type_NonZero|PythonQt::Type_RichCompare);
PythonQt::priv()->registerCPPClass("QDateTime", "", "QtCore", PythonQtCreateObject<PythonQtWrapper_QDateTime>, NULL, module, PythonQt::Type_NonZero|PythonQt::Type_RichCompare);
PythonQt::priv()->registerCPPClass("QLine", "", "QtCore", PythonQtCreateObject<PythonQtWrapper_QLine>, NULL, module, PythonQt::Type_NonZero|PythonQt::Type_RichCompare|PythonQt::Type_Multiply);
PythonQt::priv()