Python 3.x 正确关闭GTK对话框窗口
我使用Glade、Python3、Gtk3构建了一个应用程序。当我打开对话框窗口并再次关闭它时,我收到错误:Python 3.x 正确关闭GTK对话框窗口,python-3.x,gtk3,Python 3.x,Gtk3,我使用Glade、Python3、Gtk3构建了一个应用程序。当我打开对话框窗口并再次关闭它时,我收到错误: TypeError: on_aboutdialog_destroy() takes 1 positional argument but 2 were given 我的应用程序如下所示: #!/usr/bin/env python from gi.repository import Gtk from gi.repository import Gio import s
TypeError: on_aboutdialog_destroy() takes 1 positional argument but 2 were given
我的应用程序如下所示:
#!/usr/bin/env python
from gi.repository import Gtk
from gi.repository import Gio
import sys
class Handler:
#Main Window
def on_mainwindow_destroy(self):
print("destroy window")
Gtk.main_quit()
#Menu items
def on_menuquit_activate(self, menuitem):
print("quit from menu")
Gtk.main_quit()
def on_menuabout_activate(self, menuitem, data=None):
print("menu about activated")
aboutdialog = builder.get_object("aboutdialog")
aboutdialog.run()
def on_aboutdialog_destroy(self):
print("destroy about")
aboutdialog.hide()
builder = Gtk.Builder()
builder.add_from_file("psn.glade")
builder.connect_signals(Handler())
window = builder.get_object("mainwindow")
window.show_all()
Gtk.main()
我在GTK官方论坛上得到了一些帮助。通过执行以下操作可以关闭:
self.ab = self.builder.get_object("aboutdialog")
def on_aboutdialog_destroy(self, widget):
self.ab.hide()
在不知道连接了哪些信号的情况下,很难判断到底发生了什么,但是您是否尝试过按照错误消息所说的去做?定义关于ALOG销毁(自身、其他参数)的
def: