PyGObject MessageDialog - PyGTKDeprecationWarning - 不知道该怎么做

PyGObject MessageDialog - PyGTKDeprecationWarning - Not sure what to do

我正在使用 PyGObject 3.30,我想显示一个简单的 MessageDialog。 这是我的源代码:

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()

它起作用了,消息对话框弹出,可以通过单击按钮将其关闭。但是在我的终端中,我收到此错误消息:

.../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")

那么这到底是什么意思呢?我不知道任何 C。我不知道这意味着什么?例如,我什至不使用 "message_format"。它为什么抱怨它?如何修复弃用错误?我完全迷失在这里,完全不知道该怎么做。看什么方向。

我什至查阅了一些 PyGObject 示例源代码,对话框的完成方式与我的相同。该示例使用 "self" 而不是 "Gtk.Window()",但是 "self" 只是给了我一个错误,所以我使用了 "Gtk.Window()".

任何人都可以给我更通俗易懂的问题描述吗?

非常感谢!

答案都在警告消息中,它告诉您使用位置参数已被弃用,您应该"name"每个参数

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()