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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| main = tk.Tk()
f1= tk.Frame(main)
print "------- start interface script ------ "
main.title("Multiple Choice Listbox")
#variables
fields= ["ANNEE","CHEMIN"]
recap = "S:\Cartographie\Bases\Data\ABase_copie.mdb" + os.sep + "Recap_integration"
print recap
annee = "1111"
txt = list()
list_chemin=[]
list_MDB = []
#start
print "********************* liste des chemins pour l'annee 1111 *****"
search = arcpy.SearchCursor(recap,sort_fields= "CHEMIN")
for row in search:
test1 = row.getValue("CHEMIN")
test2 = row.getValue("ANNEE")
if test2 == 1111 :
print(test1)
txt.append(test1)
reslist = list()
def select(): # fonction pour afficher la selection
seleccion = lstbox.curselection()
for i in seleccion:
entrada = lstbox.get(i)
reslist.append(entrada)
for val in reslist:
print(val)
def CallScript(): # fonction pour appeller le script_recap
select()
print("start")
main.destroy()
sys.argv=[reslist]
#os.system('callscript_juin.py')
execfile('script_recap.py')
print("End")
lstbox = tk.Listbox(f1, selectmode= "multiple", width=80, height=30, font =('arial', 10, 'bold'), fg="black") #definition de listbox
for j in txt:
#print(j)
lstbox.insert(ACTIVE, j) #remplir la listbox
lstbox.pack()
label = Label(main, text=" liste des chemins ", font =('arial', 18, 'bold'), fg="blue")
label.pack()
s1 = tk.Scrollbar(f1)
lstbox.config(yscrollcommand = s1.set)
s1.config(command = lstbox.yview)
lstbox.pack(side = tk.LEFT, fill = tk.Y)
s1.pack(side = tk.RIGHT, fill = tk.Y)
f1.pack()
btn = tk.Button(main, text="Traitement", font =('arial', 12, 'bold'), fg="green", command=CallScript) # Création d'un widget Button (bouton traitement)
btn.pack()
btn = tk.Button(main, text=" Quitter ", font =('arial', 12, 'bold'), fg="red", command=main.destroy) # Création d'un widget Button (bouton quitter)
btn.pack()
main.mainloop() |
Partager