Coder Social home page Coder Social logo

mevislab / pythonqt Goto Github PK

View Code? Open in Web Editor NEW
244.0 18.0 89.0 22.09 MB

Dynamic Python binding for Qt Applications

Home Page: https://mevislab.github.io/pythonqt/

License: GNU Lesser General Public License v2.1

QMake 0.05% Batchfile 0.01% C++ 99.91% CMake 0.01% C 0.04% Shell 0.01% Vim Script 0.01%
python qt

pythonqt's Introduction

PythonQt

License

PythonQt is a dynamic Python binding for Qt. It offers an easy way to embed the Python scripting language into your Qt applications.

Documentation

API documentation is available at: https://mevislab.github.io/pythonqt

Licensing

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 https://code.qt.io/cgit/qt-labs/qtscriptgenerator.git 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, 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.

Building

General

Building PythonQt requires a couple of steps. Follow these instructions in order to get a correctly built PythonQt runtime and Qt bindings.

Recommendations

It is recommended to build the Qt bindings yourself instead of using the pregenerated ones. This ensures the bindings are compatible with your Qt version. Do not build PythonQt.pro directly because it will only use the pregenerated bindings!

Environment

First, you need to set a couple of environment variables, which depend on your Python and Qt installation.

  • PYTHON_VERSION

    Set the version of your Python interpreter. The syntax is <major>.<minor>, e.g., 3.10.

  • PYTHON_PATH

    This is the absolute path to the root directory of your Python installation.

  • PYTHON_LIB

    The absolute path to the libs directory in your python installation $PYTHON_PATH/libs.

  • PYTHON_DIR

    The PYTHON_DIR is required for non-Windows installations to find the python-config executable. This should have the same value as PYTHON_PATH.

  • QTDIR

    The absolute path to the root directory of your Qt installation.

Binding Generator

  1. cd into the generator directory

  2. Run qmake on generator.pro

    qmake CONFIG+=Release generator.pro

  3. Make the generator

    Use nmake for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use make.

  4. Generate the bindings

    We use the generator executable from step 3 to generate the bindings. The location of the generator executable can vary depending on your platform (the subdirectory is named after the current configuration, e.g., release). On Windows, the generator is named pythonqt_generator.exe; on all other platforms, it is named pythonqt_generator.

    <generator-executable> qtscript_masterinclude.h build_all.txt

PythonQt Runtime

Next, we need the PythonQt runtime.

  1. cd into the src directory

  2. qmake src.pro

    qmake CONFIG+=Release src.pro

  3. Make the runtime

    Use nmake for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use make.

Extensions

As a last step, we need to build the extensions.

  1. cd into extensions

  2. qmake src.pro

    qmake CONFIG+=Release extensions.pro

  3. Make the extensions

    Use nmake for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use make.

After all these steps, you should now have a fully working PythonQt runtime and Qt bindings for your Python/Qt installation 🎉.

MinGW

It is possible to build PythonQt with MinGW on Windows instead of using MSVC.

pythonqt's People

Contributors

dbrnz avatar dependabot[bot] avatar felixpetriconi avatar florianlink avatar githubuser0xffff avatar gregor-anich-uibk avatar he-hesce avatar iakov avatar jbowler avatar krop avatar lassoan avatar minyazevr avatar mrbean-bremen avatar nim65s avatar richard42 avatar sboehmann avatar tonka3000 avatar usiems avatar yuriufimtsev avatar yurivict avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pythonqt's Issues

Failing to execute Example: No module named 'encodings'

I tried to use pythonqt and to execute one of the examples. I used a preinstalled python 3.8 version without debug symbols or anything else. In Debug mode I'm getting a linker error that a python3.8_d.dll library is missing (#4 Ensure PYTHONQT_USE_RELEASE_PYTHON_FALLBACK works as expected ). In Release mode I can build the library and start the application, but I get the error below. I compared the sys paths between here and when executing python in a console and there I see that the path to Python38\Lib\site-packages is missing. I don't know if it is the problem.

Qt: 5.12.10, Mingw 7.3
Windows 10
Python 3.8
PythonQt commit: 9ea0fcf (latest commit on master)

Python path configuration:
PYTHONHOME = 'C:\Qt\Tools\mingw730_64\bin..\opt'
PYTHONPATH = 'AppData\Local\Programs\Python\Python38'
program name = 'PythonQtTest'
isolated = 0
environment = 1
user site = 1
import site = 0
sys._base_executable = 'build-PythonQt-Desktop_Qt_5_12_10_MinGW_64_bit-Release\lib\PyScriptingConsole.exe'
sys.base_prefix = 'C:\Qt\Tools\mingw730_64\bin\..\opt'
sys.base_exec_prefix = 'C:\Qt\Tools\mingw730_64\bin\..\opt'
sys.executable = 'build-PythonQt-Desktop_Qt_5_12_10_MinGW_64_bit-Release\lib\PyScriptingConsole.exe'
sys.prefix = 'C:\Qt\Tools\mingw730_64\bin\..\opt'
sys.exec_prefix = 'C:\Qt\Tools\mingw730_64\bin\..\opt'
sys.path = [
'AppData\Local\Programs\Python\Python38',
'AppData\Local\Programs\Python\Python38\python38.zip',
'C:\Qt\Tools\mingw730_64\bin\..\opt\DLLs',
'C:\Qt\Tools\mingw730_64\bin\..\opt\lib',
build-PythonQt-Desktop_Qt_5_12_10_MinGW_64_bit-Release\lib',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000114 (most recent call first):

Fatal Python error:
failed to get the Python codec of the filesystem encoding

Build fails with Python 3.8 on Ubuntu 20.04

Dear PythonQt community,

I have been using PythonQt for years with Python 2.7 and Python 3.6. I am now trying to build our project with Python 3.8 on Ubuntu 20.04. However, I get a compilation error as outlined further below. I am using the as of today latest code on master branch, committish 9ea0fcf of 2 December 2020. Am I missing something or is this an issue in PythonQt trunk or an issue with Ubuntu 20.04?

I would very much appreciate the community's and the developers' insight. I very much would like to use the native Ubuntu 20.04 Python and not compile and maintain my own installation.

Thank you.

Relevant error message from compiler:

In file included from /usr/include/python3.8/pystate.h:10,
                 from /usr/include/python3.8/genobject.h:11,
                 from /usr/include/python3.8/Python.h:121,
                 from ../../libsrc/PythonQt/src/PythonQtPythonInclude.h:59,
                 from ../../libsrc/PythonQt/src/PythonQt.h:45,
                 from [censored]
/usr/include/python3.8/pythread.h:128:5: error: #error "Require native threads. See https://bugs.python.org/issue31370"
  128 | #   error "Require native threads. See https://bugs.python.org/issue31370"
      |     ^~~~~
/usr/include/python3.8/pythread.h:137:5: error: ‘NATIVE_TSS_KEY_T’ does not name a type
  137 |     NATIVE_TSS_KEY_T _key;
      |     ^~~~~~~~~~~~~~~~

Contribute PythonQt support to Qt.py and/or QtPy

There are two lightweight uniform APIs that lets users write Python code that interfaces with Qt regardless of the actual Python-Qt binding:

They both have similar names, which is confusing, and both currently support PySide2, PyQt5 and the older versions of PySide and PyQt4. Both seem reasonably active, neither supports PythonQt.

I’m not sure how much work it would take to contribute support for PythonQt to either of these packages, but it would be terrific if some volunteer made the effort.

Compile Failed in macOS using QtCreator

I add the path of Python.h in PythonQt.pro

INCLUDEPATH += /Users/../anaconda3/include/python3.7m

but I still have three problems . What code I need to add to fix these problems for compile?

PythonQtConversion.o:-1: error: Undefined symbols for architecture x86_64:
  "_PyBytes_FromStringAndSize", referenced from:
      PythonQtInstanceWrapper_str(_object*) in PythonQtInstanceWrapper.o
      PythonQtWrapper_QByteArray::data(QByteArray*) in moc_com_trolltech_qt_core_builtin0.o
  "_PyBytes_Type", referenced from:
      PythonQtConv::ConvertPythonToQt(PythonQtMethodInfo::ParameterInfo const&, _object*, bool, PythonQtClassInfo*, void*, PythonQtArgumentFrame*) in PythonQtConversion.o
      PythonQtConv::PyObjToStringList(_object*, bool, bool&) in PythonQtConversion.o
  "_PyImport_ExecCodeModuleObject", referenced from:
      PythonQtImporter_load_module(_object*, _object*) in PythonQtImporter.o
  "_PyMapping_Items", referenced from:
      bool PythonQtConvertPythonToIntegerMap<QMap<int, QByteArray>, QByteArray>(_object*, void*, int, bool) in PythonQt.o
      bool PythonQtConvertPythonToIntegerMap<QMap<int, QVariant>, QVariant>(_object*, void*, int, bool) in PythonQt.o
      bool PythonQtConvertPythonToIntegerMap<QMap<int, QString>, QString>(_object*, void*, int, bool) in PythonQt.o
      bool PythonQtConvertPythonToIntegerMap<QHash<int, QByteArray>, QByteArray>(_object*, void*, int, bool) in PythonQt.o
      bool PythonQtConvertPythonToIntegerMap<QHash<int, QVariant>, QVariant>(_object*, void*, int, bool) in PythonQt.o
      bool PythonQtConvertPythonToIntegerMap<QHash<int, QString>, QString>(_object*, void*, int, bool) in PythonQt.o
      void PythonQtConv::pythonToMapVariant<QMap<QString, QVariant> >(_object*, QVariant&) in PythonQtConversion.o

:-1: error: symbol(s) not found for architecture x86_64
:-1: error: linker command failed with exit code 1 (use -v to see invocation)

no quit() function available

Hey,

I try to use the python builtin quit() function, but I always get not defined. Is there any possibility to activate that when python is embedded?

Greetings
Tonka

Get slot information from PythonQt object

Hey @florianlink , @sboehmann ,

I've try to build a .pyi stub file (PEP 484) generator for the PythonQt module. I have to introspect the objects via dir function, but that's the same approach as PySide2 has. My main problem is that I can not get the slots information to get all overloads (and also not from __init__). When I call and PythonQt function wrong, I always get an ValueError with the possible slots, which would be exactly the content I need, but throw an exception for every PythonQt module, class, method, etc. is extremely slow.

Is there any possiblity (maybe via patch) to get to this information without raising an error per PythonQt object?

The information seems to be stored in PythonQtSlot.cpp.

Any idea, help?

Thanks in advance

Tonka

How to generate under Qt 5.15.2 and 6?

How to generate code for Qt 5.15.2 and 6?
My generator is not working properly:

Please wait while source files are being generated...
Parsing typesystem file [:/trolltech/generator/build_all.txt]
Fatal error: line=1, column=1, message=unexpected end of file

Fatal error: line=2, column=62, message=Failed to parse: 'typesystem_core.xml'

Cannot parse file: ':/trolltech/generator/build_all.txt'

How to fix it, is it a problem of this project? And how to create your own configuration (.xml) files?

And another question. I would like to control which functions can be used in Python.
That is, the ability to cut out functions so that they cannot be used. Is it possible with this generator?

Release build not working

Hey folks,

Glad I found this page! So I've been trying to build PythonQt in release mode, to no avail. Debug mode builds A-okay for me. My error and background info is described here:

https://sourceforge.net/p/pythonqt/discussion/631393/thread/6aff8d8e64/?limit=25#96ba

Additionally, I am building PythonQt as a static library, using MSVC 2017.

Is there any documentation on what the build process for PythonQt is actually doing? It's hard to debug why I'm getting a debug/release mismatch when I don't really know what the generator is doing. I'm not a stranger to make (either with GNU make or visual studio), but it's a bit tough to follow.

I'm not sure how much PythonQt has changed in the past year, but my version is from August of 2019.

Fix potential crash when cleaning up

Hi,
since this is a small change and maybe not the last, I create an issue instead of pull request. Since my use case requires starting over with a fresh (empty) context for the python interpreter very often during a single run of my software, I investigate dynamic memory leaks (using valgrind/massif). In order to free all memory used by Python and PythonQt, I use the following sequence:
PythonQt::cleanup(); PyGC_Collect(); Py_Finalize();
In order to free the type objects created by PythonQtPrivate::createNewPythonQtEnumWrapper() one needs to call the garbage collector which will in turn call PythonQtInstanceWrapper_deleteObject which will crash in PythonQtInstanceWrapper.cpp:95 PythonQt::priv()->removeWrapperPointer(self->_objPointerCopy); because the priv() was deleted by PythonQt::cleanup() so one needs to add a check for PythonQt::self() && PythonQt::priv() in PythonQtInstanceWrapper.cpp:94
I do still have some dynamic leaks but am not yet sure whether they are issues of PythonQt or Python, I would be happy if someone else wants to join looking for those leaks, otherwise I will post again when I find more and fixed them and eventually submit a pull request if I manage to fix them all.
Greetings,
Gregor

super() does not work for Qt classes

I just want to share some insights into this issue, I currently have no intention to fix the issue, as that would be somewhat complicated.

This is an example of what does not work:

from PythonQt.QtGui import QDoubleValidator

class MyFunnyValidator(QDoubleValidator):
  def setRange(self, minimum, maximum, decimals):
    super().setRange(minimum, maximum, decimals+1)

The problem boils down to the fact that the method lookup of super() directly accesses the internal tp_dict member of the super classes, which is only filled to an absolute minimum by PythonQt (for performance reasons). Everything else is delivered through tp_getattro calls, but this does not work for super.

I discussed with Florian Link what would have to be done to fill the tp_dict.

  • This would probably need to happen in PythonQtInstanceWrapper_init the first time an instance of the class is created.
  • One could have a look at PythonQtClassWrapper_getattro how this is done, where the __dict__ member is dynamically filled.
  • But one would have to have in mind that QObject class wrappers can get updated methods when, e.g., the Qt bindings are loaded, so the class tp_dict would have to be updated then or at least flushed.
  • There might be other unforeseen consequences.

We both agreed that this change is somewhat tricky and probably currently not worthwhile.

Parsing error during wrapper generation with Qt5.15

I tried to generate the wrapper with the generator with Qt5.15, but I encountered the following message:

PS D:\dev-ext\src\pythonqt-mevislab_fork\generator\release> .\pythonqt_generator.exe
Please wait while source files are being generated...
Parsing typesystem file [:/trolltech/generator/build_all.txt]
Fatal error: line=1, column=1, message=unexpected end of file
Fatal error: line=2, column=62, message=Failed to parse: 'typesystem_core.xml'
Cannot parse file: ':/trolltech/generator/build_all.txt'

After running it in debug, the culprit seems to be QXmlSimpleReader::parse in TypeDatabase::parseFile, which may work differently in Qt5.15 compared to previous versions.

bind C++ function

Hi,

There are examples and tests demonstrating how to bind C++ class but is there a way to bind C++ function?
For example I have:

namespace ns{

bool foo(QString &str){ return true; }

}

How would look PythonQt code to bind this function in ns python package?

how to use pythran add a myfunction from other py files?

toolsTep.py

def HelloWord():
    print('hello word')

testpythran.py

from calaTools.toolsTep import *
#pythran export callOtherPyFiles()
def callOtherPyFiles():
    HelloWord()

complie pythran testpythran.py

  • CRITICAL :
    I am in trouble. Your input file does not seem to match Pythran's constraints...
  • testpythran.py:

    None:None error: Module 'calaTools.toolsTep' not found.

when tow function in save file and it can find ,in diffrent file it occured those errors

Need for a fresh tag

Hello,

We are currently working on integrating pythonqt in our Simcenter System Architect product which is a Qt based application. This integration will allow us to pilot our GUI in order to create and execute integration tests.

We are currently relying on the master for our development however we will required a tag to comply to our Siemens OSS clearance process. There is currently no tag of python Qt and the last 3.2 branch is four years old which is too bad.

Is-it possible to create a fresh tag?

Using PythonQt with portable Interpreter

Hey there,
i was wondering if anyone knows if i can build PythonQt with a portable Interpreter e.g. cpython. or already has experience with. Mainly it seems to be more to do than just handling paths in the python.prf?
Or is there a way i can just set a path for a specific interpreter in c++?
Thank you for this great Library!
Frederik

crashed when calling PythonQtObjectPtr::evalFile with a local disk file

I compiled PythonQt with mingw-g++ 7.3.0, and python 2.7 which I am not sure with the compiler(mostly it is vc). Everything works fine, except crashed when I tried to call PythonQtObjectPtr::evalFile like evalFile("example.py").
I googled and found this post, https://sourceforge.net/p/pythonqt/discussion/631393/thread/65f9a4af/, it seems a known issue but has not resolved.
Any update on it? or any standard solution for this issue?

About WId type

能把 qRegisterMetaType("WId"); 加入 PythonQt::init吗?
现在调用QWindow.fromWinId 提示:
PythonQt: Can't create a copy of WId, either use qRegisterMetaType() or add a copy constructor to the decorator/wrapper.

QString <-> Python conversion, null/None

Hello,

I use a custom wrapper to provide operators etc for a class. I also provide the py_toString function. Problem is if I return an empty string, then PythonQtInstanceWrapper_str returns the default ("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr).
I was wondering if it would be a good idea to convert a null QString to None and vice versa, but I think this could be a too invasive change breaking existing code, what do you think?
Another option would probably be to make getStringFromObject in PythonQtInstanceWrapper.cpp return a "bool ok" to signal that an empty string was returned by the wrapper, and then not fallback to the default string.

Edit: I chose the second option, see commit bc70661

QList<bool> support

Hi @florianlink ,

Is there a special reason why QList<bool> is not supported or is it just missing? I could not find it in PythonQt.cpp

I got following error today

ValueError: Called getValues() -> QList<bool>, return type 'QList<bool>' is ignored because it is unknown to PythonQt. Probably you should register it using qRegisterMetaType() or add a default constructor decorator to the class.

Thanks in advance

Michael

Build broken after python update to 3.8

After updating python from 3.7 to 3.8, a re-build of libPythonQt_QtAll-Qt5-Python3.so.3.2.0 is still trying to resolve libpython3.7m.so.1.0 which, of course, no longer exists.

ldd libPythonQt_QtAll-Qt5-Python3.so.3.2.0

    linux-vdso.so.1 (0x00007ffe340b2000)
    libPythonQt-Qt5-Python3.so.3 => /usr/lib/libPythonQt-Qt5-Python3.so.3 (0x00007f570fbd9000)
    libQt5Svg.so.5 => /usr/lib/libQt5Svg.so.5 (0x00007f570fb80000)
    libQt5OpenGL.so.5 => /usr/lib/libQt5OpenGL.so.5 (0x00007f570fb27000)
    libQt5PrintSupport.so.5 => /usr/lib/libQt5PrintSupport.so.5 (0x00007f570fab2000)
    libQt5MultimediaWidgets.so.5 => /usr/lib/libQt5MultimediaWidgets.so.5 (0x00007f570fa92000)
    libQt5QuickWidgets.so.5 => /usr/lib/libQt5QuickWidgets.so.5 (0x00007f570fa7c000)
    libQt5WebKitWidgets.so.5 => /usr/lib/libQt5WebKitWidgets.so.5 (0x00007f570fa2e000)
    libQt5Widgets.so.5 => /usr/lib/libQt5Widgets.so.5 (0x00007f570f396000)
    libQt5Multimedia.so.5 => /usr/lib/libQt5Multimedia.so.5 (0x00007f570f280000)
    libQt5Quick.so.5 => /usr/lib/libQt5Quick.so.5 (0x00007f570edb2000)
    libQt5WebKit.so.5 => /usr/lib/libQt5WebKit.so.5 (0x00007f570bd43000)
    libQt5Gui.so.5 => /usr/lib/libQt5Gui.so.5 (0x00007f570b75f000)
    libQt5Sql.so.5 => /usr/lib/libQt5Sql.so.5 (0x00007f570b70f000)
    libQt5XmlPatterns.so.5 => /usr/lib/libQt5XmlPatterns.so.5 (0x00007f570b330000)
    libQt5Qml.so.5 => /usr/lib/libQt5Qml.so.5 (0x00007f570ae54000)
    libQt5Network.so.5 => /usr/lib/libQt5Network.so.5 (0x00007f570ac99000)
    libQt5Xml.so.5 => /usr/lib/libQt5Xml.so.5 (0x00007f570ac57000)
    libQt5Core.so.5 => /usr/lib/libQt5Core.so.5 (0x00007f570a74a000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f570a55e000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f570a544000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f570a37d000)
    **_libpython3.7m.so.1.0 => not found_**
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f570a237000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f570a21d000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f570a1f9000)
    libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f570a165000)
    libpulse.so.0 => /usr/lib/libpulse.so.0 (0x00007f570a110000)
    libQt5WebChannel.so.5 => /usr/lib/libQt5WebChannel.so.5 (0x00007f570a0ec000)
    libicuuc.so.65 => /usr/lib/libicuuc.so.65 (0x00007f5709f0a000)
    libQt5Positioning.so.5 => /usr/lib/libQt5Positioning.so.5 (0x00007f5709e72000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f5709d32000)
    libicui18n.so.65 => /usr/lib/libicui18n.so.65 (0x00007f5709a3e000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f5709a39000)
    libQt5Sensors.so.5 => /usr/lib/libQt5Sensors.so.5 (0x00007f57099f7000)
    libwoff2dec.so.1.0.2 => /usr/lib/libwoff2dec.so.1.0.2 (0x00007f57097ec000)
    libjpeg.so.8 => /usr/lib/libjpeg.so.8 (0x00007f5709753000)
    libpng16.so.16 => /usr/lib/libpng16.so.16 (0x00007f570971b000)
    libwebp.so.7 => /usr/lib/libwebp.so.7 (0x00007f57096ab000)
    libhyphen.so.0 => /usr/lib/libhyphen.so.0 (0x00007f57094a5000)
    libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007f570933d000)
    libxslt.so.1 => /usr/lib/libxslt.so.1 (0x00007f57092fc000)
    libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00007f57091ce000)
    libgio-2.0.so.0 => /usr/lib/libgio-2.0.so.0 (0x00007f570901e000)
    libgstapp-1.0.so.0 => /usr/lib/libgstapp-1.0.so.0 (0x00007f570900e000)
    libgstbase-1.0.so.0 => /usr/lib/libgstbase-1.0.so.0 (0x00007f5708f9e000)
    libgstreamer-1.0.so.0 => /usr/lib/libgstreamer-1.0.so.0 (0x00007f5708e90000)
    libgstpbutils-1.0.so.0 => /usr/lib/libgstpbutils-1.0.so.0 (0x00007f5708e5a000)
    libgstaudio-1.0.so.0 => /usr/lib/libgstaudio-1.0.so.0 (0x00007f5708de6000)
    libgsttag-1.0.so.0 => /usr/lib/libgsttag-1.0.so.0 (0x00007f5708dac000)
    libgstvideo-1.0.so.0 => /usr/lib/libgstvideo-1.0.so.0 (0x00007f5708d0b000)
    libgstfft-1.0.so.0 => /usr/lib/libgstfft-1.0.so.0 (0x00007f5708d01000)
    libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007f5708ca5000)
    libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f5708b80000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007f5708b73000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f57112a3000)
    libharfbuzz.so.0 => /usr/lib/libharfbuzz.so.0 (0x00007f5708a6f000)
    libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007f57089df000)
    libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007f570870e000)
    libsystemd.so.0 => /usr/lib/libsystemd.so.0 (0x00007f5708667000)
    libpcre2-16.so.0 => /usr/lib/libpcre2-16.so.0 (0x00007f57085e4000)
    libdouble-conversion.so.3 => /usr/lib/libdouble-conversion.so.3 (0x00007f57085cd000)
    libzstd.so.1 => /usr/lib/libzstd.so.1 (0x00007f5708525000)
    libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007f57084f1000)
    libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f57084dc000)
    libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007f570841c000)
    libpulsecommon-13.0.so => /usr/lib/pulseaudio/libpulsecommon-13.0.so (0x00007f5708398000)
    libdbus-1.so.3 => /usr/lib/libdbus-1.so.3 (0x00007f570834e000)
    libicudata.so.65 => /usr/lib/libicudata.so.65 (0x00007f570689d000)
    libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f5706873000)
    libwoff2common.so.1.0.2 => /usr/lib/libwoff2common.so.1.0.2 (0x00007f570666e000)
    libbrotlidec.so.1 => /usr/lib/libbrotlidec.so.1 (0x00007f5706660000)
    liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f5706638000)
    libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00007f5706633000)
    libmount.so.1 => /usr/lib/libmount.so.1 (0x00007f57065d3000)
    libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f57065b8000)
    libunwind.so.8 => /usr/lib/libunwind.so.8 (0x00007f570659e000)
    libdw.so.1 => /usr/lib/libdw.so.1 (0x00007f570654a000)
    liborc-0.4.so.0 => /usr/lib/liborc-0.4.so.0 (0x00007f57064c8000)
    libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f57064bd000)
    libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f5706448000)
    libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f570637a000)
    libgraphite2.so.3 => /usr/lib/libgraphite2.so.3 (0x00007f5706355000)
    liblz4.so.1 => /usr/lib/liblz4.so.1 (0x00007f5706333000)
    libgcrypt.so.20 => /usr/lib/libgcrypt.so.20 (0x00007f5706215000)
    libsndfile.so.1 => /usr/lib/libsndfile.so.1 (0x00007f5706197000)
    libasyncns.so.0 => /usr/lib/libasyncns.so.0 (0x00007f570618f000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f570618a000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f5706182000)
    libbrotlicommon.so.1 => /usr/lib/libbrotlicommon.so.1 (0x00007f570615f000)
    libblkid.so.1 => /usr/lib/libblkid.so.1 (0x00007f5706107000)
    libelf.so.1 => /usr/lib/libelf.so.1 (0x00007f57060ed000)
    libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f57060da000)
    libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0x00007f57060b7000)
    libFLAC.so.8 => /usr/lib/libFLAC.so.8 (0x00007f5706078000)
    libogg.so.0 => /usr/lib/libogg.so.0 (0x00007f570606b000)
    libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x00007f5705e3f000)
    libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0x00007f5705b96000)

What needs to be changed for a build against python-3.8?

Add .isatty() to PythonQtStdIn

Hello. I would like an isatty method in stdin as the one in stdout:

{"isatty", (PyCFunction)PythonQtStdOutRedirect_isatty, METH_NOARGS,
"return False since this object is not a tty-like device. Needed for logging framework"
},

May I open a PR to add it to https://github.com/MeVisLab/pythonqt/blob/master/src/PythonQtStdIn.cpp? This is to follow the advice I was given at Slicer/Slicer#5705 to fix an issue using pip within the 3D Slicer Python console.

Segfault in PythonQtPrivate::createNewPythonQtInstanceWrapper

Dear PythonQt community,

I recent upgraded from the old trunk r502 (sourceforge) to latest code on GitHub master branch, committish 9ea0fcf of 2 December 2020. I did this in order to get compatibility with Python 3.8. Using Python 2.7 and 3.6 have both worked fine with "r502".

Now when I try to use the latest PythonQt with code which previously worked fine, I get a segmentation fault. Looking at some (somewhat) recent commits I see there has been some work going on in the area where the segfault happens. Though it's hard for me to identify which commit introduced the issue.

The backtrace is here:

#0  0x00007ffff40f403f in PyObject_Call () at /lib64/libpython2.7.so.1.0
#1  0x00007ffff3d11dc0 in PythonQtPrivate::createNewPythonQtInstanceWrapper(QObject*, PythonQtClassInfo*, void*) ()
    at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#2  0x00007ffff3d13b11 in PythonQtPrivate::wrapPtr(void*, QByteArray const&, bool) () at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#3  0x00007ffff3db78c7 in PythonQtConv::createCopyFromMetaType(int, void const*) () at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#4  0x00007ffff3db8663 in PythonQtConv::QVariantListToPyObject(QList<QVariant> const&) () at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#5  0x00007ffff3dbc6b2 in PythonQtSignalTarget::call(_object*, PythonQtMethodInfo const*, void**, bool) ()
    at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#6  0x00007ffff3dbc7eb in PythonQtSignalTarget::call(void**) const ()
    at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#7  0x00007ffff3dbd04a in PythonQtSignalReceiver::qt_metacall(QMetaObject::Call, int, void**) () at /home/xxx/git/qtbuild/libPythonQt-Qt5-Python2.7.so.3
#8  0x00007fffef35a144 in QMetaObject::activate(QObject*, int, int, void**) ()
    at /lib64/libQt5Core.so.5

I am using CentOS 7.9.2009 which has Python 2.7.5 and Qt 5.9.7.

I would very much appreciate the community's and the developers' insight. Thank you.

About Qt6

Qt6 is coming. Are there any plans to update PythonQt to support qt6?

thanks.

Emit error messages via signals or return them from function calls (optionally)

Hello!

Whenever a Python error occurs its description is sent to the stderr. I would like to emit a signal with error message instead. For instance, Qt’s own ECMAScript implementation, QJSEngine does not print to the stderr and instead returns a QJSValue containing error message, from which a string could be extracted and emitted via signal. It is very convenient.

The way I see it, this is how it could be done:

When error occurs during PythonQtObjectPtr::evalScript or PythonQtObjectPtr::call calls return QString (wrapped in QVariant) instead of invalid QVariant. PythonQt::hadError would then tell whether this variant contains a “normal” string or an error message.

Or perhaps you could even give errors their own struct, with fields like type, message, etc, and the return value could be tested like this:

PythonQtObjectPtr main_module = PythonQt::self()->getMainModule();
QVariant result = main_module->evalScript (script);
if (result.canConvert<PythonQtErrorStruct>())
{
    PythonQtErrorStruct error = result.value<PythonQtErrorStruct>();
    emit errorOccured (error.type, error.message);
}

I am aware that PythonQt lets redirection of stderr, but this is not the same. Plus in some cases user might want to emit error via signal, and in other to simply print it to stderr, so just bluntly redirecting the entire error output seems like a cumbersome solution.

Properties shadowing methods and missing functions

Hi all,
I am new to the concept of pythonqt and find it fascinating. Great work!
I am working from the python side, so please keep that in mind.

I am trying to access QGraphicsWidget layout property from python but apparently cannot.
When I set it via setLayout(), it seems to work, but retrieving it is not working. I always get None from QGraphicsWidget.layout
The method layout() is not available, which if I understand correctly, the philosophy of pythonqt is to expose the property to be able to atribute a value to it from python and python methods cannot have the same name as properties.
But if I instantiate and do obj.layout = QGraphicsGridLayout() I get an error that layout is a pointer and cannot receive an object.
Can someone comment on this issues and help me understand it better? I am willing to help but I there are some things about python that I do not fully understand yet.

Other issues I've encountered
missing function: QMetaObject has no connectSlotsByName
Operators are not accessible via python. Example: QDataStream >>operator

Thanks

Allow only scriptable methods and properties

What is the recommended way, to allow only scriptable methods (annotated with Q_SCRIPTABLE) and scriptable properties (SCRIPTABLE attribute of a Q_PROPERTY)?

Should I filter the data when doing introspection (PythonQt::introspection) to prevent the user from selecting any other methods and properties or is it possible to filter out methods and properties when a QObject becomes visible / registered to the Python interpreter. What is the right place in the source code to touch if i would like to enable only scriptable methods and properties?

Implementing signals and slots

I'm trying to implement a custom signal and slot but there seem to be a few errors.
I can't inherit from QObject(which seems to be the recommended way) as it doesn't exist. This example throws:
AttributeError: module 'PythonQt.QtCore' has no attribute 'QObject'
The discussion here doesn't seem to be resolved either.

If I do it without classes like so:

from PythonQt.QtCore import Signal
def slot():
    print("something")
sig = Signal("QVariant") # also tried without QVariant
sig.connect(slot)
sig.emit()

It results in a crash due to segmentation fault.
I'm new to Qt itself so would love any suggestions/right way of doing things. Thank You.

Importer issue


    connect(PythonQt::self(), SIGNAL(pythonStdErr(const QString&)), this, SLOT(log(const QString&)));
    PythonQt::self()->setImporter(NULL);
    Q_ASSERT(!mainModule.isNull());
    mainModule.evalScript(QString("import sys,site\n"));
    mainModule.evalScript("for s in site.getsitepackages(): sys.path.append(s)\n");
    mainModule.evalScript("sys.path.append(site.getusersitepackages())\n");
    mainModule.evalScript("sys.path.append(':cashcode')\n");
//    mainModule.evalScript("import serial\n");
    mainModule.evalScript("import ccnet\n");


On importing serial from module in qrc


ERROR:root:<module 'site' from '/usr/lib/python3.8/site.py'>
ERROR:root:['/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/lib/python3.8/site-packages', '/home/eri/.local/lib/python3.8/site-packages', ':cashcode']

Traceback (most recent call last):
  File \"/usr/lib/python3.8/linecache.py\", line 95, in updatecache
    
stat = os.stat(fullname)

FileNotFoundError
: 
[Errno 2] Нет такого файла или каталога: ':cashcode/ccnet.py'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File \"<string>\", line 1, in <module>
  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \":cashcode/ccnet.py\", line 9, in <module>
  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \"/home/eri/.local/lib/python3.8/site-packages/serial/__init__.py\", line 10, in <module>
    
from . import utilities, abc, model, marshal, errors, properties, meta, hooks, test, request

  File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 655, in _load_unlocked
  File \"<frozen importlib._bootstrap>\", line 618, in _load_backward_compatible
  File \"/home/eri/.local/lib/python3.8/site-packages/serial/utilities/__init__.py\", line 5, in <module>
    
compatibility.backport()  # noqa

  File \"/home/eri/.local/lib/python3.8/site-packages/serial/utilities/compatibility.py\", line 21, in backport
    
frame_info = inspect.stack()[1]  # type: inspect.FrameInfo

  File \"/usr/lib/python3.8/inspect.py\", line 1514, in stack
    
return getouterframes(sys._getframe(1), context)

  File \"/usr/lib/python3.8/inspect.py\", line 1491, in getouterframes
    
frameinfo = (frame,) + getframeinfo(frame, context)

  File \"/usr/lib/python3.8/inspect.py\", line 1465, in getframeinfo
    
lines, lnum = findsource(frame)

  File \"/usr/lib/python3.8/inspect.py\", line 794, in findsource
    
lines = linecache.getlines(file, module.__dict__)

  File \"/usr/lib/python3.8/linecache.py\", line 47, in getlines
    
return updatecache(filename, module_globals)

  File \"/usr/lib/python3.8/linecache.py\", line 103, in updatecache
    
data = cache[filename][0]()

SystemError
: 
<built-in method get_source of PythonQtImport.PythonQtImporter object at 0x7fbdeac3ebb0> returned NULL without setting an error
"

Using enum elements from C++ Qt Object in python

Short

In Python not found enum elements from C++ class derived from QObject added to PythonQt via addDecorators() and registerClass(QMetaObject*).

Versions

Qt 5.12.8
Python 3.8.10
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
PythonQt master fb16d6e on 3 Nov 2021

Example Code

Add to std example PyDecoratorsExample
ExternalWidget.h

#ifndef EXTERNAL_W_HH_
#define EXTERNAL_W_HH_

#include <QtWidgets/QWidget>

class ExternalWidget : public QWidget
{
  Q_OBJECT

public:
  enum EType
  {
    Aone,
    Atwo,
    Athree,
    Afour
  };

  Q_ENUM(EType)

  ExternalWidget(QWidget* parent = nullptr);
  ~ExternalWidget();

public slots:
  void widgetSlot(){};
};

#endif  // EXTERNAL_W_HH_

ExternalWidget.cpp

#include "ExternalWidget.h"

ExternalWidget::ExternalWidget(QWidget* parent) : QWidget(parent)
{
}

ExternalWidget::~ExternalWidget()
{
}

add to main.cpp

PythonQt::self()->registerClass(&ExternalWidget::staticMetaObject, "QtGui");

add to example.py

w = QtGui.ExternalWidget()
w.move(100,100)
w.show()

add ExternalWidget.h and ExternalWidget.cpp to HEADERS a SOURCES in PyDecoratorsExample.pro
In python console can use
dir(QtGui.ExternalWidget)

There are no enum elements Aone, Atwo e.t.c. and enum EType

Whats wrong???
I try to use Q_ENUMS() and result is the same. :(

Potential null pointer dereference in PythonQtConvertListOfKnownClassToPythonList

static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(QMetaType::typeName(metaTypeId))));
if (innerType == NULL) {
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type " << innerType->className().constData() << std::endl;
}

static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(QMetaType::typeName(metaTypeId))));
if (innerType == NULL) {
std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type " << innerType->className().constData() << std::endl;
}

This code checks the "innerType" pointer for null and then, if null, is dereferencing the pointer in the cerr prints.

class ‘PythonQtScriptingConsole’ doesn't work well after multithreading is enabled

I found that when I enable multithreading support, I have to apply macro ‘PYTHONQT_GIL_SCOPE’ to the whole message loop to make class ‘PythonQtScriptingConsole’ work well.
In general, this seems OK, but when I wanted to use macro 'PYTHONQT_ALLOW_THREADS_SCOPE' when the console was running, I found that I couldn't solve the problem.
As you know, when macro 'PYTHONQT_GIL_SCOPE' exists, macro 'PYTHONQT_ALLOW_THREADS_SCOPE' is temporarily disabled.
Therefore, when the class ‘PythonQtScriptingConsole’ does not execute any code at this time, the python thread created previously will not have a chance to be executed.
So I think if class ‘PythonQtScriptingConsole’ can support multithreading, class ‘PythonQtScriptingConsole’ will be better.

Is this the latest version of PythonQt? What versions of Qt are supported? Anything past 5.5?

First, this looks to be the main living fork of PythonQt. Is that right?

Second, what versions of Qt are supported by this fork? Anything past 5.5? I ask because of this comment over in build instructions for CsoundQt: "NB! A word about Qt versions: PythonQt does not support Qt 5.6 yet. If you want to build with PythonQt support, use Qt 5.5.1 on Linux and Windows, Qt 5.4.2 on OSX (5.5 has a bug for OSX that does not let resize floating panels (like widgets' panel))."

I'm wondering if it is still true that PythonQt only works with Qt 5.5 (which is, I think, 5 years old).

MinGW 32-bit Debug: Example application PyScriptingConsole_d.exe crashes on start

Hi,

I compiled PythonQt with MinGW 7.3.0 64-bit and MinGW 7.3.0 32-bit for debug and release. Before I did this, I installed the additional Python debug binaries (python38_d.dll) via the Python installer.

The provided example applications work properly for MinGW 64-bit debug and release and for MinGW 32-bit release. The MinGW 32-bit debug build causes a crash of several examples. The following examples crash immediatelly on start:

PyScriptingConsole_d.exe
PyLauncher_d.exe
PyGuiExample_d.exe

The applications crash before the main or qMain is entered. That means, even If I debug the applications in QtCreator I cannot set a breakpoint see any aditional information. The only information I see is a Windows message box telling me:

The application was unable to start correctly (0xc0000017). Click OK to cloase the application

Is this something someone has seen before? It is realy strange that this happens only for the debug version of the MinGW 32-bit build and only for the three examples.

Environment:
Qt: 5.12.2
Python: 3.8.2 32-bit and 64-bit
MinGW: 7.3.0

pythonX.Y-config fails with Python 2.7 and 3.6 as --embed is not supported (build/python.prf)

--embed is not supported by python2.7-config and python3.6-config so the calls to it fails. Is it possible to check so that --embed is only used if it is supported, i.e., on Python 3.8? It appears --embed was added in 3.8.

Addendum: Appears a check for the support for --embed is done in a system call in python.prf which then outputs the error message multiple times while building. It might be a good idea to redirect the output of the call to python-config to /dev/null.

Potential memory leack in pythonQTPrivate object

Hello,
I have been using PythonQT and i had to read the code to understand what's happening.
I think I may have found a memory leack in PythonQTPrivate.
PythonQtPrivate::PythonQtPrivate()
{
_importInterface = NULL;
_defaultImporter = new PythonQtQFileImporter;
_noLongerWrappedCB = NULL;
_wrappedCB = NULL;
_qObjectMissingAttribCB = NULL;
_currentClassInfoForClassWrapperCreation = NULL;
_profilingCB = NULL;
_hadError = false;
_systemExitExceptionHandlerEnabled = false;
_debugAPI = new PythonQtDebugAPI(this);
}

PythonQtPrivate::~PythonQtPrivate() {
delete _defaultImporter;
_defaultImporter = NULL;

//missing delete _debugAPI ??
delete _debugAPI;
_debugAPI = NULL;

qDeleteAll(_knownClassInfos);

PythonQtMethodInfo::cleanupCachedMethodInfos();
PythonQtArgumentFrame::cleanupFreeList();
}
I think delete _debugAPI is missing since we got a new in the constructor.
Tell me if I am wrong, if i missed somethink, a mecanism deleting it somehow.
If so, maybe add a comment to say so?
Thanks

Handling pythonqt deadblocking UI

Hey there, im new to PythonQt. I've embedded a simple python scripting widget into my application to basically call c++ functions through a CPPClass that i've registered to PythonQt. It should be noted, that i am not manipulating the UI. Everything works as expected, as long as i don't execute any infinite loop or other deadlocking things. This results in a deadlock, freezing the entire application. I want to be able to stop the execution on the run.

I've tried initializing PythonQt and evaluating code in another QThread. Also i experimented with the setEnableThreadSupport setting and the information about releasing and restoring gil states i found in various threads here. No change of behaviour.

So at this point im stuck and just asking whether there is an obvious solution i just can't see.

Thank you for any answer

Bind class that accepts object from external package

Hi,

I have simple class:

#ifndef __qColadaTreeTEST_h
#define __qColadaTreeTEST_h

// Qt includes
#include <QTreeView>

// Colada includes
#include "qColadaAppExport.h"

// h5gt includes
#include <h5gt/H5File.hpp>  // has python bindings using pybind11 

class Q_COLADA_APP_EXPORT qColadaTreeTEST : public QTreeView {
  Q_OBJECT

public:
  explicit qColadaTreeTEST(QWidget *parent = nullptr);
  ~qColadaTreeTEST() = default;

public slots:
  bool addH5File(h5gt::File file);  // file -  is of type `h5gt::File` -> it has python bindings
};

#endif

as you can see it accepts h5gt::File file wich is not Qt based C++ class. But h5gt library has python bindings done with pybind11 so it is accessible from python.

When qColadaTreeTEST is binded via PythonQt I cannot call addH5File with h5gt.File argument as it gives me an error:

import qColadaAppPythonQt
q = qColadaAppPythonQt.qColadaTreeTEST()

from h5gtpy import h5gt
file_name = 'D:/test.h5'
file = h5gt.File(file_name, h5gt.OpenFlag(h5gt.ReadWrite | h5gt.Create | h5gt.Truncate))

q.addH5File(file)   # here I get the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ValueError: Called addH5File(h5gt::File file) -> bool with wrong arguments: (<h5gtpy._h5gt.File object at 0x00000285128901F0>,)

How to tell PythonQt that h5gt::File C++ class is the same as h5gtpy._h5gt.File in Python?

Is it possible to import installed modules

Hi,

First I would like to say thank you for this really nice open source project.

I would like to use external modules from PythonQt. For testing I just installed pyreadline via pip. If I open the python console, then I can enter import pyreadline to import the module. If I enter this import statement into the python cosole in the example applications, then I get the error:

py> import pyreadline
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pyreadline'

Is it possible to use external modules in PythonQt? Is there something tho consider that I missed?

Thank you,

Uwe

error: \python27.lib: No such file or directory

I am trying to build pythonqt on windows Qt mingw 5.15.2 but I am getting this error.

:-1: error: error: \python27.lib: No such file or directory
:-1: error: [Makefile.Release:179: ../lib/PythonQt-Qt5-Python27.dll] Error 1

Handling with pyc files ignores standard python flags

Hi!
During development we added the -B (DontWriteByteCode) and the environment variables for that to our execution.
PythonQt seems to ignore those flags in PythonQtImporter and writes/loads the pyc files directly.

I think the writing of pyc files NOT in pycache has historical py2 reasons, but could the flag be evaluated in PythonQtImporter?
There is a function to load with standard python loader in PythonQt.h, but i seems too different to the "reqular" parseFile Method
and is not referenced by the interface to evaluate it.

Could handling of this flag be integrated? Or a PythonQt specific Flag would be also ok? Second would be better to have "normal" python behaviour of writing cache files only for imported files/modules and not during call of evalFile

i use pythonqt in a new envirment ,if i must instll python.exe

environment

python3.7.9
qt 5.13
win10

issue

when i release my app i can't run my app.so i delete my code .when i delete

    PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
    PythonQt::init();
    PythonQt_QtAll::init();
    PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();
    PythonQtScriptingConsole *console = new PythonQtScriptingConsole(this, mainContext);
    m_topSplitter->addWidget(console);
    m_topSplitter->setStretchFactor(0,50);
    m_topSplitter->setStretchFactor(1,2);

my app can run .
so i think it maybe issue about it .

solution

so i think it maybe python cause this.so i intall python3.7.9. and surprise it can run successfully. but i want to kown if i must install python.or it have other solution.

Understanding multi threading support

Hi,

I'm just trying to implement PythonQt in our application and I try to understand the multi threading support in the library but I'm afraid I didn't understand it completely. So I have a number of questions regarding multi threading

  • what is PythonQt::setEnableThreadSupport meant for an when should I use it. From reading the docs I would say, it is required, as soon as I use the threading module from python. Is this right?
  • in which situations should I use PythonQtThreadStateSaver or PythonQtGILScope
  • is it save to access the properties and slots of registered objects from threads created via threading module as long as the object is not an UI object?
  • is it allowed to call evalScript from a Qt worker thread when PythonQt::init has been called in the main UI thread
  • is there a recommended practice what to do, If I would like to call the interpreter (evalScript) from a worker thread.

Thank you for any help regarding these questions and btw. thank you for this great library.

Uwe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.