[wayland] pySide 6 程序不能在 wayland下运行
Tofloor
poster avatar
future
deepin
2023-08-16 04:14
Author

程序:

# -*- 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())

运行结果:
截图_选择区域_20230812160741.png

Reply Favorite View the author
All Replies
忘记、过去
deepin
2023-08-16 04:18
#1

要不试试在终端里用 python 跑这个栗子看看,是不是 IDE 里面运行环境变量配置之类的问题?

Reply View the author
future
deepin
2023-08-16 04:22
#2
忘记、过去

要不试试在终端里用 python 跑这个栗子看看,是不是 IDE 里面运行环境变量配置之类的问题?

x11下正常

Reply View the author
jalawov
deepin
2023-08-16 05:29
#3

尝试创建一个干净的python虚拟环境,然后只装pyside, 在这个环境中运行试试。我看到网上论坛里Ubuntu有一个类似的问题,只不过是相反的,wayland下能运行,x11不行,是由于装了opencv导致的。

Reply View the author
忘记、过去
deepin
2023-08-16 17:01
#4
future

x11下正常

你这里输出显示可用的 platform 不完整,V23 里面提供了 dxcb 和 dwayland 都没有,感觉环境变量不对的样子......

截图_选择区域_20230816090135.png

Reply View the author
zccrs
deepin
2023-08-16 19:03
#5

用的不是系统里的 pyside ?

Reply View the author
zccrs
deepin
2023-08-16 19:05
#6

临时解决办法是,可以试试在程序运行前去掉 QT_WAYLAND_SHELL_INTEGRATION 这个环境变量

Reply View the author
justforlxz
deepin developers team
2023-08-16 19:24
#7

https://github.com/linuxdeepin/startdde/pull/237 提交了一个修复。

Reply View the author