Test commit
[couchpytato.git] / mod_mainmenu.py
blob987730d5ce6aee52f02d466820541fc95eb5ad5b
1 import gui, pygame, os, time, mod, cfg
2 from pygame.locals import *
4 class Module(mod.Module):
5 def __init__(self, screen):
6 mod.Module.__init__(self, screen)
8 def init(self):
9 i = 0
10 for module in cfg.cf['modules'].values():
11 if module['modfilename'] != 'mod_mainmenu':
12 self.gui['LIST'].add(module['title'], cfg.cf['modules'].keys()[i], self.loadmod, self.showicon)
13 i += 1
14 self.gui['LIST'].makelist()
15 self.showgeneralgui()
16 cfg.lastmodname = cfg.modname
18 def showicon(self, value):
19 if os.path.isfile(cfg.thpath(cfg.cf['modules'][value]['prefix'] + '_icon.png')):
20 self.changebykey('ICON', cfg.thpath(cfg.cf['modules'][value]['prefix'] + '_icon.png'))
21 else:
22 self.changebykey('ICON', cfg.thpath('blank.png'))
24 def loadmod(self, value):
25 cfg.modname = value
26 cfg.modcf = cfg.cf['modules'][value]
27 self.loadmodule = value
29 def keyhandler(self, event):
30 if event.type == KEYDOWN:
31 if event.key == K_DOWN: self.gui['LIST'].select_next()
32 if event.key == K_UP: self.gui['LIST'].select_last()
33 if event.key == K_PAGEDOWN: self.gui['LIST'].next_page()
34 if event.key == K_RETURN: self.gui['LIST'].press()
35 if event.key == K_RIGHT: self.gui['LIST'].press()