Skip to content

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

@SytseGroenwold

Description

@SytseGroenwold

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions