uses Tkinter to quickly create GUI applications.Because Tkinter is built into the python installation package, the Tkinter library can be imported after Python is installed, and the IDLE is also compiled by Tkinter,
-and post-assigned values is different, the results are the same.
3. Create a canvas for drawing
To draw a picture, we need a different element:Canvas)Object, that is, the Canvas Class Object (provided by the tkinter module ).
When we create a canvas, we pass the width and height (in pixels) of the canvas to Python ). In other aspects, the Code is the same as tha
uses Tkinter to quickly create GUI applications.Since Tkinter is built into Python's installation package, as long as Python is installed to import the Tkinter library, and Idle is also written in Tkinter, for a simple graphical interface
= update) h. grid (row = 1, column = 0) l = Scale (root, from _ = 255, to = 0, command = update) l. grid (row = 1, column = 1) s = Scale (root, from _= 255, to = 0, command = update) s. grid (row = 1, column = 2) c = Canvas (root, width = 100, height = 100, bg = 'black') c. grid (row = 1, column = 3) root. mainloop ()
The above is all of the content in this article, hoping to help you learn Python programm
Use the tkinter module in Python to plot (continued), pythontkinter8. display text
UseCreate_textWrite on the canvas. This function only requires two coordinates (The position of the text x and y) and a named parameter to accept the text to be displayed. For example:
>>> from tkinter import*>>> tk = Tk()>>> canvas = Canvas(tk,width=400,height=400)>>> canvas.pack(
This Tkinter Learning Tutorial focuses on the following uses of several controls:LabelFrameEntryTextButtonListboxScrollbarExplains that each control is finally added with a pack (). Otherwise the control cannot be displayed.1.LabelDescription: LabelUsage: Label (Root object, "property list")Property:Text to displayBG background ColorWidth of 3D boundary of BD Perimeterfont fonts (color, size)Width control w
= ' Happy birthday ", font= (" couried ",") "Nine, display picturesTo display a picture on the canvas with Tkinter, first load the picture, and then use the create_image function on the canvas object.This is a picture of my existence on the E disk:We can show one.gif pictures like this: from import*>>> tk = tk ()>>> canvas = canvas (tk,width=400,height=400)> >> canvas.pack ()>>> my_image = photoimage (file='e:\\ffoutput\\one.gif ' )>>> canvas.c
uses Tkinter to quickly create GUI applications.Since Tkinter is built into Python's installation package, as long as Python is installed to import the Tkinter library, and IDLE is also written in Tkinter, for a simple graphical interface
Hello, Tkinter.
But enough talk. Some code instead.
As you know, the every serious tutorial should start with a "Hello World"-type example. In this overview, we'll show you the only one such example, but two.
Every serious tutorial starts with a "Hello World" example, and in order to keep this routine we will show you two examples.
The a pretty minimal version:
# Checkbutton for Tkinter tutorials
# Checkbutton, also known as the multiple-choice button, can represent two states: On and Off. You can set a callback function. When you click this button, the callback function is called.
'''1. Simple Checkbutton example '''
# Create a Checkbutton and display the text as "python"
From Tkinter import *
Root = Tk ()
Checkbutton
I. Introduction of Tkinter
Tkinter is a Python module, an interface called TCL/TK, which is a cross-platform scripting GUI interface. Tkinter is not the only Python graphics programming interface, but it is one of the more popular ones. The biggest feature is the cross-plat
First, Tkinter Introduction
Tkinter is a Python module that is an interface to call TCL/TK, a Cross-platform scripting interface. Tkinter is not the only Python graphics programming interface, but it is one of the more popular. The biggest feature is Cross-platform, the dis
program in the following way
$ python hello1.py
The following results will appear
Program Explanation:
1. We first import the Tkinter module, which contains everything we need to use Tkinter related functions, classes, and other related things.
From Tkinter Import *This is the way to import everything, but it ca
Python provides a variety of scenarios for developing a graphical user interface (GUI). Listed below are the most important:
The Tkinter:tkinter is the TK GUI toolkit, which is the Python interface included with Python. In this tutorial we will look at this option.
WxPython: This is an open source
descriptions... Done
Building tag database... Done
The following NEW packages will be automatically installed:
Blt tk8.4
The following NEW packages will be installed:
Blt python-tk tk8.4
0 packages upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 2565kB of archives. After unpacking 6676kB will be used.
Do you want to continue? [Y/n/?] Y
Writing extended state information...
('AB', 'cd ')T. Pack ()Root. mainloop ()'''12. Test the tag impact of Delete '''#-*-Coding: cp936 -*-# The delete method does not affect the tag. That is to say, the delete text has nothing to do with the tag.From tkinter import *Root = TK ()T = text (Root)# Create a tag whose foreground color is blueT. tag_config ('B', foreground = 'blue ')For I in range (10 ):T. insert (1.0, '123 ')# Customize two marks and use them to specify text blocks for addin
Python3 Previous version with Tkinter, followed by TkinterThe simplest code to use Tkinter is to first create a window of TK () and then add the various widgetsFrom Tkinter Import *window = Tk () label = label (window, Text = "Welcome to Python") button = button (window, Text = "click M E ") Label.pack () Button.pack (
)
cv.create_rectangle(10,10,110,110)cv.pack()root.mainloop()
# For the sake of clarity, set the background color to white to distinguish root'''3. Specify the fill color of the item '''#-*-Coding: cp936 -*-# Create a rectangle and specify that the background color of the canvas is white.# Use the property fill to set its fill colorFrom Tkinter import *Root = Tk ()# Create a Canvas and set its background col
distinguish Root'''3. Specify the fill color of the item '''#-*-Coding: cp936 -*-# Create a rectangle and specify that the background color of the canvas is white.# Use the property fill to set its fill colorFrom tkinter import *Root = TK ()# Create a canvas and set its background color to whiteCV = canvas (root, BG = 'white ')Cv. create_rectangle (10,10, 110,110, fill = 'red ')Cv. Pack ()Root. mainloop ()
This article is a summary of what I learned from the InternetI. What is Tkinter? Tkinter is a python built-in GUI graphics library that supports multiple operating systems and is developed using TCL language;The Python code we write will call the built-in Tkinter,
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.