#!/usr/bin/env /usr/bin/pythonw from Tkinter import * import os def test() : #get back the entry value fichier = entree.get() taille = len(fichier) fich = open('~/ofeli-1.5.0/tests/tutorial/ex2/ex2.m','r') #%s'%(fichier),'r') if (str(fich.readline())) != '#MESH!' : print "Erreur, le nom entre n'est pas un fichier de maillage" entree.delete(0,taille) else : print "Vous pouvez lancer l'execution" fich.close() def executer() : #get back the entry value fichier = entree.get() #execute the file with fichier for parameter os.system(("~/ofeli-1.5.0/tests/tutorial/ex2/ex2 ~/ofeli-1.5.0/tests/tutorial/ex2/%s"%(fichier))) #create a window fen = Tk() #the window title fen.title('ex2') #display a text text = Label(fen, text = 'Fichier de maillage') #put the text in first line first column text.grid() #cree une entree entree = Entry(fen) #put the text in first line third column entree.grid(row = 0, column = 2) #create a button which tests if the entered value is correct bouton2 = Button(fen, text = 'Test', command = test) #put the button in second line first column bouton2.grid(row = 1) #create a button which exexute the order when somebody clicks on "Execute" bouton = Button(fen, text = 'Execute', command = executer) #put the button in second line second column bouton.grid(row = 1, column = 1) #create a button which closes the window when somebody clicks on "Close" bouton1 = Button(fen, text = 'Close', command = fen.destroy) #put the button in first line third column bouton1.grid(row = 1, column = 2) fen.mainloop()