zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.61k stars 541 forks source link

Ui_MessageBox 初始化参数个数不足导致子类对象无法初始化 #193

Closed LittleNyima closed 1 year ago

LittleNyima commented 1 year ago

Describe the bug A clear and concise description of what the bug is. qfluentwidgets.components.dialog_box.dialog.Ui_MessageBox 初始化参数个数不足导致子类对象无法初始化 (但实际的报错位置是不对的,并不是 mask_dialog_base 的问题,应该是 Ui_MessageBox 的问题)

Environment

To Reproduce Steps to reproduce the behavior(you can use gif to demonstrate the problem): 在 gallery demo 中,点击左下角的头像按钮后,无法弹出对话框,同时后台报错:

Traceback (most recent call last):
  File "/Users/littlenyima/code/PyQt-Fluent-Widgets/examples/gallery/app/view/main_window.py", line 199, in showMessageBox
    w = MessageBox(
  File "/opt/homebrew/anaconda3/envs/py38/lib/python3.8/site-packages/qfluentwidgets/components/dialog_box/dialog.py", line 134, in __init__
    super().__init__(parent=parent)
  File "/opt/homebrew/anaconda3/envs/py38/lib/python3.8/site-packages/qfluentwidgets/components/dialog_box/mask_dialog_base.py", line 14, in __init__
    super().__init__(parent=parent)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

Code

# Minimum code to reproduce the error
from PySide6.QtWidgets import QApplication
from qfluentwidgets import MessageBox

app = QApplication()
w = MessageBox('title', 'content', None)
if w.exec():
    print(True)

Expected behavior A clear and concise description of what you expected to happen. 对话框应该正确弹出

Screenshots If applicable, add screenshots to help explain your problem. screenshot

zhiyiYo commented 1 year ago

改成下面这样可以不?

class Ui_MessageBox:
    """ Ui of message box """

    yesSignal = Signal()
    cancelSignal = Signal()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
zhiyiYo commented 1 year ago

建议使用 6.4.2,因为 pyside6.5.0 最大化后窗口会超出屏幕

LittleNyima commented 1 year ago

也可以,只要能解决初始化问题就行,pr 我也一起关了