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
|
from Tkinter import *
import tkFileDialog
import tkMessageBox
class Application:
def __init__(self, boss):
self.parent = boss
#Ceci permet d'associer (binder) le destroy du widget parent avec la croix en haut a droite de "close"
self.parent.protocol("WM_DELETE_WINDOW",self.parent.destroy)
self.parent.title("Fenetre Principale")
self.sourcelabel = Label(self.parent, text = 'fichier source', fg = 'black')
self.file = StringVar()
self.garfield = Entry(self.parent, text = self.file)
self.parcbutton = Button(self.parent, text = 'Parcourir', command = self.get_filename)
self.okbutton = Button(self.parent, text = 'OK', command = self.import_extract)
self.exitbutton = Button(self.parent, text = 'Quitter', command = self.parent.quit)
self.sourcelabel.grid(row = 1)
self.garfield.grid(row = 2, column = 0)
self.parcbutton.grid(row = 2, column = 1)
self.okbutton.grid(row = 2, column = 2)
self.exitbutton.grid(row = 3, column = 1)
def run(self):
self.parent.mainloop()
def get_filename(self):
texfile = tkFileDialog.askopenfilename(filetypes = [("Fichiers LaTeX", "*.tex")])
if not texfile:
self.file.set("Aucun")
else:
self.file.set(texfile)
def import_extract(self):
import essai
root = Tk()
root.configure(width = 500, height = 500)
appli = Application(root)
appli.run() |
Partager