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

Incompatibility with Python 3.10+ due to implicit float-to-int conversion is no longer supported #89

Closed
tak2hu opened this issue Feb 19, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@tak2hu
Copy link
Contributor

tak2hu commented Feb 19, 2023

File "/home/kys/ballontranslator/ui/scene_textlayout.py", line 31, in _font_metrics
    font = QFont(ffamily, size, weight, italic)
TypeError: arguments did not match any overloaded call:
  QFont(): too many arguments
  QFont(family: str, pointSize: int = -1, weight: int = -1, italic: bool = False): argument 2 has unexpected type 'float'
  QFont(a0: QFont, pd: QPaintDevice): argument 1 has unexpected type 'str'
  QFont(a0: QFont): argument 1 has unexpected type 'str'
  QFont(variant: Any): too many arguments
Aborted (core dumped)

Running on Linux or Windows 11 with the the source code release 1.3.28 or the master branch, the GUI worked but when I tried to run, it stopped when it got into the OCR part.

@dmMaze
Copy link
Owner

dmMaze commented Feb 19, 2023

What is the version of your installed pyqt?
and python?

@tak2hu
Copy link
Contributor Author

tak2hu commented Feb 19, 2023

yeah I think it's a python issue in both linux and windows as seen here and here

my python version is Python 3.10.9 and pyqt5 is 5.15.8

@bropines
Copy link
Contributor

yeah I think it's a python issue in both linux and windows as seen here and here

my python version is Python 3.10.9 and pyqt5 is 5.15.8

image

@tak2hu
Copy link
Contributor Author

tak2hu commented Feb 20, 2023

thanks, I'll try python 3.8 on ubuntu when I get home

@tak2hu tak2hu closed this as completed Feb 20, 2023
dmMaze added a commit that referenced this issue Feb 20, 2023
@dmMaze dmMaze reopened this Feb 20, 2023
@dmMaze dmMaze changed the title QFont(): too many arguments Incompatibility with Python 3.10+ due to implicit float-to-int conversion is no longer supported Feb 20, 2023
@dmMaze dmMaze added the bug Something isn't working label Feb 20, 2023
@dmMaze
Copy link
Owner

dmMaze commented Feb 20, 2023

The specific TypeError related with QFont should have been fixed d01a79d, it could pop up somewhere else though

@tak2hu
Copy link
Contributor Author

tak2hu commented Feb 20, 2023

yeah it did pop up once more

Traceback (most recent call last):
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/mainwindow.py", line 822, in on_pagtrans_finished
    self.st_manager.updateSceneTextitems()
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/scenetext_manager.py", line 334, in updateSceneTextitems
    blk_item = self.addTextBlock(textblock)
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/scenetext_manager.py", line 349, in addTextBlock
    blk_item = TextBlkItem(blk, len(self.textblk_item_list), show_rect=self.canvas.textblock_mode)
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/textitem.py", line 76, in __init__
    self.initTextBlock(blk, set_format=set_format)
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/textitem.py", line 244, in initTextBlock
    self.set_fontformat(font_fmt, set_char_format=set_char_fmt, set_stroke_width=False, set_effect=False)
  File "/home/kys/Git/BallonsTranslator/ballontranslator/ui/textitem.py", line 694, in set_fontformat
    font.setPointSize(ffmat.size)
TypeError: setPointSize(self, a0: int): argument 1 has unexpected type 'float'
Aborted (core dumped)

but tried this font.setPointSize(int(ffmat.size)) in ui/textitem.py and works

@tak2hu tak2hu closed this as completed Feb 20, 2023
@dmMaze
Copy link
Owner

dmMaze commented Feb 20, 2023

but tried this font.setPointSize(int(ffmat.size)) in ui/textitem.py and works

Fixed efd7144
I recommend use setPointSizeF instead of making explicitly conversions here, since point size can be float

@tak2hu
Copy link
Contributor Author

tak2hu commented Feb 20, 2023

Oh ok thanks

By the way just tested the inpainting brush tool (band aid tool?) and it crashed

Traceback (most recent call last):
  File "D:\ballontranslator\ui\drawingpanel.py", line 405, in on_use_inpainttool
    self.setInpaintCursor()
  File "D:\ballontranslator\ui\drawingpanel.py", line 727, in setInpaintCursor
    self.canvas.gv.setCursor(self.get_pen_cursor(INPAINT_BRUSH_COLOR, self.inpaint_pen.width(), shape=self.inpaintConfigPanel.shape))
  File "D:\ballontranslator\ui\drawingpanel.py", line 499, in get_pen_cursor
    painter.drawEllipse(cursor_center-pen_radius + thickness,
TypeError: arguments did not match any overloaded call:
  drawEllipse(self, r: QRectF): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, r: QRect): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, x: int, y: int, w: int, h: int): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, center: Union[QPointF, QPoint], rx: float, ry: float): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, center: QPoint, rx: int, ry: int): argument 1 has unexpected type 'numpy.float64'

Sorry for spamming your email, so I'll just leave this issue open for future reports.

@tak2hu tak2hu reopened this Feb 20, 2023
dmMaze added a commit that referenced this issue Feb 20, 2023
@dmMaze
Copy link
Owner

dmMaze commented Feb 20, 2023

Oh ok thanks

By the way just tested the inpainting brush tool (band aid tool?) and it crashed

Traceback (most recent call last):
  File "D:\ballontranslator\ui\drawingpanel.py", line 405, in on_use_inpainttool
    self.setInpaintCursor()
  File "D:\ballontranslator\ui\drawingpanel.py", line 727, in setInpaintCursor
    self.canvas.gv.setCursor(self.get_pen_cursor(INPAINT_BRUSH_COLOR, self.inpaint_pen.width(), shape=self.inpaintConfigPanel.shape))
  File "D:\ballontranslator\ui\drawingpanel.py", line 499, in get_pen_cursor
    painter.drawEllipse(cursor_center-pen_radius + thickness,
TypeError: arguments did not match any overloaded call:
  drawEllipse(self, r: QRectF): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, r: QRect): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, x: int, y: int, w: int, h: int): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, center: Union[QPointF, QPoint], rx: float, ry: float): argument 1 has unexpected type 'numpy.float64'
  drawEllipse(self, center: QPoint, rx: int, ry: int): argument 1 has unexpected type 'numpy.float64'

Sorry for spamming your email, so I'll just leave this issue open for future reports.

I have to fix those related to float-to-int conversion soon or later.
I may not test all those stuff in py3.10 anytime soon, so feel free to open a pr to fix those type err you encountered XXD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants