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
| # -*- coding:utf-8 -*-
from Tkinter import *
#Variables globales
# taille de l'image
l = 300
h = 300
# tableau indexe par des noms
f = {'largeur':l,'hauteur':h,'cadre':None,'image':None}
#fonction effacer
def effacer():
fond.delete('all')
#fonction afficher image pgm
def img_pgm():
item=fond.create_image(150,150,image=photo)
photo.configure(file="carte-pgm-binaire.pgm")
#fonction afficher image ppm
def img_ppm():
item=fond.create_image(150,150,image=photo)
photo.configure(file="carte-ppm-binaire.ppm")
#fenetre
fen3=Tk()
#creation de canvas
fond=Canvas(fen3, height=300, width=300, bg="black")
photo=PhotoImage(file="carte-pgm-binaire.pgm")
item=fond.create_image(150,150,image=photo)
fond.pack(side=LEFT)
#button afficher carte pgm
bout3=Button(fen3,text='image PGM', command=img_pgm)
bout3.pack()
#button afficher carte ppm
bout4=Button(fen3,text='image PPM', command=img_ppm)
bout4.pack()
#buton quitter
bout1=Button(fen3,text='quitter', command=fen3.quit)
bout1.pack()
#buton effacer
bout2=Button(fen3,text='effacer', command=effacer)
bout2.pack()
fen3.resizable(width=False, height=False)
fen3.mainloop()
#fen3.destroy() |
Partager