now working with pygame

parent 8c45815e
import os import os
from os.path import isfile, join from os.path import isfile, join
import pygame import pygame
import keyboard
# from storage_media import USBDeviceHandler from storage_media import USBDeviceHandler
# import time # import time
# import signal # import signal
# import keyboard # import keyboard
pygame.init()
winW = pygame.display.Info().current_w * 0.9
winH = pygame.display.Info().current_h * 0.9
window = pygame.display.set_mode((winW,winH))
#Fullscreen = True
#window.fill((205,100,100))
#pygame.display.update()
#clock = pygame.time.Clock()
dir_path = os.getcwd() dir_path = os.getcwd()
...@@ -19,7 +28,7 @@ channel = False ...@@ -19,7 +28,7 @@ channel = False
current_sound_index = -1 current_sound_index = -1
contentlist = sorted(contentlist) contentlist = sorted(contentlist)
# usb_handler = USBDeviceHandler() usb_handler = USBDeviceHandler()
def setup_sounds(): def setup_sounds():
...@@ -62,18 +71,32 @@ def play_sound(index): ...@@ -62,18 +71,32 @@ def play_sound(index):
""" """
pygame.init()
clock = pygame.time.Clock()
setup_sounds() setup_sounds()
run = True run = True
while run: while run:
clock.tick(30) #clock.tick(30)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
run = False run = False
# keyboard module
'''
if keyboard.is_pressed("q"):
print("You Pressed A Key!")
play_sound(0)
elif keyboard.is_pressed("w"):
print("You Pressed A Key!")
play_sound(1)
elif keyboard.is_pressed("e"):
print("You Pressed A Key!")
play_sound(2)
elif keyboard.is_pressed("r"):
print("You Pressed A Key!")
play_sound(3)
'''
if event.type == pygame.KEYDOWN: if event.type == pygame.KEYDOWN:
print("you pressed " + pygame.key.name(event.key)) print("you pressed " + pygame.key.name(event.key))
if event.key == pygame.K_q: if event.key == pygame.K_q:
...@@ -85,6 +108,16 @@ while run: ...@@ -85,6 +108,16 @@ while run:
elif event.key == pygame.K_r: elif event.key == pygame.K_r:
play_sound(3) play_sound(3)
'''
elif event.key == pygame.K_f:
if Fullscreen:
window = pygame.display.set_mode((winW,winH))
Fullscreen = False
else:
window = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
Fullscreen = True
'''
pygame.quit() pygame.quit()
exit() exit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment