Added error checking codes
[Python-Scripts.git] / PyXV / xv-alt.py
blob09ffc331e7bc1ccfffb28e96d0c3ef1f4979ebc4
1 #!/usr/bin/python
2 '''
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2011-2013 Cool Dude 2k - http://idb.berlios.de/
12 Copyright 2011-2013 Game Maker 2k - http://intdb.sourceforge.net/
13 Copyright 2011-2013 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
15 $FileInfo: xv-alt.py - Last Update: 04/01/2013 Ver. 1.0.0 - Author: cooldude2k $
16 '''
17 import os, sys, pygame, argparse;
19 parser = argparse.ArgumentParser();
20 parser.add_argument("-name", help="title name");
21 parser.add_argument("file", help="file name");
22 getargs = parser.parse_args();
24 if(getargs.file!=None):
25 pygame.display.quit();
26 pygame.quit();
27 sys.exit(0);
28 if(not os.path.exists(getargs.file) or not os.path.isfile(getargs.file)):
29 pygame.display.quit();
30 pygame.quit();
31 sys.exit(0);
33 pygame.display.init();
34 pyicon=pygame.image.load("/mnt/utmp/upctest/old_icon.png");
35 pygame.display.set_icon(pyicon);
36 ppmimg=pygame.image.load(getargs.file);
37 width, height = ppmimg.get_size();
38 screen = pygame.display.set_mode((width, height));
39 if(getargs.name!=None):
40 pygame.display.set_caption("PyXV - "+str(getargs.name));
41 if(getargs.name==None):
42 pygame.display.set_caption("PyXV - "+str(os.path.basename(getargs.file)));
43 pygame.display.get_active();
44 pygame.mouse.set_visible(0);
46 screen.blit(ppmimg, (0, 0));
47 pygame.display.flip();
48 done = False;
49 while not done:
50 for event in pygame.event.get():
51 if (event.type == pygame.QUIT):
52 done = True;
53 if (event.type == pygame.KEYDOWN):
54 if (event.key == pygame.K_t) or (event.key == pygame.K_w):
55 pygame.display.toggle_fullscreen();
56 if (event.key == pygame.K_i) or (event.key == pygame.K_m):
57 pygame.display.iconify();
58 if (event.key == pygame.K_ESCAPE) or (event.key == pygame.K_q):
59 done = True;
60 pygame.display.quit();
61 pygame.quit();
62 os._exit(0);