| 
 | 
 
 
 楼主 |
发表于 2024-4-1 10:31:50
|
显示全部楼层
 
 
 
 
我的代码结构是这样的: 
 
class BaseWindow(QWidget): 
    def __init__(self): 
        super().__init__() 
 
class WindowA(BaseWindow): 
    def __init__(self): 
        super().__init__() 
 
class WindowB(BaseWindow): 
 
         def __init__(self): 
        super().__init__() 
 
      
      # 录入框位置 
    def customized_getText(parent, title, label): 
        dlg = QInputDialog(parent) 
        dlg.setInputMode(QInputDialog.TextInput) 
        dlg.setWindowTitle(title) 
        dlg.setLabelText(label) 
        dlg.move(x, y) 
        return dlg.exec(), dlg.textValue() 
 
       main_window = WindowB() 
            x = 200 
            y = 200 
           input, ok = QInputDialog.getText(main_window, '录入', f'请录入行号(从1开始计数,以英文逗号隔开。例如:1,2,3):', 
                                            options=QInputDialog.NoButtons, 
                                            text=lambda: customized_getText(main_window, '录入', 
                                                                            f'请录入行号(从1开始计数,以英文逗号隔开。例如:1,2,3):')) 
 
然后报错: 
line 1389, in exclude_rows_and_cols 
    exclude_rows_input, ok = QInputDialog.getText(main_window, '录入', f'请录入' 
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
ValueError: 'PySide6.QtWidgets.QInputDialog.getText' called with wrong argument values: 
  PySide6.QtWidgets.QInputDialog.getText(<__main__.WindowB(0x1a4ae4ec2a0) at 0x000001A4AEF661C0>, '录入', '请录入行号(从1开始计数,以英文逗号隔开。例如:1,2,3):') 
Found signature: 
  PySide6.QtWidgets.QInputDialog.getText(PySide6.QtWidgets.QWidget, str, str, PySide6.QtWidgets.QLineEdit.EchoMode = Instance(PySide6.QtWidgets.QLineEdit.Normal), str = '', PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), PySide6.QtCore.Qt.InputMethodHint = Instance(Qt.ImhNone)) 
 |   
 
 
 
 |