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