# coding=UTF-8 import pygtk pygtk.require('2.0') import gtk import gtk.glade import pickle import os from grid_button import * from selection_manager import * from joy_manager import * class Grid: def __init__(self,core,name,rows,cols,id,button_list=None,parent_grid=None): #super(Grid,self).__init__() # initializing gtk.Widget self.name=name self.rows=rows self.cols=cols self.id=id self.is_an_opened_file=False self.parent_grid=parent_grid self.cfg_manager=core.conf_manager self.joy=core.joy self.core=core self.selection_manager=None if button_list==None: self.button_list=[] #print "button list is empty" else: self.button_list=[] count=0 self.vbox=gtk.VBox(True,self.cols) self.vbox.show() hbox=gtk.HBox(True,self.rows) hbox.show() ccount=0 for item in range((self.rows*self.cols)): if count < self.rows: #print ("%s - %s"%(item,count)) if button_list==None: #default button #button=Grid_Button(None,None,"Mallige Normal","#000000") #testing button #def __init__(self,parent_grid,img_path=None,text=None,font=None,color=None,mode=None,synth_line=None,sound=None,grid=None): button=Grid_Button(self,"../rsrc/default.png","Texto %s"%(item+1),"URW Palladio L Italic 12","#000000","SYNTH","Boton numero %s"%(item+1)) else: #print "loading button [%s]"%item button=Grid_Button(self,button_list[item].image_path,button_list[item].text,button_list[item].font,button_list[item].font_color,button_list[item].mode,button_list[item].synth_line,button_list[item].sound,button_list[item].grid_link) self.button_list.append(button) #button.connect("clicked",button.print_variables) hbox.pack_start(button,True,True,0) if count == self.rows -1: #print "Row done..." self.vbox.pack_start(hbox,True,True,0) hbox=gtk.HBox(True,self.rows) hbox.show() count=-1 count+=1 self.selection_manager=Selection_Manager(self.rows,self.cols,self.button_list,self.cfg_manager,self.joy) # must be initialized AFTER the buttons #def __init__ def get_data(self): return (self.name,self.rows,self.cols) #def get_data def destroy_(self, widget, data=None): gtk.main_quit() #def destroy def add_grid(self,path,id): self.core.winmain.open_grid(path,id) #def add_grid def dump(self): joy=self.joy core=self.core sm=self.selection_manager self.joy=None self.core=None self.winmain=None #self.cfg_manager=None #self.vbox=None self.selection_manager=None file_name=os.path.expanduser("~/"+self.name+".grid") output = open(file_name, 'wb') pickle.dump(self, output, -1) output.close() self.joy=joy self.selection_manager=sm self.core=core joy=None sm=None core=None #def dump def create_keyboard(self): #def __init__(self,core,name,rows,cols,id,button_list=None,parent_grid=None): grid=Grid(self.core,"Teclado",14,5,self.core.id_counter) #def set_values(self,path,text,font,color,synth_line,sound,grid_link,mode): grid.button_list[0].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[1].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[2].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[3].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[4].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[5].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[6].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[7].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[8].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[9].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[10].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[11].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[12].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[13].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[14].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[15].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[16].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[17].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[18].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[19].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[20].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[21].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[22].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[23].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[24].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[25].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[26].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[27].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[28].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[29].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[30].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[31].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[32].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[33].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[34].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[35].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[36].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[37].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[38].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[39].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[40].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[41].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[42].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[43].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[44].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[45].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[46].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[47].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[48].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[49].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[50].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[51].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[52].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[53].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[54].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[55].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[56].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[57].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[58].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[59].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[60].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[61].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[62].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[63].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[64].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[65].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[66].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[67].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[68].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") grid.button_list[69].set_values(None,"º","URW Palladio L Italic 12","#000000","",None,"SYNTH") self.add_grid(grid) #class Grid '''if __name__=="__main__": grid=Grid("Grid 3",7,7) pkl_file = open('/home/hector/data1.pkl', 'rb') tmp_grid = pickle.load(pkl_file) grid=Grid(tmp_grid.name,tmp_grid.rows,tmp_grid.cols,tmp_grid.button_list) window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_size_request(400, 100) window.connect("destroy", grid.destroy) window.set_border_width(10) window.show() window.add(grid.vbox) sm=Selection_Manager(grid) #grid.dump() gtk.main()'''