这个问题在这里已有答案:
如何将ObjectName
的名称像self.lineEdit_260
一样传递给使用python 3.4的方法中的参数?
self.Open_Fan_J104_A_stage_2(no=self.lineEdit_260.text()))
def Open_Fan_J104_A_stage_2(self,no):
if no=='' and self.lineEdit_247.text()=='':
print(type(self.lineEdit_260.text()))
self.start_time=datetime.datetime.now()
self.lineEdit_260.setText(str(self.start_time))
elif self.lineEdit_247.text()=='':
QMessageBox.information(self, 'x')
else:
self.lineEdit_260.setText('')
self.start_time = datetime.datetime.now()
self.lineEdit_260.setText(str(self.start_time))
self.lineEdit_247.setText('')
self.lineEdit_241.setText('')
当我运行此代码时:
self.pushButton_123.clicked.connect( self.Open_Fan_J104_A_stage_2(no=self.lineEdit_260.text()))
TypeError:参数1具有意外类型'NoneType'
我认为,Open_Fan_J104_A_stage_2
期待一个callable
,因为缺乏信息。所以试试吧,
self.Open_Fan_J104_A_stage_2(lambda: self.lineEdit_260.text()))