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
| from tkinter import *
class Application(Frame):
def __init__(self, master):
Frame.__init__(self,master)
self.grid()
self.frameLeftTop()
self.frameLeftBottom()
self.frameRightTop()
self.frameRightBottom()
def frameLeftTop(self):
self.leftTop = Frame(root,width=400,height=200,pady=5,bg="red")
self.leftTop.grid(row=0, column=0)
Label(self.leftTop,text="Label 1").grid(row=0, column=0,sticky="wn")
## Text(self.leftTop,height=6,width=40).grid(row=1,column=0,sticky="wn")
## Button(self.leftTop,text="Exécuter",width=50,bg="white").grid(row=2,column=0,sticky="wn")
def frameLeftBottom(self):
self.leftBottom = Frame(root,width=400,height=200,pady=5,bg="green")
self.leftBottom.grid(row=1, column=0)
Label(self.leftBottom,text="Label 2").grid(row=1, column=0,sticky="n")
def frameRightTop(self):
self.rightTop = Frame(root,width=400,height=200,pady=5,bg="yellow")
self.rightTop.grid(row=0, column=1)
Label(self.rightTop,text="Label 3").grid(row=0, column=1,sticky="n")
def frameRightBottom(self):
self.rightBottom = Frame(root,width=400,height=200,pady=5,bg="black")
self.rightBottom.grid(row=1, column=1)
Label(self.rightBottom,text="Label 4").grid(row=1, column=1,sticky="n")
root = Tk()
root.title("Frames")
root.geometry("800x400")
app = Application(root)
root.mainloop() |
Partager