忘记、过去
2023-08-16 04:18 deepin
要不试试在终端里用 python 跑这个栗子看看,是不是 IDE 里面运行环境变量配置之类的问题?
Reply Like 0 View the author
要不试试在终端里用 python 跑这个栗子看看,是不是 IDE 里面运行环境变量配置之类的问题?
要不试试在终端里用 python 跑这个栗子看看,是不是 IDE 里面运行环境变量配置之类的问题?
x11下正常
尝试创建一个干净的python虚拟环境,然后只装pyside, 在这个环境中运行试试。我看到网上论坛里Ubuntu有一个类似的问题,只不过是相反的,wayland下能运行,x11不行,是由于装了opencv导致的。
x11下正常
你这里输出显示可用的 platform 不完整,V23 里面提供了 dxcb 和 dwayland 都没有,感觉环境变量不对的样子......
用的不是系统里的 pyside ?
临时解决办法是,可以试试在程序运行前去掉 QT_WAYLAND_SHELL_INTEGRATION 这个环境变量
https://github.com/linuxdeepin/startdde/pull/237 提交了一个修复。
Popular Ranking
ChangePopular Events
More
程序:
# -*- coding: utf-8 -*-
'''
【简介】
PySide6中 QFontDialog 例子
'''
import sys
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
class FontDialogDemo(QWidget):
def __init__(self, parent=None):
super(FontDialogDemo, self).__init__(parent)
layout = QVBoxLayout()
self.fontLabel = QLabel("Hello,我来显示字体效果")
layout.addWidget(self.fontLabel)
self.fontButton1 = QPushButton("设置QLabel字体")
self.fontButton1.clicked.connect(self.set_label_font)
layout.addWidget(self.fontButton1)
self.fontButton2 = QPushButton("设置Qwidget字体")
self.fontButton2.clicked.connect(lambda:self.setFont(QFontDialog.getFont(self.font(),self)[1]))
layout.addWidget(self.fontButton2)
self.setLayout(layout)
self.setWindowTitle("Font Dialog 例子")
# self.setFont(QFontDialog.getFont(self.font(),self)[1])
def set_label_font(self):
ok, font = QFontDialog.getFont()
if ok:
self.fontLabel.setFont(font)
if __name__ == '__main__':
app = QApplication(sys.argv)
demo = FontDialogDemo()
demo.show()
sys.exit(app.exec())
运行结果: