import Resources import Grid import Player import gtk import gtk.glade import os import sys import glob import gobject import lxml.etree class Launcher: def __init__(self): self.log("init") self.resources = Resources.Resources() uitree=gtk.glade.XML(Resources.get_rsrc()+"/launcher.glade") self.winmain=uitree.get_widget("winmain") self.cmbGrid=uitree.get_widget("cmbGrid") self.btnClose=uitree.get_widget("btnClose") self.btnLaunch=uitree.get_widget("btnLaunch") self.winmain.connect("destroy",self.OnDestroy) self.btnClose.connect("clicked",self.OnBtnCloseClick) self.btnLaunch.connect("clicked",self.OnBtnLaunchClick) self.cmbGrid.connect("changed",self.OnCmbGridUpdate) #populating combo box store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_STRING) for proj in glob.glob(self.resources.get_grids()+"/*.AmicProject"): self.log(proj) for file in glob.glob(proj+"/*.grid"): print file #fast and ugly xml parsing document = lxml.etree.parse(file) root = document.getroot() for node in root: if node.tag=="gridname": store.append([node.text,file]) self.cmbGrid.set_model(store) self.winmain.show_all() def log(self,txt): print("[Launcher]:%s" % (txt)) def OnCmbGridUpdate(self,data): print self.cmbGrid.get_active() def OnDestroy(self,data): self.log("Quit") gtk.main_quit() def OnBtnCloseClick(self,data): self.log("Quit requested") gtk.main_quit() def OnBtnLaunchClick(self,data): model=self.cmbGrid.get_model() q=self.cmbGrid.get_active_iter() name=model.get_value(q,0) path=model.get_value(q,1) self.log("launching grid: "+name) self.log("path: "+path) self.winmain.hide() player = Player.Player(path) #end