def test_get_types__not_owned(self): """Ensures get_types works when the clipboard is not owned by the pygame application. """ self._skip_if_clipboard_owned() data_types = scrap.get_types() self.assertIsInstance(data_types, list)
# Initialize the scrap module and use the clipboard mode. scrap.init() scrap.set_mode(pg.SCRAP_CLIPBOARD) usage() while going: for e in pg.event.get(): if e.type == pg.QUIT or (e.type == pg.KEYDOWN and e.key == pg.K_ESCAPE): going = False elif e.type == pg.KEYDOWN and e.key == pg.K_g: # This means to look for data. print("Getting the different clipboard data..") for t in scrap.get_types(): r = scrap.get(t) if r and len(r) > 500: print("Type %s : (large %i byte buffer)" % (t, len(r))) elif r is None: print("Type %s : None" % (t, )) else: print("Type %s : '%s'" % (t, r.decode("ascii", "ignore"))) if "image" in t: namehint = t.split("/")[1] if namehint in ["bmp", "png", "jpg"]: f = BytesIO(r) loaded_surf = pg.image.load(f, "." + namehint) screen.blit(loaded_surf, (0, 0)) elif e.type == pg.KEYDOWN and e.key == pg.K_p:
# Initialize the scrap module and use the clipboard mode. scrap.init () scrap.set_mode (SCRAP_CLIPBOARD) usage () while going: for e in pygame.event.get (): if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE): going = False elif e.type == KEYDOWN and e.key == K_g: # This means to look for data. print ("Getting the different clipboard data..") for t in scrap.get_types (): r = scrap.get (t) if r and len (r) > 500: print ("Type %s : (large %i byte buffer)" % (t, len(r))) elif r is None: print ("Type %s : None" % (t,)) else: print ("Type %s : '%s'" % (t, r.decode('ascii', 'ignore'))) if "image" in t: namehint = t.split("/")[1] if namehint in ['bmp', 'png', 'jpg']: f = BytesIO(r) loaded_surf = pygame.image.load(f, "." + namehint) screen.blit(loaded_surf, (0,0))