class MainAddMatch(qtw.QMainWindow): def __init__(self): qtw.QMainWindow.__init__(self) self.ui = Ui_AddMatch() self.ui.setupUi(self) self.show() self.ui.pushButton.clicked.connect(self.addmatch) self.ui.pushButton_2.clicked.connect(exit) def addmatch(self): ID=self.ui.lineEdit.text() Time=self.ui.lineEdit_7.text() Team1=self.ui.lineEdit_2.text() Score=self.ui.lineEdit_3.text() Team2=self.ui.lineEdit_4.text() Yellowcards=self.ui.lineEdit_5.text() Redcards=self.ui.lineEdit_6.text() Date=self.ui.lineEdit_8.text() f = open('datngu.json',) data = json.load(f) f.close() data['matches_details'].append({"ID":ID,"Time":Time,"Team1":Team1,"Score":Score,"Team2":Team2,"Yellow cards":Yellowcards,"Red cards":Redcards,"Date":Date}) f2= open('datngu.json','w') json.dump(data,f2) f2.close()