Comments (8)
I have tested this part of the code with the following script with Python 2.7 and Python 3.4 and it works:
(what version of Python 3 are you using?)
import struct
from qwt.qt.QtGui import (QApplication, QColor, QFont, QPixmap, QFontMetrics,
QPainter)
from qwt.qt.QtCore import Qt
def findAscent(font):
dummy = "E"
white = QColor(Qt.white)
fm = QFontMetrics(font)
pm = QPixmap(fm.width(dummy), fm.height())
pm.fill(white)
p = QPainter(pm)
p.setFont(font)
p.drawText(0, 0, pm.width(), pm.height(), 0, dummy)
p.end()
img = pm.toImage()
w = pm.width()
linebytes = w*4
for row in range(img.height()):
line = img.scanLine(row).asstring(linebytes)
for col in range(w):
color = struct.unpack('I', line[col*4:(col+1)*4])[0]
if color != white.rgb():
return fm.ascent()-row+1
return fm.ascent()
if __name__ == '__main__':
app = QApplication([])
font = QFont('Arial')
print(findAscent(font))
from pythonqwt.
Tested on Python 3.3 on Windows 10. It works too.
from pythonqwt.
com-sixs@sixs7:~/picca/bugs$ python3.4 test.py
Traceback (most recent call last):
File "test.py", line 30, in
print(findAscent(font))
File "test.py", line 20, in findAscent
line = img.scanLine(row).asstring(linebytes)
SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer supported!
from pythonqwt.
I split the line and it failes with the asstring method
Traceback (most recent call last):
File "test.py", line 32, in
print(findAscent(font))
File "test.py", line 22, in findAscent
line = sline.asstring(linebytes)
SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer supported!
from pythonqwt.
https://bugs.python.org/issue15657
I think that there is a bad interaction with sip
from pythonqwt.
https://riverbankcomputing.com/pipermail/pyqt/2014-December/035201.html
from pythonqwt.
Ok, I think you found the source of the problem.
Given the fact that Phil Thompson wrote here that the bug was fixed in latest sip snapshot on december 2014, it should be fixed with PyQt4 >= 4.11.4 and PyQt5 >= 5.4.
So the question is: what version of PyQt are you using? and would it be possible for you to upgrade your PyQt installation?
from pythonqwt.
ii python-sip 4.16.4+dfsg-1 amd64 Python/C++ bindings generator runtime library
ii python3-sip 4.16.4+dfsg-1 amd64 Python 3/C++ bindings generator runtime library
picca@sixs7:~/Debian/guiqwt$ dpkg -l | grep python-qt4
ii python-qt4 4.11.2+dfsg-1 amd64 Python bindings for Qt4
ii python-qt4-gl 4.11.2+dfsg-1 amd64 Python bindings for Qt4's OpenGL module
The current Debian jessie is affected by this bug :((. It means that for now it is not possible to backport the python3 version of python-qwt. Not a big deal, but it is nice to have the info somewhere :)
thanks
from pythonqwt.
Related Issues (20)
- Bugfixe : QSize + QSizeF
- support for PySide6 ? HOT 1
- Add support for PyQt6 HOT 2
- PyQt/NumPy types conflict
- Add input widgets and other features of Qwt
- AttributeError: 'QwtScaleWidget' object has no attribute 'maxMajor' / 'maxMinor' / 'stepSize'
- Actually NAME the library QwtMathMLTextEngine is provided by HOT 1
- TypeError: QwtPlotDict.__init__() [...] with PySide 6.5.0 HOT 9
- [PySide] AttributeError: 'QwtPlotCanvas' object has no attribute 'Sunken'
- AttributeError: 'XXX' object has no attribute '_QwtPlot__data'
- TypeError: unexpected type 'QSize' HOT 4
- Print to PDF: AttributeError: 'NoneType' object has no attribute 'getContentsMargins'
- Signal disconnection issue with PySide 6.5.3
- Plot markers: labels and symbols are clipped HOT 8
- Performance issue with High DPI displays HOT 6
- Visual glitches when trying to scroll a QwtScaleDiv HOT 2
- Add NumPy V2.0 support HOT 1
- `QwtAbstractScaleDraw` label cache mechanism can cause segmentation fault
- `QwtSymbol` constructor: segmentation fault on CentOS/Python3.12/PyQt5
- `QwtPlot.setMouseTracking` is ignored HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pythonqwt.