I've been trying to scale a Pixmap image correctly, however when calling the function I get a TypeError - am I doing something wrong?
It's stating that "size" isn't a valid argument, but also stating it's an argument within the same error call.
Code:
label = QtWidgets.QLabel(self.main_window)
image = QtGui.QPixmap(assets.images.icon)
image = image.scaled(
size = QtCore.QSize(64, 64),
aspectRatioMode = QtCore.Qt.AspectRatioMode.KeepAspectRatio,
TransformationMode = QtCore.Qt.TransformationMode.SmoothTransformation
)
label.resize(QtCore.QSize(64, 64))
label.setPixmap(image)
Error:
arguments did not match any overloaded call:
scaled(self, size: QSize, aspectRatioMode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio, transformMode: Qt.TransformationMode = Qt.FastTransformation): 'size' is not a valid keyword argument
Strangely enough, it decided to work once I took away the argument names.
label = QtWidgets.QLabel(self.main_window)
image = QtGui.QPixmap(assets.images.icon)
image = image.scaled(
QtCore.QSize(64, 64),
QtCore.Qt.AspectRatioMode.KeepAspectRatio,
QtCore.Qt.TransformationMode.SmoothTransformation
)
label.resize(QtCore.QSize(64, 64))
label.setPixmap(image)