# -*- coding: cp1252 -*-
from Tkinter import *
class AutreEcran(Frame):
def __init__(self, boss, master = None, **kw):
Frame.__init__(self, master, **kw)
Label(self, text = "Autre écran", font = "Courier 12" ).grid(row = 1, column = 1, padx = 5, pady = 5)
Button(self, text = "Menu", font = "Courier 12", command = lambda : boss.autre_ecran(Menu)).grid(row = 2, column = 1, padx = 5, pady = 5)
class Menu(Frame):
def __init__(self, boss, master = None, **kw):
Frame.__init__(self, master, **kw)
Label(self, text = "Menu Principal", font = "Courier 12" ).grid(row = 1, column = 1, padx = 5, pady = 5)
Button(self, text = "Autre écran", font = "Courier 12", command = lambda : boss.autre_ecran(AutreEcran)).grid(row = 2, column = 1, padx = 5, pady = 5)
class Gui(Frame):
def __init__(self, master = None, **kw):
Frame.__init__(self, master, **kw)
self.widget = Menu(self)
self.widget.grid(row = 1, column = 1)
def autre_ecran(self, ecran):
self.widget.grid_forget()
self.widget = ecran(self)
self.widget.grid(row = 1, column = 1)
if __name__ == '__main__':
fen = Tk()
a = Gui(fen)
a.grid()
fen.mainloop()
|