1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import pygame
25 import os, sys
26 pygame.init()
28 - def __init__(self, fondo,FontName = None, FontSize = 40):
29 pygame.font.init()
30 self.font = pygame.font.Font(FontName, FontSize)
31 self.size = FontSize
32 self.fondo=fondo
33 - def render(self, text, color, pos):
34
35 x, y = pos
36 for i in text.split("\r"):
37 self.fondo.pantalla.blit(self.font.render(i, 1, color), (x, y))
38
39 y += self.size
40 -class VENTANA(pygame.sprite.Sprite):
41 """ Class doc """
42
44 """ Class initialiser """
45 pygame.sprite.Sprite.__init__(self)
46 self.pantalla=pygame.display.set_mode((800,600))
47 pygame.display.set_caption("proyecto icaro")
48 icono=pygame.image.load(sys.path[0] +"/imagenes/icaro.png")
49 pygame.display.set_icon(icono)
50 self.cadena=""
52 pygame.display.update()
53 pygame.event.get()
54 self.pantalla.fill((123,180,255))
55 self.mouse_x, self.mouse_y = pygame.mouse.get_pos()
56 self.mouse_buton=pygame.mouse.get_pressed()
57
58
59
60 -class BOTON(pygame.sprite.Sprite):
61 """ Class doc """
62 redct=0
63 - def __init__ (self,pantalla,x,y,img,ej,texto):
64 """ Class initialiser """
65 pygame.sprite.Sprite.__init__(self)
66 self.imagen=pygame.image.load(img)
67 self.pantalla=pantalla
68 self.posicion=x,y
69 self.ejecuta=ej
70 self.rect = self.imagen.get_rect()
71 self.rect[0]=x
72 self.rect[1]=y
73 self.texto=texto
75 y=100
76 self.pantalla.blit(self.imagen,self.posicion)
77 if self.rect.collidepoint (
78 ventana.mouse_x,
79 ventana.mouse_y
80 ):
81 for txt in self.texto:
82 texto.render(txt,(255,255,255),(350,y))
83 y+=40
84 if (
85 self.rect.collidepoint (
86 ventana.mouse_x,
87 ventana.mouse_y
88 ) and
89 ventana.mouse_buton[0]):
90 os.system(self.ejecuta)
91
92
93 -class SALIR(pygame.sprite.Sprite):
94 """ Class doc """
95
96 - def __init__ (self,pantalla,x,y,img,texto):
97 """ Class initialiser """
98 pygame.sprite.Sprite.__init__(self)
99 self.imagen=pygame.image.load(img)
100 self.pantalla=pantalla
101 self.posicion=x,y
102 self.rect = self.imagen.get_rect()
103 self.rect[0]=x
104 self.rect[1]=y
105 self.texto=texto
107 y=100
108 self.pantalla.blit(self.imagen,self.posicion)
109 if self.rect.collidepoint (
110 ventana.mouse_x,
111 ventana.mouse_y
112 ):
113 for txt in self.texto:
114 texto.render(txt,(255,255,255),(350,y))
115 y+=40
116 if (
117 self.rect.collidepoint (
118 ventana.mouse_x,
119 ventana.mouse_y
120 ) and
121 ventana.mouse_buton[0]):
122 exit()
123 pass
124 config=[]
125 pyt= ["Lanza la teminal interactiva ","con el modulo apicaro. Necesita ","tener IDLE instalado"]
126 tur= ["Lanza TurtleArt con el modulo ","Tortucaro. ","para manejo conectado ","a la netbook"]
127 icr= ["Lanza Icaro-bloques para ","manejo de robots autonomos"]
128 sal=["Sale del sistema"]
129 conf=open(sys.path[0] +"/config.dat","r")
130 dat=conf.readlines()
131 for txt in dat:
132 config.append(txt)
133 conf.close()
134 ventana=VENTANA()
135 BotonPython=BOTON(ventana.pantalla,100,10,sys.path[0] +"/imagenes/main/python.png","idle -c 'import apicaro; icaro=apicaro.puerto(); icaro.iniciar()'",pyt)
136 BotonIcaro=BOTON(ventana.pantalla,100,150,sys.path[0] +"/imagenes/main/icaro.png","python "+sys.path[0] +"/icaro.py",icr)
137 BotonTurtle=BOTON(ventana.pantalla,100,290,sys.path[0] +"/imagenes/main/tortucaro.png",config[1],tur)
138 texto=Text(ventana)
139 salir=SALIR(ventana.pantalla,100,430,sys.path[0] +"/imagenes/main/salir.png",sal)
141
142 while True:
143 for evento in pygame.event.get():
144 if evento.type==pygame.QUIT:
145 pygame.quit()
146 ventana.update()
147 BotonIcaro.update()
148 BotonTurtle.update()
149 BotonPython.update()
150 salir.update()
151
152 return 0
153
154 if __name__ == '__main__':
155 main()
156