Skip to content

Commit 8943964

Browse files
committed
pygame
1 parent 1882706 commit 8943964

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

pygame/clipboard/main.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# author: Bartlomiej "furas" Burek (https://blog.furas.pl)
2+
# date: 2022.04.14
3+
4+
import pygame
5+
import random
6+
7+
# --- constants --- (UPPER_CASE_NAMES)
8+
9+
SCREEN_WIDTH = 800
10+
SCREEN_HEIGHT = 600
11+
12+
BLACK = (0, 0, 0)
13+
14+
FPS = 25 # for more than 220 it has no time to update screen
15+
16+
# --- main ---
17+
18+
pygame.init()
19+
pygame.scrap.init()
20+
pygame.scrap.set_mode(pygame.SCRAP_CLIPBOARD)
21+
#pygame.scrap.set_mode(pygame.SCRAP_SELECTION)
22+
23+
screen = pygame.display.set_mode( (SCREEN_WIDTH, SCREEN_HEIGHT) )
24+
25+
# --- mainloop ---
26+
27+
clock = pygame.time.Clock()
28+
29+
running = True
30+
while running:
31+
32+
# --- events ---
33+
for event in pygame.event.get():
34+
if event.type == pygame.QUIT:
35+
running = False
36+
37+
elif event.type == pygame.KEYUP:
38+
if event.key == pygame.K_ESCAPE:
39+
running = False
40+
41+
elif event.key == pygame.K_v and event.mod & pygame.KMOD_CTRL:
42+
print('Clipboard:', pygame.scrap.get(pygame.SCRAP_TEXT))
43+
print('Clipboard:', pygame.scrap.get("text/plain;charset=utf-8").decode())
44+
45+
for t in pygame.scrap.get_types():
46+
r = pygame.scrap.get(t)
47+
print('>', t, r)
48+
49+
# --- draws ---
50+
51+
screen.fill(BLACK)
52+
53+
pygame.display.flip()
54+
55+
# --- FPS ---
56+
57+
ms = clock.tick(FPS)
58+
59+
# --- end ---
60+
61+
pygame.quit()
62+

0 commit comments

Comments
 (0)