Revert Rejected Dialogue/form To Show Last Accepted Values On Reopen
I'm setting up an 'options' dialog in a program, where I can change some values and close the dialog with Ok/Cancel to accept of reject my changes. After closing the dialog with ca
Solution 1:
You have to implement a method that sets the values of the dialog to the default values:
# ...
class MainWindow(QMainWindow):
# ...
def open_dlg(self):
self.txtdlg.reset()
if self.txtdlg.exec_() == QDialog.Accepted:
print(self.txtdlg.preferences)
class TextDialog(QDialog):
# ...
def reset(self):
self.preferences = "text here"
self.textedit.setText(self.preferences)
def save_and_close(self):
self.preferences = self.textedit.toPlainText()
self.accept()
# ...
Post a Comment for "Revert Rejected Dialogue/form To Show Last Accepted Values On Reopen"