Advertisement
Guest User

PyClock 1.0.0-0

a guest
Apr 29th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.95 KB | None | 0 0
  1. #!/usr/bin/python2
  2.  
  3. import os, sys, time, locale, calendar, pygame;
  4. from os import environ, system;
  5. from sys import exit;
  6. from time import gmtime, strftime;
  7. from pygame import init, quit;
  8. from pygame.locals import *;
  9.  
  10. init();
  11. print('init pygame');
  12. pyconfig = open('/mnt/utmp/pyclock/config.txt', 'r');
  13. print('loading config file "/mnt/utmp/pyclock/config.txt"');
  14. configload=pyconfig.readlines();
  15. fonttopload=configload[0].rstrip('\n');
  16. fontbottomload=configload[1].rstrip('\n');
  17. fonttopsize=configload[2].rstrip('\n');
  18. fontbottomsize=configload[3].rstrip('\n');
  19. bgcolor=configload[4].rstrip('\n');
  20. bgcsplit=bgcolor.split(',');
  21. fontcolor=configload[5].rstrip('\n');
  22. fncsplit=fontcolor.split(',');
  23. topfontxy=configload[6].rstrip('\n');
  24. tfxysplit=topfontxy.split(',');
  25. bottomfontxy=configload[7].rstrip('\n');
  26. bfxysplit=bottomfontxy.split(',');
  27. dateformat=configload[8].rstrip('\n');
  28. timeformat=configload[9].rstrip('\n');
  29.  
  30. environ['SDL_VIDEODRIVER'] = 'x11';
  31. pygame.display.init();
  32. print('init pygame x11 display');
  33. pyscreen=pygame.display.set_mode((800,480),FULLSCREEN);
  34. print('setting display mode 800x480');
  35. print('setting fullscreen mode');
  36. pybackground=pygame.Surface(pyscreen.get_size());
  37. pybackground.fill((int(bgcsplit[0]),int(bgcsplit[1]),int(bgcsplit[2])));
  38. pygame.display.set_caption('PyClock Test App');
  39. print('setting caption "PyClock Test App"');
  40. pygame.mouse.set_visible(0);
  41. pygame.display.get_active();
  42. # pygame.display.toggle_fullscreen();
  43. pygame.font.init();
  44. print('init pygame font');
  45. toppyfont=pygame.font.Font(fonttopload, int(fonttopsize));
  46. print('loading top font file "%s"' % fonttopload);
  47. print('setting top font size %s' % fonttopsize);
  48. bottompyfont=pygame.font.Font(fontbottomload, int(fontbottomsize));
  49. print('loading bottom font file "%s"' % fontbottomload);
  50. print('setting bottom font size %s' % fontbottomsize);
  51.  
  52. done = False
  53. while not done:
  54.    pyscreen.fill((int(bgcsplit[0]),int(bgcsplit[1]),int(bgcsplit[2])));
  55.    time1=toppyfont.render(strftime(dateformat), 1, (int(fncsplit[0]),int(fncsplit[1]),int(fncsplit[2])));
  56.    time2=bottompyfont.render(strftime(timeformat), 1, (int(fncsplit[0]),int(fncsplit[1]),int(fncsplit[2])));
  57.    a=pygame.sprite.Sprite();
  58.    a.image=time1;
  59.    a.rect=time1.get_rect();
  60.    a.rect.center=((int(tfxysplit[0]),int(tfxysplit[1])));
  61.    b = pygame.sprite.Sprite();
  62.    b.image=time2;
  63.    b.rect=time2.get_rect();
  64.    b.rect.center=((int(bfxysplit[0]),int(bfxysplit[1])));
  65.    group=pygame.sprite.RenderUpdates(a, b);
  66.    group.clear(pyscreen, pybackground);
  67.    rects = group.draw(pyscreen);
  68.    pygame.display.update(rects);
  69.    pygame.display.update();
  70.    for event in pygame.event.get():
  71.       if (event.type == KEYUP) or (event.type == KEYDOWN):
  72.          if (event.key == K_ESCAPE):
  73.             done = True
  74.  
  75. pygame.font.quit();
  76. print('uninit pygame font');
  77. pygame.display.quit();
  78. print('uninit pygame x11 display');
  79. quit();
  80. print('uninit pygame');
  81. print('exiting python');
  82. exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement