00001 ############################################################################## 00002 # 00003 # Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com> 00004 # 00005 # WARNING: This program as such is intended to be used by professional 00006 # programmers who take the whole responsability of assessing all potential 00007 # consequences resulting from its eventual inadequacies and bugs 00008 # End users who are looking for a ready-to-use solution with commercial 00009 # garantees and support are strongly adviced to contract a Free Software 00010 # Service Company 00011 # 00012 # This program is Free Software; you can redistribute it and/or 00013 # modify it under the terms of the GNU General Public License 00014 # as published by the Free Software Foundation; either version 2 00015 # of the License, or (at your option) any later version. 00016 # 00017 # This program is distributed in the hope that it will be useful, 00018 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 # GNU General Public License for more details. 00021 # 00022 # You should have received a copy of the GNU General Public License 00023 # along with this program; if not, write to the Free Software 00024 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00025 # 00026 ############################################################################## 00027 00028 import gc 00029 from PyQt4.QtCore import * 00030 00031 def printObjects(): 00032 printList( gc.get_objects() ) 00033 00034 def printReferrers( obj ): 00035 printList( [x for x in gc.get_referrers( obj ) if not '<bound method ' in str(x)] ) 00036 00037 def printList( l ): 00038 print '\n'.join( [str(x) for x in l] ) 00039 00040 def info( text ): 00041 print text 00042 00043 def warning( text ): 00044 print text 00045 00046 def error( text ): 00047 print text 00048 00049 # The DebugEventFilter class has been used to find a problem with an invisible 00050 # widget that was created, not inserted in any layout and that didn't allow to 00051 # click widgets below it. I'm leaving the code by now as it might be useful in the 00052 # future. Simply uncommenting the installEventFilter line will do. 00053 class DebugEventFilter(QObject): 00054 def __init__(self, parent=None): 00055 QObject.__init__(self, parent) 00056 00057 def eventFilter(self, obj, event): 00058 print "EVENT %d THROWN ON OBJECT '%s' OF TYPE '%s'" % ( event.type(), unicode(obj.objectName() ), unicode(obj.staticMetaObject.className()) ) 00059 return QObject.eventFilter( self, obj, event ) 00060 00061 00062 #app.installEventFilter( DebugEventFilter(win) )