Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- import os, sys, time, locale, calendar, pygame;
- from os import environ, system;
- from sys import exit;
- from time import gmtime, strftime;
- from pygame import init, quit;
- from pygame.locals import *;
- init();
- print('init pygame');
- pyconfig = open('/mnt/utmp/pyclock/config.txt', 'r');
- print('loading config file "/mnt/utmp/pyclock/config.txt"');
- configload=pyconfig.readlines();
- fonttopload=configload[0].rstrip('\n');
- fontbottomload=configload[1].rstrip('\n');
- fonttopsize=configload[2].rstrip('\n');
- fontbottomsize=configload[3].rstrip('\n');
- bgcolor=configload[4].rstrip('\n');
- bgcsplit=bgcolor.split(',');
- fontcolor=configload[5].rstrip('\n');
- fncsplit=fontcolor.split(',');
- topfontxy=configload[6].rstrip('\n');
- tfxysplit=topfontxy.split(',');
- bottomfontxy=configload[7].rstrip('\n');
- bfxysplit=bottomfontxy.split(',');
- dateformat=configload[8].rstrip('\n');
- timeformat=configload[9].rstrip('\n');
- environ['SDL_VIDEODRIVER'] = 'x11';
- pygame.display.init();
- print('init pygame x11 display');
- pyscreen=pygame.display.set_mode((800,480),FULLSCREEN);
- print('setting display mode 800x480');
- print('setting fullscreen mode');
- pybackground=pygame.Surface(pyscreen.get_size());
- pybackground.fill((int(bgcsplit[0]),int(bgcsplit[1]),int(bgcsplit[2])));
- pygame.display.set_caption('PyClock Test App');
- print('setting caption "PyClock Test App"');
- pygame.mouse.set_visible(0);
- pygame.display.get_active();
- # pygame.display.toggle_fullscreen();
- pygame.font.init();
- print('init pygame font');
- toppyfont=pygame.font.Font(fonttopload, int(fonttopsize));
- print('loading top font file "%s"' % fonttopload);
- print('setting top font size %s' % fonttopsize);
- bottompyfont=pygame.font.Font(fontbottomload, int(fontbottomsize));
- print('loading bottom font file "%s"' % fontbottomload);
- print('setting bottom font size %s' % fontbottomsize);
- done = False
- while not done:
- pyscreen.fill((int(bgcsplit[0]),int(bgcsplit[1]),int(bgcsplit[2])));
- time1=toppyfont.render(strftime(dateformat), 1, (int(fncsplit[0]),int(fncsplit[1]),int(fncsplit[2])));
- time2=bottompyfont.render(strftime(timeformat), 1, (int(fncsplit[0]),int(fncsplit[1]),int(fncsplit[2])));
- a=pygame.sprite.Sprite();
- a.image=time1;
- a.rect=time1.get_rect();
- a.rect.center=((int(tfxysplit[0]),int(tfxysplit[1])));
- b = pygame.sprite.Sprite();
- b.image=time2;
- b.rect=time2.get_rect();
- b.rect.center=((int(bfxysplit[0]),int(bfxysplit[1])));
- group=pygame.sprite.RenderUpdates(a, b);
- group.clear(pyscreen, pybackground);
- rects = group.draw(pyscreen);
- pygame.display.update(rects);
- pygame.display.update();
- for event in pygame.event.get():
- if (event.type == KEYUP) or (event.type == KEYDOWN):
- if (event.key == K_ESCAPE):
- done = True
- pygame.font.quit();
- print('uninit pygame font');
- pygame.display.quit();
- print('uninit pygame x11 display');
- quit();
- print('uninit pygame');
- print('exiting python');
- exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement