Reputation: 151
I'm trying to add FigureCanvasQTAgg argument as widget to some layout using addWidget funtion and TypeError occured. This Error appers only when trying to run my standalone appliciation that was built using pyinstaller. When running the script directly everything works well.
I'm using python=3.6
, PySide2=5.12.3
, pyInstaller=3.4
from PySide2.QtWidgets import QApplication, QMainWindow, QMessageBox, QLineEdit, QComboBox, QWidget
import matplotlib
matplotlib.use("Qt5Agg")
from PySide2.QtCore import Qt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
class TasksConfigCreatorAdapter(QMainWindow):
def __init__(self):
super(TasksConfigCreatorAdapter, self).__init__()
self.dialog = Ui_TasksConfigCreatorDialog()
self.dialog.setupUi(self)
self.figure = None
self.setupCanvasLayout()
def setupCanvasLayout(self):
if self.figure is None:
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.figure.set_facecolor("white")
self.toolbar = NavigationToolbar(self.canvas, None)
self.dialog.canvasLayout.addWidget(self.canvas, *(0, 0))
self.dialog.canvasLayout.addWidget(self.toolbar, *(1, 0))
TypeError: 'PySide2.QtWidgets.QGridLayout.addWidget' called with wrong argument types:
PySide2.QtWidgets.QGridLayout.addWidget(FigureCanvasQTAgg, int, int)
Supported signatures:
PySide2.QtWidgets.QGridLayout.addWidget(PySide2.QtWidgets.QWidget, int, int, PySide2.QtCore.Qt.Alignment=Default(Qt.Alignment))
PySide2.QtWidgets.QGridLayout.addWidget(PySide2.QtWidgets.QWidget, int, int, int, int, PySide2.QtCore.Qt.Alignment=Default(Qt.Alignment))
PySide2.QtWidgets.QGridLayout.addWidget(PySide2.QtWidgets.QWidget)
Upvotes: 3
Views: 14347
Reputation: 13
I had a similar issue.
TypeError: 'qRegisterResourceData' called with wrong argument types:
qRegisterResourceData(int, str, str, str)
Supported signatures:
qRegisterResourceData(int, unicode, unicode, unicode)
My mistake was that I was using Python3 and didn't use -py3
flag to compile the qrc file, where the default is Python2.
Usage: C:\Python36\Lib\site-packages\PySide\pyside-rcc.exe [options] <inputs>
Options:
-o file Write output to file rather than stdout
-py2 Generate code for any Python v2.x version (default)
-py3 Generate code for any Python v3.x version
-name name Create an external initialization function with name
-threshold level Threshold to consider compressing files
-compress level Compress input files by level
-root path Prefix resource access path with root path
-no-compress Disable all compression
-version Display version
-help Display this information
Upvotes: 0
Reputation: 151
Solved this issue by adding PyQt5
module to the exclude list in the spec file.
When trying to create the standalone in one folder mode, I figured out that PyQt5
files was added as well as PySide2
files which interrupt and cause this issue to happend.
Upvotes: 3