import pygtk pygtk.require('2.0') import gtk import gtk.glade from grid import * from configuration_manager import * from custom_label import * class Label_Manager(gtk.Notebook): def __init__(self,core): super(Label_Manager, self).__init__() # initializing gtk.Notebook self.show() self.core=core self.grid_list=[] self.connect("switch-page",self.selection_manager_init) #self.connect("page-removed",self.selection_manager_init) self.connect("page-added",self.selection_manager_init) #def __init__ def add_grid(self,grid): # label=gtk.Label(grid.name) # print grid.id cl=Custom_Label(grid.name,grid) self.append_page(grid.vbox,cl) self.grid_list.append(grid) tmp=self.get_n_pages() tmp-=1 self.set_current_page(tmp) cl.notebook=self #self.next_page() #def add_grid #def callback(notebook, page, page_num, user_param1, ...) # def callback(notebook, type, user_param1, ...) #def callback(notebook, page, page_num, user_param1, ...) def selection_manager_init(self,notebook,page,page_num): #print "hey listen!" #print "Focus Tab [%s]"%self.get_current_page() # print "Grid list %s"%self.grid_list # if self.grid_list==0: # self=Label_Manager(self.core) # print "Focus Tab [%s]"%page_num # print "Grid list lenght: %s"%len(self.grid_list) if len(self.grid_list)>0: for item in self.grid_list: if item.id != page_num: # print "Grid ID[%s]'s selection manager is disabled"%item.id item.selection_manager.running=False else: # print "Grid ID[%s]'s selection manager is enabled"%item.id item.selection_manager.running=True # print item.id #def selection_manager_init def update_manager(self,id): # print "2 - Grid list %s"%self.grid_list # print self.core.id_counter # print len(self.grid_list) # if len(self.grid_list)==0: # print "!!!" # self=Label_Manager(self.core) if len(self.grid_list)>0: for item in self.grid_list: if item.id != id: pass else: item.selection_manager.running=True #def update_manager def update_counter(self): self.core.id_counter-=1 def delete_from_list(self, id): counter=0 print "quieres borrar %s"%id for item in self.core.winmain.opened_files: l_id,fname=item if id==l_id: self.core.winmain.opened_files.pop(counter) print "Closing [%s]..."%fname #else: # print ("id que me pasas [%s], id de la lista [%s]"%(id,l_id)) counter+=1 print self.core.winmain.opened_files def update_opened_list(self,to_edit_list): counter=0 list=[] print "me llegan %s"%to_edit_list for item in self.core.winmain.opened_files: l_id,fname=item for item2 in to_edit_list: if item2==l_id: l_id-=1 to_edit_list.pop(counter) counter+=1 print "actualizando..." counter=0 list.append((l_id,fname)) self.core.winmain.opened_files=list print "me quedan asi %s"%self.core.winmain.opened_files #class Label_Manager if __name__=="__main__": cfg_mngr=Configuration_Manager() cfg_mngr.load_cfg_file() grid2=Grid(cfg_mngr,"grid 2",3,7) grid3=Grid(cfg_mngr,"grid 3",4,2) pkl_file = open('/home/hector/data1.pkl', 'rb') tmp_grid = pickle.load(pkl_file) grid=Grid(cfg_mngr,tmp_grid.name,tmp_grid.rows,tmp_grid.cols,tmp_grid.button_list) window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_size_request(800, 600) window.connect("destroy", grid.destroy) window.set_border_width(10) window.show() lm=Label_Manager() lm.add_grid(grid) lm.add_grid(grid2) lm.add_grid(grid3) window.add(lm) gtk.main()