Menu

Importing PythonQt from command line python?

Help
2015-04-28
2015-04-29
  • Michael Werth

    Michael Werth - 2015-04-28

    Is it possible to import PythonQt without launching a PythonQt-compiled app? AKA would it be possible to compile some PythonQt code and then load this directly from Python? I tried to do this with the examples, but it doesn't work for me; I'm only able to execute "import PythonQt" from the embedded Python console in the examples, but not from independent python scripts

     
  • Florian Link

    Florian Link - 2015-04-29

    https://sourceforge.net/p/pythonqt/discussion/631393/thread/ec93fba5/

    contains a similar discussion. It is not the focus of PythonQt, since there are PySide and PyQt, which both offer just that. Apart from that, it is possible and not that hard to be done.

    By now, PythonQt is only a shared library, not a Python C extension.
    To make it importable, you need to build a Python c extension that links PythonQt and calls PythonQt::init(). This C extension can then be imported from Python when it is in the sys.path. If more effort is put into it, QtCore, QtGui etc. could each be made a Python C extension which each loads its PythonQt if not already done.

    I can answer questions in that direction, but someone else will need to implement this. I don't want to build another PySide which I have to support, including all the end user questions regarding the Qt Api.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.