Source

pysdl-cffi / testing / test_clipboard.py

Full commit
#!/usr/bin/env pypy
from __future__ import (print_function, division, absolute_import, 
    unicode_literals)

import sys
import os
import traceback

from sdl import *

################################################################################

def test_clipboard():
    assert SDL_Init(SDL_INIT_VIDEO) >= 0, 'Unable to initialize SDL'

    mainwindow = SDL_CreateWindow("SDL Test Window", SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED, 512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN)
    assert mainwindow, "Unable to create main window"
    
    print("has clipboard:",SDL_HasClipboardText())
    print("get clipboard:",repr(SDL_GetClipboardText()))
    print("setting clipboard...")
    SDL_SetClipboardText("Hey everyone!")
    assert SDL_GetClipboardText() == "Hey everyone!" 
    
    SDL_DestroyWindow(mainwindow)
    
    SDL_Quit()
    
if __name__ == '__main__':
    test_clipboard()