utility.py

Go to the documentation of this file.
00001 import gtk
00002 
00003 def PrettyPrintTime(sec):
00004         """Utility function. PrettyPrintTime(63)=='1:03'"""
00005         return repr(sec/60)+':'+'%02u' % (sec%60)
00006         
00007 
00008 def ReportError(majortext,minortext):
00009         """Print out error message and display a corresponding dialog to the user."""
00010         print 'ERROR -',majortext,'(',minortext,')'
00011         
00012         dlg=gtk.MessageDialog(buttons=gtk.BUTTONS_OK,message_format=majortext,type=gtk.MESSAGE_ERROR)
00013         dlg.format_secondary_text(repr(minortext))
00014         dlg.present()
00015         dlg.run()
00016         dlg.hide()
00017                 
00018                 
00019 class GreyedOut:
00020         """For use in a with statement to grey out and then restore a widget.
00021         Overengineering is fun."""
00022         def __init__(self,widget):
00023                 self._widget_widget=widget
00024         def __enter__(self):
00025                 self._widget_widget.set_sensitive(False)
00026                 return self._widget_widget
00027         def __exit__(self,type,value,traceback):
00028                 self._widget_widget.set_sensitive(True)
00029                 return False

Generated on Mon Aug 6 21:24:20 2007 for plai by  doxygen 1.5.1