#-*-Coding:utf-8-*-from Tkinter Import *root = Tk () # 80x80 represents the size of the main window at initialization, 0, 0 represents the location of the window at the time of initialization root.geometry (' 80x80+10+10 ' # Fill in Direction ' ' label (root, Text = ' L1 ', bg = ' red '). Pack (fill = Y) label (root, Text = ' L2 ', bg = ' green '). Pack (fill = BOTH) label (root, Text = ' L3 ', bg = ' blue '). Pack (fill = X) # Around layout label (root, Text = ' L1 ', bg = ' red '). Pack (fill = Y, side = left) label (root, Text = ' L2 ', bg = ' green '). Pack (fill = BOTH, side = right) Label (root, Text = ' L3 ', bg = ' blue '). Pack (fill = X, side = left) # Absolute Layout L4 = label (root, Text = ' L4 ') l4.place (x = 3, y = 3, anchor = NW) ' ' # grid grid layout L1 = label (root, Text = ' L1 ', BG = ' Red ') L2 = label (root, Text = ' L2 ', bg = ' blue ') L3 = label (root, Text = ' L3 ', bg = ' green ') L4 = label (root, Text = ' L 4 ', bg = ' yellow ') L5 = Label (root, Text = ' L5 ', bg = ' Purple ') l1.grid (row = 0, column = 0) l2.grid (row = 1, column = 0) l3.g RID (row = 1, column = 1) l4.grid (row = 2) l5.grid (row = 0, column = 3) root.mainloop ()
Python Tkinter Simple layout learning