0

How can I pass the name of ObjectName like self.lineEdit_260 as a parameter in a method using 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('')

When I run this code:

self.pushButton_123.clicked.connect( self.Open_Fan_J104_A_stage_2(no=self.lineEdit_260.text()))

TypeError: argument 1 has unexpected type 'NoneType'

Anas Abu Farraj
  • 1,540
  • 4
  • 23
  • 31
  • It is an `attribute` of the `instance`, why do you wanna pass it ? – han solo Mar 04 '19 at 07:13
  • I have many line edit and each one take vaIue when press on it's own button so i want to pass the name of lineedit function to control each one by it's button – mohamed saleh Mar 04 '19 at 17:23

1 Answers1

0

I think, the Open_Fan_J104_A_stage_2 expects a callable and since there was a lack of information. So try,

self.Open_Fan_J104_A_stage_2(lambda: self.lineEdit_260.text()))
han solo
  • 6,390
  • 1
  • 15
  • 19