Python+GTK如何抑制警告

2024-05-03 06:52:11 发布

您现在位置:Python中文网/ 问答频道 /正文

当我启动python程序时,终端会充满:

rcGUI.py:331: Warning: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialised
label1 = gtk.Label("Current tools configured:")
rcGUI.py:286: Warning: Attempt to add property GtkSettings::gtk-scrolled-window-placement after class was initialised
scroll_window = gtk.ScrolledWindow()
rcGUI.py:291: DeprecationWarning: use gtk.TreeView
infoList = gtk.CList(2, ["Tool" , "Version"])
rcGUI.py:291: Warning: Attempt to add property GtkSettings::gtk-button-images after class was initialised
infoList = gtk.CList(2, ["Tool" , "Version"])
rcGUI.py:217: Warning: Attempt to add property GtkSettings::gtk-can-change-accels after class was initialised
toolCombo = gtk.combo_box_entry_new_text()
rcGUI.py:217: Warning: Attempt to add property GtkSettings::gtk-menu-popup-delay after class was initialised
toolCombo = gtk.combo_box_entry_new_text()
rcGUI.py:217: Warning: Attempt to add property GtkSettings::gtk-menu-popdown-delay after class was initialised
toolCombo = gtk.combo_box_entry_new_text()
rcGUI.py:217: Warning: Attempt to add property GtkSettings::gtk-entry-select-on-focus after class was initialised
toolCombo = gtk.combo_box_entry_new_text()
rcGUI.py:217: Warning: Attempt to add property GtkSettings::gtk-entry-password-hint-timeout after class was initialised
toolCombo = gtk.combo_box_entry_new_text()

有趣的是,我在KDE中运行它的用户并没有收到所有这些警告(除了不推荐的警告),但是在GNOME中却得到了。所以我认为最简单的方法就是压制所有这些警告。我只是还不知道怎么回事。在


Tags: topyaddgtkpropertyclassentrywarning