I am trying to convert this PyQt5 example to PySide2. I have modified a few other files and this is the first time I have encountered this problem. The only difference between the two is using "PySide2" instead of "PyQt5" in the import statements, my code is shown bellow:
import sys
import qdarkstyle
import qtawesome as qta
from PySide2 import QtWidgets
from PySide2 import QtCore
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
def create_toolbutton(menu=False, popup_mode=None):
toolbutton = QtWidgets.QToolButton()
icon = qta.icon("mdi.pan", color="white")
toolbutton.setIcon(icon)
toolbutton.setIconSize(QtCore.QSize(48, 48))
if menu:
toolbutton.setMenu(QtWidgets.QMenu())
for i in range(3):
toolbutton.menu().addAction("Action #{}".format(i))
if popup_mode:
toolbutton.setPopupMode(popup_mode)
return toolbutton
toolbar = QtWidgets.QFrame()
layout = QtWidgets.QGridLayout(toolbar)
layout.setSpacing(10)
layout.setColumnStretch(0, 1)
labels = ["No Menu", "DelayedPopup", "InstantPopup", "MenuButtonPopup"]
props = [
{"menu": False, "popup_mode": None},
{"menu": True, "popup_mode": 0},
{"menu": True, "popup_mode": 2},
{"menu": True, "popup_mode": 1},
]
for i, (kargs, label) in enumerate(zip(props, labels)):
layout.addWidget(QtWidgets.QLabel(label), 0, i + 1, QtCore.Qt.AlignCenter)
layout.addWidget(create_toolbutton(**kargs), 1, i + 1, QtCore.Qt.AlignCenter)
layout.setColumnStretch(layout.columnCount(), 1)
toolbar.show()
sys.exit(app.exec_())
I get this error
Traceback (most recent call last):
File "C:\Python\Projects\Examples\Qt_examples\PySd2\popupbtns\popup.py", line 4, in <module>
from PySide2 import QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.
I am using Python 3.6.8 and pyside2 5.14.2.1
Any help is appreciated