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
| #!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter as TK
from tkFileDialog import asksaveasfilename
from tkMessageBox import showinfo
def exporter ():
filepath = asksaveasfilename(
title="exporter",
filetypes=[
('jpgfiles', '.jpg'),
('shapefiles', '.shp'),
]
)
if filepath:
with open(filepath, "w") as file_out:
# ceci est juste un exemple d'écriture de données
for i in range(10):
file_out.write("Ligne {}: données exportées\n".format(i))
# end for
# end with
# notification
showinfo("Succès", "Fichier exporté avec succès.")
# end if
# end def
root = TK.Tk()
TK.Button(root, text="Exporter", command=exporter).pack(padx=10, pady=10)
root.mainloop() |
Partager