#!/usr/bin/python#-*-coding:utf-8-*-if __name__=='__main__': fromTkinterImport*Root= Tk ()#Tk () is a function in the Tkinter library.Root.title ('What the hell?') Canvas=Canvas (root, Width= 400,#width of canvasHeight = 400,#the height of the canvasBG ='Red' #Beijing color of canvas) X0= 20y0= 20Y1= 275X1= 275#RectangleCanvas.create_rectangle (X0,y0,x1,y1,fill ='Yellow')#Rectangle Two coordinate point (x0,y0) (x1,y1) starting and ending point on a diagonal #LineCanvas.create_line (30,30,300,30,width ='1', fill ='Yellow')#Line (30,30) (300,30) Start and end #EllipseA1 = 100B1= 100#Center Point coordinatesR = 60#radiusW1 = 90H1= 60#W1 and H1 represent the distance between right and left #canvas.create_oval (a1-r,b1-r,w1,h1,width = ' 1 ', fill = ' yellow ') #ArcCanvas.create_arc (60,100,300,200,#coordinate meaning yourself try extent settings 90 and 180 will understandStart ='0', extent =' the')#the starting and ending angle of an arc #Canvas.pack (Expand=yes, fill=both) add a canvas to the main window #Expand 1 #Enable Fill Property #Expand 0 #Close the Fill property #fill = X #widgets follow GUI form changes in x direction when GUI form size changes #fill = Y #widgets follow GUI form changes in Y-direction when GUI form size changes #fill = BOTH #When the GUI form size changes, the widget follows the GUI form in both X and y directionsCanvas.pack () root.mainloop ( )
Python Tkinter knowledge points