GTK对话框构造函数不能用于创建子类Messagedialog WTF的实例
当我运行以下代码时:
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}" ?',
)
我会收到此错误:
Dialog constructor cannot be used to create instances of a subclass MessageDialog
这是什么意思?我该如何解决?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题是使用
new
,它似乎是为父gtk.dialog
类保留的。来自这个来源直接使用gtk.messagedialog
构造函数:I think the problem is the use of
new
, which seems to be reserved for the parentGtk.Dialog
class. From this source, it seems you can use theGtk.MessageDialog
constructor directly: