2013-12-20 75 views
2

當我啓動我的Python程序,終端洪水與:的Python + GTK - 如何禁止警告

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中。所以我認爲最簡單的方法是壓制所有這些警告。我只是還沒有能夠找出如何。

+2

相關討論:https://mail.gnome.org/archives/commits-list/2013-April/msg07206.html – Anonimista

回答

1
import warnings 
warnings.filterwarnings("ignore") 

到不過濾:

warnings.filterwarnings("default")