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
| from Tkinter import *
import tkMessageBox, sys,tkFont,tkFileDialog,xlrd
class Fenetre:
def __init__(self):
"""Constructeur de la fenêtre Ajout et modication de fichiers"""
self.root =Tk(className=' Ajout et modication de fichiers')# creation Ajout et modication de fichiers
"""Bouton Ajouter fichier"""
self.but1=Button(self.root, text='Ajouter fichier',command=self.Ajout_fichier,font=tkFont.Font(family="Arial",size=10 ), height=2,width =20,borderwidth=3)
self.but1.grid(row=2, column=0, sticky =W,padx =5,pady =5)
self.taille=0# taille du Labelframe Organe
self.num_ligne=4
self.num_organe=1
#self.text_organe="organe "
self.LF_org =LabelFrame(self.root, text= "Organe(s) à Exporter", width =550, height =50+self.taille,fg="blue")
self.LF_org.grid(padx =5,pady =5,columnspan=2)
Button(self.root,text='Quiter',font=tkFont.Font (family="Arial",size=10 ), height=2,width =20,borderwidth=3,command=self.root.destroy).grid(row=100, \
column=0, sticky =W,padx =5,pady =5)
Button(self.root, text='Exporter',font=tkFont.Font (family="Arial",size=10 ), height=2,width =20,borderwidth=3).grid(row=100, \
column=1, sticky =E,padx =5,pady =5)
self.root.mainloop()
def Ajout_fichier(self):
self.tab={}
self.enty_text=StringVar()# variable permettant de stocker l'emplacement du fichier selectionné
self.etat = IntVar()
filename= tkFileDialog.askopenfilename(title="Selectionnez votre fichie S'il vous plait" ,filetypes = [("Excel Files",".xls")])
if filename:
self.enty_text.set(str(filename))
text_organe=self.nom_organe(filename)
self.ch1 = Checkbutton(self.LF_org,text =text_organe ,state=ACTIVE ,selectcolor="green",
variable=self.etat, onvalue=1,offvalue=0)
self.ch1.grid(row=self.num_ligne)
self.entree=Entry(self.LF_org,width=70,state=DISABLED )
self.entree.grid(row=self.num_ligne,column=2,padx =20,pady =5)
#repupere l'emplacement du fichier selectionné
self.entree['textvariable']=self.enty_text# mise a jour de la zone de texte
self.boutsup=Button(self.LF_org,text='Supprimer',font=tkFont.Font (family="Arial",size=7 ),command=self.supprimer_fichier, height=2,width =7,borderwidth=2)
self.boutsup.grid(row=self.num_ligne,column=3,sticky =E,padx =5,pady =5)
self.taille+=10 #la taille du FrameLabel s'augmente de 10 pixels
self.num_ligne+=1 #incremente le numero de ligne pour placer une nlle selection de fichier
self.num_organe+=1 # incremente le numero d"organe
Button(self.root,text='Modifier Fichier Ajouté',font=tkFont.Font (family="Arial",size=10 ),command=self.modifier_fichier, height=2,width =20,borderwidth=3).grid(row=2, \
column=1, sticky =E,padx =5,pady =5) # le bouton modifier n'apparait que si on ajoute un fichier |
Partager