How to draw a straight line in python

(*-*)浩
Release: 2019-07-09 10:34:45
Original
10610 people have browsed it

Tkinter is Python’s standard GUI library. Python uses Tkinter to quickly create GUI applications.

How to draw a straight line in python

Since Tkinter is built into the python installation package, you can import the Tkinter library after installing Python, and IDLE is also used Written in Tkinter, Tkinter can still handle the simple graphical interface easily. (Recommended learning: Python video tutorial)

Create a canvas for drawing

If we want to draw a picture, we need a different element: a

canvas (canvas)

object, which is the object of the Canvas class (provided by the tkinter module).

When we create a canvas, we pass in the width and height of the canvas (in pixels) to Python. Other aspects are the same as the button code:

>>> from tkinter import*
>>> tk = Tk()
>>> canvas = Canvas(tk,width=500,height=500)
>>> canvas.pack()
Copy after login

How to draw a straight line in python

Note:

pack function

is used to let In the correct position in the canvas display. If this function is not called, nothing will be displayed normally.

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to draw a straight line in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!