import gtk import gtk.glade import Core class WinBtnSetup: def __init__(self,grid_button): print("WinBtnSetp::init()") self.grid_button=grid_button self.uitree=gtk.glade.XML(Core.Core.RSRC_PATH+"/winbtnsetup.glade") self.win=self.uitree.get_widget("winbtnsetup") btnok=self.uitree.get_widget("btnOk") btncancel=self.uitree.get_widget("btnCancel") self.chsimage=self.uitree.get_widget("chsImage") self.chsmedia=self.uitree.get_widget("chsMedia") self.chsopengrid=self.uitree.get_widget("chsOpenGrid") self.imgpreview=self.uitree.get_widget("imgPreview") self.btnfont = self.uitree.get_widget("btnFont") self.btncolor = self.uitree.get_widget("btnColor") btnok.connect("clicked",self.OnBtnOkClick) btncancel.connect("clicked",self.OnBtnCancelClick) self.chsimage.connect("selection-changed",self.OnChsImageFileSet) #self.chsmedia.connect("selection-changed",self.OnChsMediaFileSet) #self.chsopengrid.connect("selection-changed",self.OnChsOpenGridFileSet) filter = gtk.FileFilter() filter.set_name("Images") filter.add_pattern("*.png") filter.add_pattern("*.jpg") filter.add_pattern("*.gif") filter.add_pattern("*.tif") filter.add_pattern("*.xpm") self.chsimage.add_filter(filter) filter = gtk.FileFilter() filter.set_name("Media") filter.add_pattern("*.wav") filter.add_pattern("*.ogg") filter.add_pattern("*.mp3") self.chsmedia.add_filter(filter) filter = gtk.FileFilter() filter.set_name("Grids") filter.add_pattern("*.grid") self.chsopengrid.add_filter(filter) self.btnfont.connect("font-set",self.OnBtnFontFontSet) self.btncolor.connect("color-set",self.OnBtnColorColorSet) self.txtName=self.uitree.get_widget("txtName") self.txtSpeech=self.uitree.get_widget("txtSpeech") self.rdbSpeech=self.uitree.get_widget("rdbSpeech") self.rdbMedia=self.uitree.get_widget("rdbMedia") self.rdbOpenGrid=self.uitree.get_widget("rdbOpenGrid") self.rdbCloseGrid=self.uitree.get_widget("rdbCloseGrid") self.win.set_title("Button Configuration") self.win.show() def OnBtnOkClick(self,data): # print("WinBtnSetup::OnBtnOkClick()") mode=None go_out=False if self.rdbSpeech.get_active(): mode="SYNTH" go_out=True if self.rdbMedia.get_active(): mode="MEDIA" go_out=True if self.rdbOpenGrid.get_active(): mode="OPEN" go_out=True if self.rdbCloseGrid.get_active(): if self.grid_button.parent_grid.parent_grid==None: print "You're not a child grid" go_out=False else: mode="GOBACK" go_out=True self.grid_button.set_values(self.chsimage.get_filename(),self.txtName.get_text(),self.btnfont.get_font_name(),self.btncolor.get_color().to_string(),self.txtSpeech.get_text(),self.chsmedia.get_filename(),self.chsopengrid.get_filename(),mode) if go_out: self.win.destroy() def OnBtnCancelClick(self,data): #print("WinBtnSetup::OnBtnCancelClick()") self.win.destroy() def OnChsImageFileSet(self,data): #print("Set Image file: " + str(data.get_filename())) if data.get_filename()!=None: pixbuf = gtk.gdk.pixbuf_new_from_file(data.get_filename()) pixbuf = pixbuf.scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR) self.imgpreview.set_from_pixbuf(pixbuf) #else: # self.imgpreview.set_from_file(data.get_filename()) def OnChsMediaFileSet(self,data): pass def OnChsOpenGridFileSet(self,data): pass def OnBtnFontFontSet(self,data): print("Da Font: "+str(self.btnfont.get_font_name())) def OnBtnColorColorSet(self,data): print("Da color: "+ str(self.btncolor.get_color()) )