Python diary--using Tkinter to learn GUI design

Source: Internet
Author: User

2017.12.28

First introduce the various components and standard properties used by Tkinter:

Component:

Button Button control; Displays the button in the program.
Canvas A canvas control; display graphic elements such as lines or text
Checkbutton Multi-box control; for providing multiple selection boxes in a program
Entry Input controls for displaying simple text content
Frame A frame control that displays a rectangular area on the screen and is used as a container
Label Label control; can display text and bitmaps
Listbox A list box control; a ListBox widget is used to display a list of strings to the user
Menubutton The menu button control, because the menu item is displayed.
Menu Menu controls, display menu bars, drop-down menus, and pop-up menus
Message Message control: Used to display multiple lines of text, similar to label
Radiobutton radio button control; Displays a single-selected button state
Scale A range control that displays a numeric scale that is a range of numbers for the output limit
Scrollbar A scrollbar control that is used when the content exceeds a visual area, such as a list box ...
Text Text control; for displaying multiple lines of text
TopLevel A container control that provides a separate dialog box, similar to a frame
Spinbox Input controls, similar to entry, but can specify input range values
Panedwindow Panedwindow is a window layout-managed plug-in that can contain one or more child controls.
Labelframe Labelframe is a simple container control. Commonly used with complex window layouts.
Tkmessagebox A message box to display your application.

Standard properties:

Dimension Control size;
Color Control color;
Font control font;
Anchor Anchor Point;
Relief control style;
Bitmap Bitmap
Cursor Cursor

Write a simple form program yourself.

ImportTkinter as TK fromTkinterImportMessageBoxclassapp:def __init__(self,root): Frame=tk. Frame (Root) frame.pack () Self.hi_there=tk. Button (frame,text="Greeting", fg="Blue", command=Self.say_hi) self.hi_there.pack (Side=tk. left)defSay_hi (self): Messagebox.askokcancel (title="Is you sure", message="How is it ?") Root=tk. Tk () app=app (Root) root.mainloop ()

Python diary--using Tkinter to learn GUI design

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.