This article mainly introduces the PythonTkinter simple layout example tutorial, including filling, left and right layout, absolute layout, grid layout, etc, for more information about how to use Python Tkinter, see the following example. Share it with you for your reference. The details are as follows:
#-*-Coding: UTF-8-*-from Tkinter import * root = Tk () #80x80 indicates the size of the main window during initialization, and indicates the location of the window during initialization as root. geometry ('80x80 + 10 + 10') # Fill 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) # Left and Right 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 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 = 'l4 ', bg = 'yellow') l5 = Label (root, text = 'l5 ', bg = 'purple') l1.grid (row = 0, column = 0) l2.grid (row = 1, column = 0) l3.grid (row = 1, column = 1) l4.grid (row = 2) l5.grid (row = 0, column = 3) root. mainloop ()
Shows the Running Effect of Grid layout:
If you are interested, you can test the running effect of the examples in this article. I believe it will be of some reference value for your Python program design.