Tkinter _ a simple window

Source: Internet
Author: User

# Encoding = utf-8import tkinter as TK # create a window = TK. TK () # Set the window title window. title ("My first tkinter window") # Set the window size window. geometry ("300x200") # defines string variables. You can set and obtain the value Var = TK of string variables. stringvar () color_flag = false # define the action when you click the button, alternately explicit \ non-explicit label text def get_label_color (): Global color_flag if color_flag = false: color_flag = true var. set ("I Have Been clicked") else: color_flag = false var. set ("") # define a label. bg is the background color label_1 = TK. label (window, textvar = var, BG = "green", width = 20, Height = 2, font = 20) # Place the label on the window label_1.pack () # define a button = TK. button (window, text = "Click me", width = 15, Height = 2, command = get_label_color) # Place the button on the window button. pack () # loop detection window. mainloop ()

Tkinter _ a simple window

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.