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 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| # -*- coding: utf-8 -*-
from Tkinter import *
from PIL import Image,ImageTk
import tkMessageBox
import wx
class FenPrincipale:
def __init__(self):
"""Constructeur de la fenetre principale"""
self.root = Tk()
self.can = Canvas(self.root,width = 600, height = 450, bd=10,relief=RIDGE)
self.can.tag_bind('toggle_cursor', '<Enter>', lambda e: self.can.configure(cursor = 'hand1'))
self.can.tag_bind('toggle_cursor', '<Leave>', lambda e: self.can.configure(cursor=''))
self.imageCategorie = Image.open("Images/Icones/CercleCategorie.png")
self.imageCategorie.thumbnail((100, 100), Image.ANTIALIAS)
self.imgCategorie = ImageTk.PhotoImage(self.imageCategorie)
self.Categorie = self.can.create_image(455,230,image=self.imgCategorie,tag='toggle_cursor')
self.can.tag_bind(self.Categorie,'<Button-1>',FenCategorie)
Button(self.root,text='Categorie',command=FenCategorie).pack()
Button(self.root,text='Quitter',command=self.root.quit).pack()
self.can.pack()
self.root.mainloop()
def rayQuit(self,event=None):
self.root.quit()
class FenCategorie:
def __init__(self,event=None):
"""Constructeur de la fenêtre principale"""
#Creation de la fenetre principale
self.rootC = Toplevel()
self.rootC.geometry("%dx%d+%d+%d" %(180,250,(self.rootC.winfo_screenwidth()-180)/2,(self.rootC.winfo_screenheight()-250)/2))
self.rootC.resizable(width=False, height=False)
self.rootC.title('Catégorie')
#Creation du Menu
self.menuG = Menu(self.rootC)
self.menufichier = Menu(self.menuG,tearoff = 0)
self.menufichier.add_command(label = "Quitter",command=self.rootC.destroy)
self.menuG.add_cascade(label="Fichier", menu=self.menufichier)
self.rootC.config(menu=self.menuG)
#Affichage fond et icone
self.can = Canvas(self.rootC,width = 180, height = 250, bd=10,relief=RIDGE)
self.imagePhoto = Image.open("Images/Icones/fontCategorie.png")
self.imagePhoto.thumbnail((310,310), Image.ANTIALIAS)
self.imgPhoto = ImageTk.PhotoImage(self.imagePhoto)
self.can.create_image(90,125,image=self.imgPhoto)
self.can.pack()
# Programme principal
if __name__ == '__main__':
FenPrincipale() |
Partager