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
| #-*- coding:Utf-8 -*-
from Tkinter import*
class BarreDesMenus(Frame):
def __init__(self, boss = None):
Frame.__init__(self, borderwidth = 2)
BoutonMenu1 = Menubutton(self, text =" Informations ")
BoutonMenu1.pack(side= RIGHT)
menu1 = Menu(BoutonMenu1)
menu1.add_command(label = "menu1", command = boss.commandmenu1)
menu1.add_command(label = "menu2", command = boss.commandmenu2)
menu1.add_command(label = "menu3", command = boss.commandmenu3)
BoutonMenu1.configure(menu = menu1)
class Application(Frame):
def __init__(self, boss = None):
Frame.__init__(self)
BarreMenus = BarreDesMenus(self) #FRAME 1
BarreMenus.pack()
#--------------------------- TOUTES LES COMMANDES AUXILIAIRES ---------------------------#
def commandmenu1(self):
fenetre_commandmenu1 = Tk()
fenetre_commandmenu1.title("Menu1")
#fenetre_commandmenu2.destroy
#fenetre_commandmenu3.destroy
#je voulais mettre un truc pour eviter que il y ait toutes les fentre ouvertes en meme temps
msg = Label(fenetre_commandmenu1, text="texte ici").grid(row = 1, column = 1)
Bouttonretour = Button(fenetre_commandmenu1, text=" Retour ", command = fenetre_commandmenu1.destroy).grid(row=2, column=1)
def commandmenu2(self):
fenetre_commandmenu2 = Tk()
fenetre_commandmenu2.title("menu2")
msg = Label(fenetre_commandmenu2, text="texte ici").grid(row = 1, column = 1)
Bouttonretour = Button(fenetre_commandmenu2, text=" Retour ", command = fenetre_commandmenu2.destroy).grid(row=2, column=1)
def commandmenu3(self):
fenetre_commandmenu3 = Tk()
fenetre_commandmenu3.title("menu3")
msg = Label(fenetre_commandmenu3, text="texte ici").grid(row = 1, column = 1)
Bouttonretour = Button(fenetre_commandmenu3, text=" Retour ", command = fenetre_commandmenu3.destroy).grid(row=2, column=1)
appli = Application()
appli.mainloop() |
Partager