In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to draw an ellipse with the Python tkinter library". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to draw an ellipse with the Python tkinter library" can help you solve the problem.
1. Ellipse drawing
Example code:
Import tkinter as tk # Import tkinter Library And rename it tkfrom tkinter import messagebox # Import messagebox module mywindow = tk.Tk () # create a form mywindow.title ("draw ellipse") # set the title of the form # create the canvas and layout mycanvas = tk.Canvas (mywindow,width=350,height=350 Bg= "white") mycanvas.pack () # draw the ellipse myoval = mycanvas.create_oval (10Magne20340300) # create_oval () method draw the ellipse # set the width and color of the ellipse border myova2 = mycanvas.create_oval (30mine205line 5line = "red") # set whether the border of the ellipse is a dotted line myova4 = mycanvas.create_oval Dash= (5 purple 3) # sets the filling color of the ellipse myova5 = mycanvas.create_oval (100meme 120pr 260jpg 200pr Widthboat 8 dagger outline = "blue", dash= (5pime 3), fill= "purple") # draws a circle myova6 = mycanvas.create_oval (140jue 180mm widthwatch 5line = "red") mywindow.mainloop () # displays the canvas
Running result:
Second, drawing rectangles
Example code:
Import tkinter as tk # Import tkinter Library And rename it tkfrom tkinter import messagebox # Import messagebox module mywindow = tk.Tk () # create a form mywindow.title ("draw rectangle") # set the title of the form # create the canvas and layout mycanvas = tk.Canvas (mywindow, width=350, height=350) Bg= "purple") mycanvas.pack () # draw rectangle a = 10 # define two integer variables b = 34 use for loop to make multiple rectangles for i in range (a, b, 20): mycanvas.create_rectangle (for i in range (a, b, 20): create _ rectangle () method can draw rectangle mywindow.mainloop () # display canvas
Running result:
Third, polygon drawing
Example code:
Import tkinter as tk # Import tkinter Library And rename it tkmywindow = tk.Tk () # create a form mywindow.title ("draw polygons") # set the title of the form # create the canvas and lay out mycanvas = tk.Canvas (mywindow, width=250, height=250, bg= "white") mycanvas.pack () # draw polygons mycanvas.create_polygon (80, purple, 180, 180, 130, 180, 180, 180, 180, 40, fill= "purple", width=5 Outline= "red") mywindow.mainloop () # display canvas
Running result:
This is the end of the introduction to "how to draw an ellipse with the Python tkinter library". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 288
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.