Python tkinter Simple Layout Instance Tutorial _python

Source: Internet
Author: User
Tags pack

The example in this article shows the Python Tkinter method for implementing a simple layout, with a more detailed annotation for the reader to understand. Share for everyone to use for reference. as follows:

#-*-Coding:utf-8-*-from tkinter import * root = Tk () # 80x80 represents the size of the main window at initialization time, 0, 0 represents the location of the window at initialization root.geometry (' 80x80+10 +10 ') # padding Direction ' label (root, Text = ' L1 ', bg = ' red '). Pack (fill = Y) Label (root, Text = ' L2 ', bg = ' green '). Pack (fill = B OTH) label (root, Text = ' L3 ', bg = ' blue '). Pack (fill = X) # Left and right layout Label (root, Text = ' L1 ', bg = ' red '). Pack (fill = Y, sid E = left) label (root, Text = ' L2 ', bg = ' green '). Pack (fill = BOTH, side = right) label (root, Text = ' L3 ', bg = ' Blue '). pac K (fill = X, side = left) # absolute Layout L4 = Label (root, Text = ' L4 ') l4.place (X = 3, y = 3, anchor = NW) ' # grid grid layout L1 = L 
Abel (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) l

 2.grid (row = 1, column = 0) l3.grid (row = 1, column = 1) l4.grid (row = 2) l5.grid (row = 0, column = 3) root.mainloop ()

The grid grid layout works as shown in the following illustration:

Interested readers can test the effect of the example of this article, I believe that the Python program for everyone to have some reference value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.