1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #!/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('/C/python24/ofeli/tests/tutorial/ex2/%s'%(fichier),'r')
tkFileDialog.askopenfilename(filetypes = [("All", "*"),("fichier de maillage","*.m")])
if str(fich.readline()) != '#MESH!\n' :
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 run() :
#get back the entry value
fichier = entree.get()
#execute the file with fichier for parameter
os.system(("/C/python24/ofeli/tests/tutorial/ex2/ex2 ~/ofeli/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 = 'run', command = run)
#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() |
Partager