+11
-9
@@ -4,31 +4,33 @@ PyQt5 Bindings for QTermWidget
|
||||
|
||||
INSTALL:
|
||||
------------
|
||||
####1. Download QTermWidget -> https://github.com/lxde/qtermwidget
|
||||
|
||||
####2. Compile and install it:
|
||||
$ mkdir build && cd build
|
||||
####1. Download, compile and install QTermWidget:
|
||||
$ git clone https://github.com/lxde/qtermwidget.git
|
||||
$ cd qtermwidget && 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:
|
||||
|
||||
$ python config.py
|
||||
####2. Install PyQt5 and PyQt5-devel if not yet installed.
|
||||
####3. Configure, compile and install Python bindings. Execute in terminal in the qtermwidget bindings folder:
|
||||
$ cd pyqt/
|
||||
$ QT_SELECT=5 python config.py
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
####5. You can run ./test.py to test the installed module.
|
||||
####4. You can run ./test.py to test the installed module.
|
||||
|
||||
|
||||
ABOUT:
|
||||
---------
|
||||
Curently maintained by:
|
||||
- Pawel Koston <pawelkoston@gmail.com>
|
||||
|
||||
Based on previous PyQt4 bindings by:
|
||||
- Piotr "Riklaunim" Maliński <riklaunim@gmail.com>,
|
||||
- Alexander Slesarev <alex.slesarev@gmail.com>
|
||||
|
||||
|
||||
PyQt5 QTermWidget Bindings
|
||||
License: GPL3
|
||||
|
||||
|
||||
+59
-48
@@ -5,66 +5,74 @@ 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
|
||||
"""The class that represents PyQt configuration values.
|
||||
"""
|
||||
|
||||
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())
|
||||
def getEnv(self, name, default):
|
||||
return os.environ.get(name) or default
|
||||
|
||||
self.pyQtIncludePath = self.getEnv('PYQT_INCLUDE_PATH','/usr/share/sip/PyQt5' )
|
||||
def __init__(self):
|
||||
qmake_bin = subprocess.check_output(
|
||||
["which", "qmake"], universal_newlines=True).strip(' \t\n\r')
|
||||
qtconfig = subprocess.check_output(
|
||||
[qmake_bin, "-query"], universal_newlines=True)
|
||||
qtconfig = dict(x.split(":", 1) for x in qtconfig.splitlines())
|
||||
|
||||
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']
|
||||
}
|
||||
self.pyQtIncludePath = self.getEnv(
|
||||
'PYQT_INCLUDE_PATH', '/usr/share/sip/PyQt5')
|
||||
|
||||
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')
|
||||
pyqtconfig = {
|
||||
"pyqt_config_args": "--confirm-license -v " + str(self.pyQtIncludePath) + " --qsci-api -q " + qmake_bin,
|
||||
"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']
|
||||
}
|
||||
|
||||
sipconfig.Configuration.__init__(self, [pyqtconfig])
|
||||
self.set_build_macros(macros)
|
||||
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.
|
||||
# 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"]))
|
||||
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(["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"] )
|
||||
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
|
||||
@@ -73,20 +81,23 @@ makefile.extra_lib_dirs.append("../lib/")
|
||||
makefile.extra_lib_dirs.append("..")
|
||||
makefile.extra_libs = ["qtermwidget5"]
|
||||
|
||||
# Support for C++11
|
||||
makefile.extra_cxxflags.append('-std=c++11')
|
||||
|
||||
# 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 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
|
||||
}
|
||||
# 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.
|
||||
|
||||
+33
-8
@@ -1,8 +1,6 @@
|
||||
%Module QTermWidget
|
||||
|
||||
|
||||
|
||||
|
||||
%Import QtGui/QtGuimod.sip
|
||||
%Import QtCore/QtCoremod.sip
|
||||
%Import QtWidgets/QtWidgetsmod.sip
|
||||
@@ -21,9 +19,16 @@ public:
|
||||
ScrollBarRight=2
|
||||
};
|
||||
|
||||
enum KeyboardCursorShape
|
||||
{
|
||||
BlockCursor=0,
|
||||
UnderlineCursor=1,
|
||||
IBeamCursor=2
|
||||
};
|
||||
|
||||
QTermWidget(int startnow = 1, QWidget *parent = 0);
|
||||
~QTermWidget();
|
||||
|
||||
void startTerminalTeletype();
|
||||
QSize sizeHint() const;
|
||||
void startShellProgram();
|
||||
int getShellPID();
|
||||
@@ -35,10 +40,11 @@ public:
|
||||
void setShellProgram(const QString & progname);
|
||||
void setWorkingDirectory(const QString & dir);
|
||||
QString workingDirectory();
|
||||
void setArgs(QStringList &args);
|
||||
void setArgs(QStringList & args);
|
||||
void setTextCodec(QTextCodec *codec);
|
||||
void setColorScheme(const QString & name);
|
||||
static QStringList availableColorSchemes();
|
||||
static void addCustomColorSchemeDir(const QString& custom_dir);
|
||||
void setHistorySize(int lines);
|
||||
void setScrollBarPosition(ScrollBarPosition);
|
||||
void scrollToEnd();
|
||||
@@ -59,28 +65,47 @@ public:
|
||||
void setMonitorActivity(bool);
|
||||
void setMonitorSilence(bool);
|
||||
void setSilenceTimeout(int seconds);
|
||||
int getPtySlaveFd() const;
|
||||
void setKeyboardCursorShape(KeyboardCursorShape shape);
|
||||
void setAutoClose(bool);
|
||||
QString title() const;
|
||||
QString icon() const;
|
||||
signals:
|
||||
void finished();
|
||||
void copyAvailable(bool);
|
||||
void termGetFocus();
|
||||
void termLostFocus();
|
||||
void termKeyPressed(QKeyEvent *);
|
||||
void urlActivated(const QUrl&);
|
||||
void urlActivated(const QUrl&, bool fromContextMenu);
|
||||
void bell(const QString& message);
|
||||
void activity();
|
||||
void silence();
|
||||
void sendData(const char *,int);
|
||||
void titleChanged();
|
||||
void receivedData(const QString &text);
|
||||
public slots:
|
||||
void copyClipboard();
|
||||
void pasteClipboard();
|
||||
void pasteSelection();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void setSize(const QSize &);
|
||||
void setKeyBindings(const QString & kb);
|
||||
void clear();
|
||||
void toggleShowSearchBar();
|
||||
void setSize(const QSize&);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
virtual void resizeEvent(QResizeEvent *);
|
||||
protected slots:
|
||||
void sessionFinished();
|
||||
void selectionChanged(bool textSelected);
|
||||
private:
|
||||
void *createTermWidget(int startnow, void *parent);
|
||||
void search(bool forwards, bool next);
|
||||
void setZoom(int step);
|
||||
void init(int startnow);
|
||||
private slots:
|
||||
void find();
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
void matchFound(int startColumn, int startLine, int endColumn, int endLine);
|
||||
void noMatchFound();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user