【发布时间】:2018-09-25 13:50:02
【问题描述】:
我正在使用 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()
它起作用了,MessageDialog 会弹出并且可以通过单击按钮来关闭。但是在我的终端中,我收到了以下错误消息:
.../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()”。
谁能给我一个更简单的问题描述?
提前非常感谢!
【问题讨论】: