def main(): found_valid = FALSE push_rgb_visual() try: tbf_readlen = os.environ["TBF_READLEN"] readlen = string.atoi(tbf_readlen) except KeyError: pass try: tbf_bps = os.environ["TBF_KBPS"] bps = string.atoi(tbf_bps) print "Simulationg %d kBytes/sec" % bps readlen = bps * 1024 / 10 except KeyError: pass i = 1 if len(sys.argv) == 1: pixbuf = GdkPixbuf.GdkPixbufFromData(default_image, GDK.COLORSPACE_RGB, FALSE, 8, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3) new_testrgb_window(pixbuf, "") for xpm in xpms: pixbuf = GdkPixbuf.GdkPixbufFromXpmData(xpm) new_testrgb_window(pixbuf, "") found_valid = TRUE else: for i in range(1, len(sys.argv)): pixbuf = GdkPixbuf.GdkPixbufFromFile(sys.argv[i]) if pixbuf: new_testrgb_window(pixbuf, "File") found_valid = TRUE status = ProgressFileStatus() pixbuf_loader = GdkPixbufLoader.GdkPixbufLoader() status.loader = pixbuf_loader pixbuf_loader.connect("area_prepared", progressive_prepared_callback, status) pixbuf_loader.connect("area_updated", progressive_updated_callback, status) status.imagefile = open(sys.argv[1], "r") status.readlen = readlen status.timeout = Timeout(100, update_timeout, status) if found_valid: mainloop()
has_alpha=FALSE, bits_per_sample=8, width=50, height=50) show_pixbuf (pixbuf, "new with alpha=FALSE") f = open ("pic.ppm", "r") magic_number = f.readline () line = f.readline () import string width, height = string.split (line) width = string.atoi (width) height = string.atoi (height) data = f.read () f.close () pixbuf = GdkPixbuf.GdkPixbufFromData (data=data, colorspace=GdkPixbuf.COLORSPACE_RGB, has_alpha=FALSE, bits_per_sample=8, width=width, height=height, rowstride=width * 3) #, destroy_fn=None, destroy_fn_data=None) show_pixbuf (pixbuf, "new from data") xpm_data = [ "32 32 9 1", " s None c None", "o c #999999", "O c black", "+ c #333333", "@ c #111111", "# c #FF6666", "$ c #FEFE00", "% c #DDDDDD", "& c #BBBBBB", " ",