准备环境
pip install pyside6 -i https://pypi.tuna.tsinghua.edu.cn/simple
`
pycharm中配置Designer
PySide6-Designer
C:\APP\Anaconda\Scripts\pyside6-designer.exe
$FileName$
$ProjectFileDir$
PyUiC
C:\APP\Anaconda\Scripts\pyside6-uic.exe
$FileName$ -o $FileNameWithoutExtension$.py
$FileDir$
补齐代码
if __name__ == '__main__':
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication(sys.argv)
window = QMainWindow()
view = Ui_MainWindow()
view.setupUi(window)
window.show()
sys.exit(app.exec())
或者
if __name__ == '__main__':
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
view = Ui_Form()
view.setupUi(window)
window.show()
sys.exit(app.exec())
添加环境变量
- 方式1(创建环境变量)
QT_QPA_PLATFORM_PLUGIN_PATH C:\APP\Anaconda\lib\site-packages\PySide6\plugins\platforms
- 方式2
import os
import PySide6
dirname = os.path.dirname(PySide6.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
print(plugin_path)
|