URL: https://linuxfr.org/forums/programmation-python/posts/script-et-ihm-sous-tk Title: Script et ihm sous tk Authors: supai Date: 2007年01月10日T19:23:59+01:00 Tags: Score: 0 J'ai developpe un script, puis un ihm. Mais je n'arrive pas à les faire dialoguer ensemble. Quelqu'un peut m'aider voici le script #------------------------Partie SCRIPT from Tkinter import * from os import chdir chdir("/Volumes/GERTEX/_test/") #chdir("/_test/") import shutil, string, re #Création du widget principal ("parents") fen1 = Tk() fen1.title("ALERT_TAGLIST") obfic = open("taglist.txt","r") # Lecture ds le fichier taglist des 60 dernières lignes lignes = obfic.readlines()[-59:] obfic.close() obfic = open("tampon_taglist.txt","w") # Copie ds le fichier tampon_taglist des 60 dernières lignes obfic.write("".join(lignes)) obfic.close() chIn1 = raw_input('Remplacer la chaine de caracteres de id1 ') chIn2 = raw_input('Par la nouvelle chaine de caractere de id1 suivante ') chIn3 = raw_input('Remplacer la chaine de caracteres de id2 ') chIn4 = raw_input('Par la nouvelle chaine de caractere de id2 suivante ') chIn5 = raw_input('Remplacer le mnemonic ') chIn6 = raw_input('Par le mnemonic suivant ') s = open('/Volumes/GERTEX/_test/tampon_taglist.txt','r') o = open('/Volumes/GERTEX/_test/tampon1_taglist.txt','w') for i in s.readlines(): o.write('%s\n' % i.replace(chIn1 , chIn2)),('%s\n' % i.replace(chIn3 , chIn4)),('%s\n' % i.replace(chIn5 , chIn6)) s.close() o.close() #------------------------Partie GUI #Création de widgets 'Label' et 'Entry' txt1 = Label(fen1, text = 'Ancien ID1:') txt2 = Label(fen1, text = 'Nouveau ID1:') txt3 = Label(fen1, text = 'Ancien ID2:') txt4 = Label(fen1, text = 'Nouveau ID2:') txt5 = Label(fen1, text = 'Ancien mnemonic:') txt6 = Label(fen1, text = 'Nouveau mnemonic:') txt7 = Label(fen1, text = '') bou1 = Button(fen1, text='Valider', command = fen1.destroy) entr1 = Entry(fen1) entr2 = Entry(fen1) entr3 = Entry(fen1) entr4 = Entry(fen1) entr5 = Entry(fen1) entr6 = Entry(fen1) entr7 = Entry(fen1) entr8 = Entry(fen1) #Création d'un widget 'Canvas' contenant une image bitmap #can1 = Canvas(fen1, width =160, height =160, bg ='white') #photo = PhotoImage(file ='1.gif') #item = can1.create_image(80, 80, image =photo) #Mise en page à l'aide de la méthode 'grip' txt1.grid(row =0) txt2.grid(row =1) txt3.grid(row =2) txt4.grid(row =3) txt5.grid(row =4) txt6.grid(row =5) txt7.grid(row =6) bou1.grid(row =7) entr1.grid(row =0,column =1) entr2.grid(row =1,column =1) entr3.grid(row =2,column =1) entr4.grid(row =3,column =1) entr5.grid(row =4,column =1) entr6.grid(row =5,column =1) #can1.grid(row =1, column =3, rowspan =3, padx =10, pady =5) #Démarrage fen1.mainloop()

AltStyle によって変換されたページ (->オリジナル) /