def test_contains__not_owned(self): """Ensures contains works when the clipboard is not owned by the pygame application. """ self._skip_if_clipboard_owned() # Use a unique data type identifier to ensure there is no preexisting # data. DATA_TYPE = "test_contains__not_owned" contains = scrap.contains(DATA_TYPE) self.assertFalse(contains)
loaded_surf = pg.image.load(f, "." + namehint) screen.blit(loaded_surf, (0, 0)) elif e.type == pg.KEYDOWN and e.key == pg.K_p: # Place some text into the selection. print("Placing clipboard text.") scrap.put(pg.SCRAP_TEXT, as_bytes("Hello. This is a message from scrap.")) elif e.type == pg.KEYDOWN and e.key == pg.K_a: # Get all available types. print("Getting the available types from the clipboard.") types = scrap.get_types() print(types) if len(types) > 0: print("Contains %s: %s" % (types[0], scrap.contains(types[0]))) print(("Contains _INVALID_: ", scrap.contains("_INVALID_"))) elif e.type == pg.KEYDOWN and e.key == pg.K_i: print("Putting image into the clipboard.") scrap.set_mode(pg.SCRAP_CLIPBOARD) fp = open(os.path.join(main_dir, "data", "liquid.bmp"), "rb") buf = fp.read() scrap.put("image/bmp", buf) fp.close() elif e.type in (pg.KEYDOWN, pg.MOUSEBUTTONDOWN): usage() pg.display.flip() c.tick(40)
elif e.type == KEYDOWN and e.key == K_p: # Place some text into the selection. print ("Placing clipboard text.") scrap.put (SCRAP_TEXT, as_bytes("Hello. This is a message from scrap.")) elif e.type == KEYDOWN and e.key == K_a: # Get all available types. print ("Getting the available types from the clipboard.") types = scrap.get_types () print (types) if len (types) > 0: print ("Contains %s: %s" % (types[0], scrap.contains (types[0]))) print ("Contains _INVALID_: ", scrap.contains ("_INVALID_")) elif e.type == KEYDOWN and e.key == K_i: print ("Putting image into the clipboard.") scrap.set_mode (SCRAP_CLIPBOARD) fp = open (os.path.join(main_dir, 'data', 'liquid.bmp'), 'rb') buf = fp.read () scrap.put ("image/bmp", buf) fp.close () elif e.type in (KEYDOWN, MOUSEBUTTONDOWN): usage () pygame.display.flip() c.tick(40)
loaded_surf = pg.image.load(f, "." + namehint) screen.blit(loaded_surf, (0, 0)) elif e.type == pg.KEYDOWN and e.key == pg.K_p: # Place some text into the selection. print("Placing clipboard text.") scrap.put(pg.SCRAP_TEXT, b"Hello. This is a message from scrap.") elif e.type == pg.KEYDOWN and e.key == pg.K_a: # Get all available types. print("Getting the available types from the clipboard.") types = scrap.get_types() print(types) if len(types) > 0: print(f"Contains {types[0]}: {scrap.contains(types[0])}") print("Contains _INVALID_: ", scrap.contains("_INVALID_")) elif e.type == pg.KEYDOWN and e.key == pg.K_i: print("Putting image into the clipboard.") scrap.set_mode(pg.SCRAP_CLIPBOARD) fp = open(os.path.join(main_dir, "data", "liquid.bmp"), "rb") buf = fp.read() scrap.put("image/bmp", buf) fp.close() elif e.type in (pg.KEYDOWN, pg.MOUSEBUTTONDOWN): usage() pg.display.flip() c.tick(40) pg.quit()