I'm using PyGObject 3.30 and I want to display a simple MessageDialog. This is my source code:
def report_error(self, reason):
dialog = Gtk.MessageDialog(Gtk.Window(), 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Something went wrong")
dialog.format_secondary_text(reason)
dialog.run()
dialog.destroy()
It works and the MessageDialog pops up and can be dismissed by clicking on the button. However in my terminal I am getting this error message:
.../main.py:84: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "parent, flags, message_type, buttons, message_format" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
dialog = Gtk.MessageDialog(Gtk.Window(), 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Something went wrong")
...main.py:84: PyGTKDeprecationWarning: The keyword(s) "message_format" have been deprecated in favor of "text" respectively. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
dialog = Gtk.MessageDialog(Gtk.Window(), 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Something went wrong")
So what exactly does that mean? I don't know any C. I have no idea what any of this means? I don't even use "message_format" for example. Why is it complaining about it? How can I fix the deprecation error? I'm totally lost here with absolutely no way of knowing what to do. What direction to look at.
I even looked up some PyGObject example source code and the dialog was done in the same way that I have it. The example was using "self" instead of "Gtk.Window()", but "self" just gave me an error, so I used "Gtk.Window()".
Can anybody please give me a more noob-friendly description of what the problem is?
Thanks so much in advance!
The answer it's all in the warning message, it's telling you that using positional argument it's deprecated and that you should "name" each argument
def report_error(self, reason):
dialog = Gtk.MessageDialog(parent=Gtk.Window(), flags=0, message_type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.OK, text="Something went wrong")
dialog.format_secondary_text(reason)
dialog.run()
dialog.destroy()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With