From 499351faa98edf564403acd5f67950c6ad0c13f6 Mon Sep 17 00:00:00 2001 From: pkk Date: Sun, 3 Jan 2016 00:36:06 +0000 Subject: [PATCH 1/2] pyqt5 bindings --- pyqt/README.md | 23 ++++++++++ pyqt/config-old.py | 85 +++++++++++++++++++++++++++++++++++ pyqt/config.py | 93 +++++++++++++++++++++++++++++++++++++++ pyqt/config.py.in | 0 pyqt/qtermwidget.sip | 86 ++++++++++++++++++++++++++++++++++++ pyqt/qtermwidgetconfig.py | 0 pyqt/test.py | 34 ++++++++++++++ 7 files changed, 321 insertions(+) create mode 100644 pyqt/README.md create mode 100755 pyqt/config-old.py create mode 100755 pyqt/config.py create mode 100644 pyqt/config.py.in create mode 100644 pyqt/qtermwidget.sip create mode 100644 pyqt/qtermwidgetconfig.py create mode 100755 pyqt/test.py diff --git a/pyqt/README.md b/pyqt/README.md new file mode 100644 index 0000000..b3995ce --- /dev/null +++ b/pyqt/README.md @@ -0,0 +1,23 @@ +PyQt4 Bindings for QTermWidget + +By Piotr "Riklaunim" Maliński , + Alexander Slesarev + +PyQt4 QTermWidget Bindings License: GPL3 + +INSTALL: +1. Download QTermWidget from http://qtermwidget.sourceforge.net/. +2. Compile and install it: + $ cmake . + $ make + $ sudo make install +If `make install` command will not work just copy the qtermwidget.so* files to /usr/lib directory. +3. Install PyQt4 and PyQt4-devel if not yet installed. +4. Configure, compile and install bindings. Execute in terminal in the qtermwidget bindings folder: + +$ python config.py +$ make +$ sudo make install + +5. You can run ./test.py to test the installed module. + diff --git a/pyqt/config-old.py b/pyqt/config-old.py new file mode 100755 index 0000000..b5eb76e --- /dev/null +++ b/pyqt/config-old.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# PyQt4 bindings for th QTermWidget project. +# +# Copyright (C) 2009 Piotr "Riklaunim" Maliński , +# Alexander Slesarev +# +# 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 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +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 = "qtermwidget.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, "qtermwidget.sip"])) + +# We are going to install the SIP specification file for this module and +# its configuration module. +installs = [] + +installs.append(["qtermwidget.sip", os.path.join(config.default_sip_dir, + "qtermwidget")]) + +installs.append(["qtermwidgetconfig.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.extra_lib_dirs.append("..") +makefile.extra_libs = ["qtermwidget4"] + +# 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. + "qtermwidget_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. + "qtermwidget_sip_flags": qt_sip_flags} + +# This creates the qtermwidgetconfig.py module from the qtermwidgetconfig.py.in +# template and the dictionary. +sipconfig.create_config_module("qtermwidgetconfig.py", "config.py.in", content) diff --git a/pyqt/config.py b/pyqt/config.py new file mode 100755 index 0000000..70ad215 --- /dev/null +++ b/pyqt/config.py @@ -0,0 +1,93 @@ +import os +import sipconfig +import subprocess +import os +import site +import pprint +from distutils import sysconfig +import pyqtconfig +from PyQt5 import QtCore +import PyQt5 + +class Configuration(sipconfig.Configuration): + """The class that represents PyQt configuration values. + """ + def getEnv(self,name, default): + return os.environ.get(name) or default + + def __init__(self): + qtconfig = subprocess.check_output(["/usr/lib64/qt5/bin/qmake", "-query"], universal_newlines=True) + qtconfig = dict(x.split(":", 1) for x in qtconfig.splitlines()) + + self.pyQtIncludePath = self.getEnv('PYQT_INCLUDE_PATH','/usr/share/sip/PyQt5' ) + + pyqtconfig = { + "pyqt_config_args": "--confirm-license -v "+str(self.pyQtIncludePath)+" --qsci-api -q /usr/lib64/qt5/bin/qmake", + "pyqt_version": QtCore.PYQT_VERSION, + "pyqt_version_str": QtCore.PYQT_VERSION_STR, + "pyqt_bin_dir": PyQt5.__path__[0], + "pyqt_mod_dir": PyQt5.__path__[0], + "pyqt_sip_dir": str(self.pyQtIncludePath), + "pyqt_modules": "QtCore QtGui QtWidgets", #... and many more + "pyqt_sip_flags": QtCore.PYQT_CONFIGURATION['sip_flags'], + "qt_version": QtCore.QT_VERSION, + "qt_edition": "free", + "qt_winconfig": "shared", + "qt_framework": 0, + "qt_threaded": 1, + "qt_dir": qtconfig['QT_INSTALL_PREFIX'], + "qt_data_dir": qtconfig['QT_INSTALL_DATA'], + "qt_archdata_dir": qtconfig['QT_INSTALL_DATA'], + "qt_inc_dir": qtconfig['QT_INSTALL_HEADERS'], + "qt_lib_dir": qtconfig['QT_INSTALL_LIBS'] + } + + macros = sipconfig._default_macros.copy() + macros['INCDIR_QT'] = qtconfig['QT_INSTALL_HEADERS'] + macros['LIBDIR_QT'] = qtconfig['QT_INSTALL_LIBS'] + macros['MOC'] = os.path.join(qtconfig['QT_INSTALL_BINS'], 'moc') + + sipconfig.Configuration.__init__(self, [pyqtconfig]) + self.set_build_macros(macros) + + +## The name of the SIP build file generated by SIP and used by the build system. +build_file = "qtermwidget.sbf" + +# Get the SIP configuration information. +config = Configuration() + +# Run SIP to generate the build_file +os.system(" ".join([config.sip_bin, '-I' , str(config.pyQtIncludePath), str(config.pyqt_sip_flags), "-b", build_file,"-o", "-c", ". " " qtermwidget.sip"])) + +installs = [] +installs.append(["qtermwidget.sip", os.path.join(config.pyqt_sip_dir,"qtermwidget")]) +installs.append(["qtermwidgetconfig.py", config.pyqt_mod_dir]) + +makefile = sipconfig.SIPModuleMakefile( configuration = config, build_file = build_file, installs = installs, qt=["QtCore" ,"QtGui", "QtWidgets"] ) + +# 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.extra_lib_dirs.append("../lib/") +makefile.extra_lib_dirs.append("..") +makefile.extra_libs = ["qtermwidget5"] + +# Generate the Makefile itself. +makefile.generate() + +content = { + # Publish where the SIP specifications for this module will be + # installed. + "qtermwidget_sip_dir": config.pyqt_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. + "qtermwidget_sip_flags": config.pyqt_sip_flags + } + +# This creates the qtermwidgetconfig.py module from the qtermwidgetconfig.py.in +# template and the dictionary. +sipconfig.create_config_module("qtermwidgetconfig.py", "config.py.in", content) diff --git a/pyqt/config.py.in b/pyqt/config.py.in new file mode 100644 index 0000000..e69de29 diff --git a/pyqt/qtermwidget.sip b/pyqt/qtermwidget.sip new file mode 100644 index 0000000..51a4f80 --- /dev/null +++ b/pyqt/qtermwidget.sip @@ -0,0 +1,86 @@ +%Module QTermWidget + + + + +%Import QtGui/QtGuimod.sip +%Import QtCore/QtCoremod.sip +%Import QtWidgets/QtWidgetsmod.sip + +class QTermWidget : QWidget { + +%TypeHeaderCode +#include <../lib/qtermwidget.h> +%End + +public: + enum ScrollBarPosition + { + NoScrollBar=0, + ScrollBarLeft=1, + ScrollBarRight=2 + }; + + QTermWidget(int startnow = 1, QWidget *parent = 0); + ~QTermWidget(); + + QSize sizeHint() const; + void startShellProgram(); + int getShellPID(); + void changeDir(const QString & dir); + void setTerminalFont(QFont &font); + QFont getTerminalFont(); + void setTerminalOpacity(qreal level); + void setEnvironment(const QStringList & environment); + void setShellProgram(const QString & progname); + void setWorkingDirectory(const QString & dir); + QString workingDirectory(); + void setArgs(QStringList &args); + void setTextCodec(QTextCodec *codec); + void setColorScheme(const QString & name); + static QStringList availableColorSchemes(); + void setHistorySize(int lines); + void setScrollBarPosition(ScrollBarPosition); + void scrollToEnd(); + void sendText(QString &text); + void setFlowControlEnabled(bool enabled); + bool flowControlEnabled(); + void setFlowControlWarningEnabled(bool enabled); + static QStringList availableKeyBindings(); + QString keyBindings(); + void setMotionAfterPasting(int); + int historyLinesCount(); + int screenColumnsCount(); + void setSelectionStart(int row, int column); + void setSelectionEnd(int row, int column); + void getSelectionStart(int& row, int& column); + void getSelectionEnd(int& row, int& column); + QString selectedText(bool preserveLineBreaks = true); + void setMonitorActivity(bool); + void setMonitorSilence(bool); + void setSilenceTimeout(int seconds); +signals: + void finished(); + void copyAvailable(bool); + void termGetFocus(); + void termLostFocus(); + void termKeyPressed(QKeyEvent *); + void urlActivated(const QUrl&); + void bell(const QString& message); + void activity(); + void silence(); +public slots: + void copyClipboard(); + void pasteClipboard(); + void pasteSelection(); + void zoomIn(); + void zoomOut(); + void setKeyBindings(const QString & kb); + void clear(); + void toggleShowSearchBar(); + void setSize(const QSize&); +protected: + void resizeEvent(QResizeEvent *e); +private: + void *createTermWidget(int startnow, void *parent); +}; diff --git a/pyqt/qtermwidgetconfig.py b/pyqt/qtermwidgetconfig.py new file mode 100644 index 0000000..e69de29 diff --git a/pyqt/test.py b/pyqt/test.py new file mode 100755 index 0000000..8d82f20 --- /dev/null +++ b/pyqt/test.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# PyQt4 bindings for th QTermWidget project. +# +# Copyright (C) 2009 Piotr "Riklaunim" Maliński , +# Alexander Slesarev +# +# 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 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import sys, signal +from PyQt5 import QtCore,QtWidgets + +import QTermWidget + +signal.signal(signal.SIGINT, signal.SIG_DFL) +a = QtWidgets.QApplication(sys.argv) + +w = QTermWidget.QTermWidget() +w.finished.connect(a.quit) +w.show() + +a.exec_() \ No newline at end of file From 504f014939dc301be24cf2d7fc57458b47feb336 Mon Sep 17 00:00:00 2001 From: pkk Date: Sun, 3 Jan 2016 00:42:01 +0000 Subject: [PATCH 2/2] pyqt5 bindings --- pyqt/README.md | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/pyqt/README.md b/pyqt/README.md index b3995ce..71e8758 100644 --- a/pyqt/README.md +++ b/pyqt/README.md @@ -1,23 +1,34 @@ -PyQt4 Bindings for QTermWidget +PyQt5 Bindings for QTermWidget +============================== -By Piotr "Riklaunim" Maliński , - Alexander Slesarev -PyQt4 QTermWidget Bindings License: GPL3 +INSTALL: +------------ +####1. Download QTermWidget -> https://github.com/lxde/qtermwidget + +####2. Compile and install it: + $ mkdir build && cd build + $ cmake .. + $ make + $ sudo make install +If `make install` command will not work just copy the `qtermwidget.so*` files to /usr/lib directory. +####3. Install PyQt5 and PyQt5-devel if not yet installed. +####4. Configure, compile and install bindings. Execute in terminal in the qtermwidget bindings folder: -INSTALL: -1. Download QTermWidget from http://qtermwidget.sourceforge.net/. -2. Compile and install it: - $ cmake . - $ make - $ sudo make install -If `make install` command will not work just copy the qtermwidget.so* files to /usr/lib directory. -3. Install PyQt4 and PyQt4-devel if not yet installed. -4. Configure, compile and install bindings. Execute in terminal in the qtermwidget bindings folder: + $ python config.py + $ make + $ sudo make install -$ python config.py -$ make -$ sudo make install +####5. You can run ./test.py to test the installed module. -5. You can run ./test.py to test the installed module. + +ABOUT: +--------- +Based on previous PyQt4 bindings by: +- Piotr "Riklaunim" Maliński , +- Alexander Slesarev + + +PyQt5 QTermWidget Bindings +License: GPL3