home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / examples / apt-gtk.py < prev    next >
Encoding:
Python Source  |  2009-03-30  |  675 b   |  30 lines

  1. #!/usr/bin/python
  2. """Example for gtk widgets"""
  3. import pygtk
  4. pygtk.require("2.0")
  5. import gtk
  6.  
  7. import apt.gtk.widgets
  8.  
  9.  
  10. def main():
  11.     """Main function."""
  12.     win = gtk.Window()
  13.     win.connect("destroy", gtk.main_quit)
  14.     progress = apt.gtk.widgets.GtkAptProgress()
  15.     win.set_title("GtkAptProgress Demo")
  16.     win.add(progress)
  17.     progress.show()
  18.     win.show()
  19.     cache = apt.cache.Cache(progress.open)
  20.     if cache["xterm"].isInstalled:
  21.         cache["xterm"].markDelete()
  22.     else:
  23.         cache["xterm"].markInstall()
  24.     progress.show_terminal(expanded=True)
  25.     cache.commit(progress.fetch, progress.install)
  26.     gtk.main()
  27.  
  28. if __name__ == "__main__":
  29.     main()
  30.