Hi there,
I have a message dialog in a script, which I borrowed from https://python-gtk-3-tutorial.readthedocs.io/en/latest/dialogs.html#example
The relevant part reads:
def on_existing_files (self):
dialog = Gtk.MessageDialog(
flags=0,
message_type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.YES_NO,
text="Existing Files",
)
dialog.format_secondary_text(
"There are files from a previous session.\nDo you want to overwrite them?"
)
dialog.props.secondary_use_markup = True
response = dialog.run()
if response == Gtk.ResponseType.YES:
if os.path.isfile(self.first_file):
os.remove(self.first_file)
if os.path.isfile(self.second_file):
os.remove(self.second_file)
elif response == Gtk.ResponseType.NO:
Gtk.main_quit()
dialog.destroy()
The default answer is to quit in Linux and to erase the files in Windows.
I wanted to add a default response, but I don’t know how to do it.
dialog.set_default_response()
seems to be the way to do that.
I’m afraid I don’t know how to know the response_id
values for each button.
How could I set the default response for the dialog buttons?
Many thanks for you help.