python-sip

PyQt custom widget in c++

倖福魔咒の 提交于 2019-12-04 20:11:43
Can I write custom Qt widget in pure C++, compile it and use in PyQt? I'm trying to use the ctypes-opencv with qt and I have performance problems with python's code for displaying opencv's image in Qt form. Lukáš Lalinský You will have to write a Python wrapper for the widget, using the sip library (which is used by PyQt). There is a simple example for a Qt/C++ widget in the documentation. 来源: https://stackoverflow.com/questions/1607515/pyqt-custom-widget-in-c

How can access to pixel data with PYQt' QImage scanline()

空扰寡人 提交于 2019-12-04 14:05:34
I need to access the pixel data in a qimage object with PyQt4. The .pixel() is too slow so the docs say to use the scanline() method. In c++ I can get the pointer returned by the scanline() method and read/write the pixel RGB value from the buffer. With Python I get the SIP voidptr object that points to the pixels buffer so I can only read the pixel RGB value using bytearray but I cannot change the value in the original pointer. Any suggestions? Luke Here are some examples: from PyQt4 import QtGui, QtCore img = QtGui.QImage(100, 100, QtGui.QImage.Format_ARGB32) img.fill(0xdeadbeef) ptr = img

Python method resolution mystery

南笙酒味 提交于 2019-12-04 01:32:20
问题 I can't figure out why this program is failing. #!/usr/bin/env python from __future__ import division, print_function from future_builtins import * import types import libui as ui from PyQt4 import QtCore import sip p = ui.QPoint() q = QtCore.QPoint() def _q_getattr(self, attr): print("get %s" % attr) value = getattr(sip.wrapinstance(self.myself(), QtCore.QPoint), attr) print("get2 %s returned %s" % (attr, value)) return value p.__getattr__ = types.MethodType(_q_getattr, p) print(p.__getattr_

Prototyping with Python code before compiling

心已入冬 提交于 2019-12-03 02:23:52
问题 I have been mulling over writing a peak fitting library for a while. I know Python fairly well and plan on implementing everything in Python to begin with but envisage that I may have to re-implement some core routines in a compiled language eventually. IIRC, one of Python's original remits was as a prototyping language, however Python is pretty liberal in allowing functions, functors, objects to be passed to functions and methods, whereas I suspect the same is not true of say C or Fortran.

Prototyping with Python code before compiling

我怕爱的太早我们不能终老 提交于 2019-12-02 15:55:29
I have been mulling over writing a peak fitting library for a while. I know Python fairly well and plan on implementing everything in Python to begin with but envisage that I may have to re-implement some core routines in a compiled language eventually. IIRC, one of Python's original remits was as a prototyping language, however Python is pretty liberal in allowing functions, functors, objects to be passed to functions and methods, whereas I suspect the same is not true of say C or Fortran. What should I know about designing functions/classes which I envisage will have to interface into the

python readthedocs how to satisfy the requirement sip (or pyqt)

十年热恋 提交于 2019-12-01 19:20:26
I want to publish the documentation of my project https://bitbucket.org/oaltun/opn in readthedocs.org. The build fails. There are different errors shown in the log https://readthedocs.org/builds/opn/2247789/ , but the first is "no module named sip". sip is needed by pyqt, which is needed by the project. Normally in this kind of situation, as far as I understand, you would add missing package to your setup.py, and check the readthedocs.org option to create a virtualenv. I do check the box to create a virtualenv. But I can not add sip or pyqt to setup.py. The problem is pyqt & sip does not use

python readthedocs how to satisfy the requirement sip (or pyqt)

狂风中的少年 提交于 2019-12-01 17:34:07
问题 I want to publish the documentation of my project https://bitbucket.org/oaltun/opn in readthedocs.org. The build fails. There are different errors shown in the log https://readthedocs.org/builds/opn/2247789/ , but the first is "no module named sip". sip is needed by pyqt, which is needed by the project. Normally in this kind of situation, as far as I understand, you would add missing package to your setup.py, and check the readthedocs.org option to create a virtualenv. I do check the box to

Installing PyQt5 from sources: Unable to import PyQt5.sip

别来无恙 提交于 2019-12-01 11:47:17
I'm trying to build PyQt5 from the sources. I'm running fedora 28 and I installed Qt5 via dnf . Installing Sip following this seems OK. But when i try to configure PyQt i got this error: # python3 configure.py -q /usr/bin/qmake-qt5 Querying qmake about your Qt installation... Error: Unable to import PyQt5.sip. Make sure you have configured SIP to create a private copy of the sip module. According to the doc I did: # python3 configure.py --sip-module private.sip # python3 configure.py -q /usr/bin/qmake-qt5 -n private.sip But i still get the error. So I'm guessing I'm not using it properly. Any

Installing PyQt5 from sources: Unable to import PyQt5.sip

巧了我就是萌 提交于 2019-12-01 07:34:03
问题 I'm trying to build PyQt5 from the sources. I'm running fedora 28 and I installed Qt5 via dnf . Installing Sip following this seems OK. But when i try to configure PyQt i got this error: # python3 configure.py -q /usr/bin/qmake-qt5 Querying qmake about your Qt installation... Error: Unable to import PyQt5.sip. Make sure you have configured SIP to create a private copy of the sip module. According to the doc I did: # python3 configure.py --sip-module private.sip # python3 configure.py -q /usr

Python method resolution mystery

梦想与她 提交于 2019-12-01 06:00:47
I can't figure out why this program is failing. #!/usr/bin/env python from __future__ import division, print_function from future_builtins import * import types import libui as ui from PyQt4 import QtCore import sip p = ui.QPoint() q = QtCore.QPoint() def _q_getattr(self, attr): print("get %s" % attr) value = getattr(sip.wrapinstance(self.myself(), QtCore.QPoint), attr) print("get2 %s returned %s" % (attr, value)) return value p.__getattr__ = types.MethodType(_q_getattr, p) print(p.__getattr__('x')()) # Works! Prints "0" print(p.x()) # AttributeError: 'QPoint' object has no attribute 'x' I