0

When I run the following code:

 dialog = Gtk.MessageDialog.new(
            None,
            Gtk.DialogFlags.MODAL,
            Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.YES_NO,
            f'Do you really want to {action} "{data["list_element"].name}" ?',
        )

I get this error:

Dialog constructor cannot be used to create instances of a subclass MessageDialog

What does it mean? How do I solve it?

BobMorane
  • 3,870
  • 3
  • 20
  • 42
mijorus
  • 111
  • 1
  • 7

1 Answers1

0

I think the problem is the use of new, which seems to be reserved for the parent Gtk.Dialog class. From this source, it seems you can use the Gtk.MessageDialog constructor directly:

 dialog = Gtk.MessageDialog(
            None,
            Gtk.DialogFlags.MODAL,
            Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.YES_NO,
            f'Do you really want to {action} "{data["list_element"].name}" ?',
        )
BobMorane
  • 3,870
  • 3
  • 20
  • 42