def add_patient_clicked(self): text, ok = QtGui.QInputDialog.getText(self, '', 'Enter patient name:') if ok: new_file_name = os.path.join(PATIENT_DIR, str(text) + '.pkl') if os.path.exists(new_file_name): QtGui.QMessageBox.about(self, 'Error', 'Name already exists!') else: new_patient = Patient(str(text)) else: return text, ok = QtGui.QInputDialog.getInt(self, '', 'Enter patient age:') if ok: new_patient.age = int(text) else: return text, ok = QtGui.QInputDialog.getText(self, '', 'Enter patient diagnosis:') if ok: new_patient.diagnosis = str(text) else: return text, ok = QtGui.QInputDialog.getItem(self, '', 'Enter patient gender:', ['Female', 'Male', 'Other']) if ok: new_patient.gender = str(text) else: return pickle.dump(new_patient, open(new_file_name, 'wb')) self.update_patient_list()