-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rokola.py
executable file
·208 lines (152 loc) · 5.98 KB
/
Rokola.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import xmmsclient
import os
import Controller
import Caja_paraLista
import serial
import time
class PrimeraRokola:
def __init__(self):
# -------------Ventana y Propiedades-----------------
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.fullscreen()
self.window.set_title("Rokola")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(50)
self.box_grande = gtk.HBox(False, 0)
self.window.add(self.box_grande)
#-----------------------------------------------------
#-------------Ventana para Bloqueo--------------------
self.muro = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.muro.fullscreen()
self.muro.set_title("MURO")
self.muro.set_border_width(50)
image = gtk.Image()
image.set_from_file("Pantalla.gif")
image.show()
self.muro.add(image)
#------------------------------------------------------
self.player = Controller.Controller({})
self.player.stop()
self.player.clear()
self.id_agregar = None
self.tam_pls = 0
self.store_1 = self.create_model()
self.store_2 = None
self.store_3 = None
self.lista_Izq = Caja_paraLista.Caja_lista(self.store_1, "Inicial")
self.lista_Cen = Caja_paraLista.Caja_lista(self.store_2, "Artista")
self.lista_Der = Caja_paraLista.Caja_lista(self.store_3, "Cancion")
#agregar las cajas para lista al BOX
self.box_grande.pack_start(self.lista_Izq.sw, True, True, 0)
self.box_grande.pack_start(self.lista_Cen.sw, True, True, 0)
self.box_grande.pack_start(self.lista_Der.sw, True, True, 0)
# Creates a new button with the label "Button 1".
self.button1 = gtk.Button("Agregar")
# Now when the button is clicked, we call the "callback" method
# with a pointer to "button 1" as its argument
self.button1.connect("clicked", self.play_callback, "button agregar")
self.lista_Izq.tV.connect("row-activated", self.artistas)
self.lista_Cen.tV.connect("row-activated", self.canciones)
self.lista_Der.tV.connect("row-activated", self.accion)
self.box_grande.pack_start(self.button1, True, True, 0)
self.window.show_all()
def play_callback(self, widget, data):
if self.id_agregar:
if self.player.is_playing():
self.player.add_idtopls(self.id_agregar)
else:
self.player.clear()
self.player.add_idtopls(self.id_agregar)
self.player.play_start()
#self.player.play(self.tam_pls) # el cero es el numero de la cacion
self.tam_pls = self.tam_pls + 1
print self.tam_pls
print "Hello again - %s was pressed" % data
self.id_agregar = None
self.bloqueo()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def create_model(self):
Inicial = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M","N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
store = gtk.ListStore(str)
for Ini in Inicial:
store.append([Ini])
return store
def artistas(self, widget = None, row = None, col = None):
if widget != None:
model = widget.get_model()
text = model[row][0]
else:
text = None
store = gtk.ListStore(str)
store.clear()
artist = self.player.get_av_artist_list()
print "Buscando artistas con Inicial = %s " % text
for art in artist:
U = art["artist"]
if U != None:
if U[0] == text:
store.append([U])
self.lista_Cen.tV.set_model(store)
def canciones(self, widget = None, row = None, col = None):
if widget != None:
model = widget.get_model()
text = model[row][0]
else:
text = None
store = gtk.ListStore(str, int)
store.clear()
artistmatch = self.player.create_a_coll(text)
print artistmatch
for art in artistmatch:
U = art["title"]
X = art["id"]
print U
print X
if U != None:
store.append([U, X])
self.lista_Der.tV.set_model(store)
def accion(self, widget = None, row = None, col = None):
print '----------acciones----------'
if widget != None:
model = widget.get_model()
text = model[row][0]
ids = model[row][1]
else:
text = None
print text
print ids
self.id_agregar = ids
def bloqueo(self):
print '-----------para bloquear pantalla ------------'
bit = 'B'
self.muro.show_all()
while gtk.events_pending():
gtk.main_iteration(False)
#limpiar la columnas despues de desbloqueo
self.lista_Cen.tV.set_model(None)
self.lista_Der.tV.set_model(None)
#se define la entrada serial
usbport = '/dev/ttyUSB0'
ser = serial.Serial(usbport, 9600, timeout=1)
cont = 0
while bit != 'h':
bit = ser.read(1)
print cont
cont = cont + 1
self.muro.hide_all()
while gtk.events_pending():
gtk.main_iteration(False)
def main():
gtk.main()
return 0
if __name__ == "__main__":
rokola = PrimeraRokola()
main()