Example #1
0
    def test_init__reinit(self):
        """Ensures reinitializing the scrap module doesn't clear its data."""
        data_type = pygame.SCRAP_TEXT
        expected_data = as_bytes("test_init__reinit")
        scrap.put(data_type, expected_data)

        scrap.init()

        self.assertEqual(scrap.get(data_type), expected_data)
Example #2
0
 def _window_on_key_down(self, key, scancode=None, unicode=None):
     try:
         # XXX Experimental, and work only with pygame.
         modifiers = getWindow().modifiers
         if scancode == 55 and 'ctrl' in modifiers:
             from pygame import SCRAP_TEXT
             from pygame import scrap
             scrap.init()
             text = scrap.get(SCRAP_TEXT)
             if text:
                 self.keyboard.text += text
             return True
     except Exception, e:
         pymt_logger.warning('Unable to use scrap module: %s' % str(e)) 
Example #3
0
    def test_issue_208(self):
        """PATCH: pygame.scrap on X11, fix copying into PRIMARY selection

           Copying into theX11 PRIMARY selection (mouse copy/paste) would not
           work due to a confusion between content type and clipboard type.

        """

        from pygame import display, event, freetype
        from pygame.locals import SCRAP_SELECTION, SCRAP_TEXT
        from pygame.locals import KEYDOWN, K_y, QUIT

        success = False
        freetype.init()
        font = freetype.Font(None, 24)
        display.init()
        display.set_caption("Interactive X11 Paste Test")
        screen = display.set_mode((600, 200))
        screen.fill(pygame.Color("white"))
        text = "Scrap put() succeeded."
        msg = (
            "Some text has been placed into the X11 clipboard."
            " Please click the center mouse button in an open"
            " text window to retrieve it."
            '\n\nDid you get "{}"? (y/n)'
        ).format(text)
        word_wrap(screen, msg, font, 6)
        display.flip()
        event.pump()
        scrap.init()
        scrap.set_mode(SCRAP_SELECTION)
        scrap.put(SCRAP_TEXT, text.encode("UTF-8"))
        while True:
            e = event.wait()
            if e.type == QUIT:
                break
            if e.type == KEYDOWN:
                success = e.key == K_y
                break
        pygame.display.quit()
        self.assertTrue(success)
Example #4
0
    def test_issue_208(self):
        """PATCH: pygame.scrap on X11, fix copying into PRIMARY selection

           Copying into theX11 PRIMARY selection (mouse copy/paste) would not
           work due to a confusion between content type and clipboard type.

        """

        from pygame import display, event, freetype
        from pygame.locals import SCRAP_SELECTION, SCRAP_TEXT
        from pygame.locals import KEYDOWN, K_y, QUIT

        success = False
        freetype.init()
        font = freetype.Font(None, 24)
        display.init()
        display.set_caption("Interactive X11 Paste Test")
        screen = display.set_mode((600, 200))
        screen.fill(pygame.Color("white"))
        text = "Scrap put() succeeded."
        msg = (
            "Some text has been placed into the X11 clipboard."
            " Please click the center mouse button in an open"
            " text window to retrieve it."
            '\n\nDid you get "{}"? (y/n)'
        ).format(text)
        word_wrap(screen, msg, font, 6)
        display.flip()
        event.pump()
        scrap.init()
        scrap.set_mode(SCRAP_SELECTION)
        scrap.put(SCRAP_TEXT, text.encode("UTF-8"))
        while True:
            e = event.wait()
            if e.type == QUIT:
                break
            if e.type == KEYDOWN:
                success = e.key == K_y
                break
        pygame.display.quit()
        self.assertTrue(success)
Example #5
0
 def setUp(self):
     if self.not_initialized:
         pygame.init()
         pygame.display.set_mode((1, 1))
         scrap.init()
         self.not_initialized = False
Example #6
0
def usage():
    print("Press the 'g' key to get all of the current clipboard data")
    print("Press the 'p' key to put a string into the clipboard")
    print("Press the 'a' key to get a list of the currently available types")
    print("Press the 'i' key to put an image into the clipboard")


main_dir = os.path.split(os.path.abspath(__file__))[0]

pg.init()
screen = pg.display.set_mode((200, 200))
c = pg.time.Clock()
going = True

# 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)
Example #7
0
 def setUp(self):
     if self.not_initialized:
         pygame.init ()
         pygame.display.set_mode ((1, 1))
         scrap.init ()
         self.not_initialized = False
Example #8
0
    def test_init(self):
        """Ensures scrap module still initialized after multiple init calls."""
        scrap.init()
        scrap.init()

        self.assertTrue(scrap.get_init())
Example #9
0
 def setUpClass(cls):
     pygame.display.init()
     pygame.display.set_mode((1, 1))
     scrap.init()
Example #10
0


size = wid, hei = 990, 590 # size obviously ## pensei em aumentar o tamanho!!
back = 132, 122, 130 # background color RGB
screen = pygame.display 
screen.set_caption("Txu ru ru")
screen = pygame.display.set_mode(size)
pygame.display.set_mode(size)
pygame.key.set_repeat(140,80)

from sys import stdout
from pygame.locals import *
import pygame.scrap as scrap  
import popen2
scrap.init()
scrap.set_mode(SCRAP_CLIPBOARD)
# Buffer musics
#pygame.mixer.music.load("musics/quebranozes.mp3") tem de ser uma musiquinha de tensão

# End of buffer musics


# Fonts
pygame.font.init()
font_big = pygame.font.Font(None, 35)
font_medium = pygame.font.Font(None, 22)
font_small = pygame.font.Font(None, 15)
# End Fonts

# Buffer image
Example #11
0
    def test_init(self):
        # Test if module initialized after multiple init() calls.
        scrap.init()
        scrap.init()

        self.assertTrue(scrap.get_init())