import pygame
from pygame.locals import *
import subprocess
PIPE = subprocess.PIPE
cmd = 'omxplayer -o hdmi 1.MPG'
cmd2 = 'sudo kill '
running = True
pygame.init()
window = pygame.display.set_mode((300,300))
window.fill(pygame.Color(0,0,0))
fps = pygame.time.Clock()
global p
while running:
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
p = subprocess.Popen(cmd, shell = True)
pk = p.pid
cmd2=cmd2+str(pk)
if event.type == pygame.KEYDOWN:
running = False
print cmd2
subprocess.Popen(cmd2, shell = True)
pygame.display.update()
fps.tick(30)
pygame.quit()