Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: drawText argument 1 has unexpected type 'float' #7

Open
SytseGroenwold opened this issue May 7, 2023 · 3 comments
Open

Comments

@SytseGroenwold
Copy link

After cloning the repo and attempting to start the program, I received this error message:

(venv) me@M1-MacBook-Air map-stylizer % python3.10 main.py                                               
Traceback (most recent call last):
  File ".../map-stylizer/src/gui/Widgets/mapwidget.py", line 46, in paintEvent
    self._drawPreloadScreen(p)
  File ".../map-stylizer/src/gui/Widgets/mapwidget.py", line 139, in _drawPreloadScreen
    p.drawText(self.width()/2-w/2, self.height()/2+h/2, text)
TypeError: arguments did not match any overloaded call:
  drawText(self, p: Union[QPointF, QPoint], s: str): argument 1 has unexpected type 'float'
  drawText(self, rectangle: QRectF, flags: int, text: str): argument 1 has unexpected type 'float'
  drawText(self, rectangle: QRect, flags: int, text: str): argument 1 has unexpected type 'float'
  drawText(self, rectangle: QRectF, text: str, option: QTextOption = QTextOption()): argument 1 has unexpected type 'float'
  drawText(self, p: QPoint, s: str): argument 1 has unexpected type 'float'
  drawText(self, x: int, y: int, width: int, height: int, flags: int, text: str): argument 1 has unexpected type 'float'
  drawText(self, x: int, y: int, s: str): argument 1 has unexpected type 'float'
zsh: abort      python3.10 main.py

This type error is easily fixed by following the stack trace to mapwidget:139 and casting both numeral arguments of the p.drawText() invocation with a simple int().

Will create a pull request in case this solution is deemed acceptable.

@SytseGroenwold
Copy link
Author

In case this is relevant: using python 3.10 on a M1 MacBook.

@mpcola
Copy link

mpcola commented Feb 11, 2024

I had the same error. After fixing it with int() wrappers as SytseGroenwold suggested above, I found the next thing that crashed it:
* WARNING: tag="waterway"; key="flowline" will not render unless manually added! Traceback (most recent call last): File "C:\...\map-stylizer-master\src\gui\Widgets\mapwidget.py", line 44, in paintEvent self._map.draw(p) File "C:\...\map-stylizer-master\src\core\Map.py", line 252, in draw p.fillRect(0, 0, xo, h, QColor(255, 255, 255)) TypeError: arguments did not match any overloaded call: fillRect(self, QRectF, Union[QBrush, QColor, Qt.GlobalColor, QGradient]): argument 1 has unexpected type 'int' fillRect(self, QRect, Union[QBrush, QColor, Qt.GlobalColor, QGradient]): argument 1 has unexpected type 'int' fillRect(self, int, int, int, int, Union[QBrush, QColor, Qt.GlobalColor, QGradient]): argument 3 has unexpected type 'float' fillRect(self, QRectF, Union[QColor, Qt.GlobalColor, QGradient]): argument 1 has unexpected type 'int' fillRect(self, QRect, Union[QColor, Qt.GlobalColor, QGradient]): argument 1 has unexpected type 'int' fillRect(self, int, int, int, int, Union[QColor, Qt.GlobalColor, QGradient]): argument 3 has unexpected type 'float' fillRect(self, int, int, int, int, Qt.GlobalColor): argument 3 has unexpected type 'float' fillRect(self, QRect, Qt.GlobalColor): argument 1 has unexpected type 'int' fillRect(self, QRectF, Qt.GlobalColor): argument 1 has unexpected type 'int' fillRect(self, int, int, int, int, Qt.BrushStyle): argument 3 has unexpected type 'float' fillRect(self, QRect, Qt.BrushStyle): argument 1 has unexpected type 'int' fillRect(self, QRectF, Qt.BrushStyle): argument 1 has unexpected type 'int' fillRect(self, int, int, int, int, QGradient.Preset): argument 3 has unexpected type 'float' fillRect(self, QRect, QGradient.Preset): argument 1 has unexpected type 'int' fillRect(self, QRectF, QGradient.Preset): argument 1 has unexpected type 'int'

@piipecek
Copy link

piipecek commented Mar 6, 2024

Same here. The error further appeared on all uses of fillRect, that also requires manually adding int() around first 4 arguments. After these changes, I managed to get it running on mac - python3.11 - PyQT5 5.15.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants