Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize graffiti color table and go board by Python programming tkinter library Canvas

Shulou Source: shulou.com Published: 2022-06-03 07:56:26 09月22日 Update

In this issue, the editor will bring you about Python programming tkinter library Canvas how to achieve graffiti color table and go board, the article is rich in content and professional analysis and description for you, I hope you can get something after reading this article.

There are three examples of Canvas operation in tkinter library one: graffiti import tkinter as tkimport pyautogui as agfrom time import sleepdef paint (event): X1, y1 = (event.x-1), (event.y-1) x2, y2 = (event.x + 1), (event.y + 1) tCanvas.create_oval (x1, y1, x2, y2, fill = "black") def moveRect (wMagneh): ag.moveRel Duration=w/1000) # moveRel move # dragRel drag ag.moveRel (0m m h, duration=h/1000) ag.moveRel (- w m m 0, duration=w/1000) ag.moveRel (0m m m h, duration=h/1000) sleep (0.5) win = tk.Tk () X Y=ag.size () winPos = "640x480 +" winPos + = str ((XMel 640) / / 2) + "+" winPos + = str ((Ymai 480) / / 2) win.geometry (winPos) win.resizable (False, False) win.title ('Desktop Resolution:' + str (X) + "x" + str (Y) win.update () tCanvas = tk.Canvas (win, width = win.winfo_width (), height = 400, bg = 'white') tCanvas.pack (side = "top") tCanvas.bind (" Paint) tCanvas.update () tk.Label (win, text = "canvas drawing") .pack (side = "bottom") x0 = 150 60w y0ag.moveTo h = 350160x, y = win.winfo_rootx () + x0, win.winfo_rooty () + y0ag.moveTo (x, y, duration=0.5) moveRect (wh) # draw a straight line tCanvas.create_line (x0, x0, y0) tCanvas.create_line (x0, y0, x0) ) # you can assign the upper left and lower right coordinate points together to the variable coord = x0juw, y0qih, x0coord,fill='limegreen' (coord) coord = x0coord y0 + h, x0, y0tCanvas.create_line (coord,fill=' blue') tCanvas.update () moveRect # draw a rectangle coord = x0examples 1mlmlmlmltCanvas.createcylindricangle (coord,fill='limegreen') tCanvas.update () moveRect (HMH) # draw a circle or ellipse coord = x0wow TCanvas.update (coord,fill='deepskyblue') tCanvas.update () CHORD () ARC (ARC) sleep (1) sleep (1) coord = 100,100,300, 300tCanvas.create_arc (coord,start=0,extent=180) # draw a fan, bow or an arc # type = PIESLICE sector, CHORD arch, ARC arc Fill='gold') tCanvas.update () sleep (1) coord = 240,60,490,31 colors can also be represented by 6-digit hexadecimal GRB values for tCanvas.create_arc (coord,style=tk.CHORD,start=10,fill='#7CFC00') tCanvas.update () sleep (1) coord = 180,10,470, 300tCanvas.create_arc (coord,style=tk.ARC,width=3,dash=6,extent=-180) # parameters You can search the relevant parameter table win.mainloop () running effect picture on the Internet:

Tags: Color instance run chessboard resolution effects effect graphics desktop programming content parameters size Arial that is bow fan text more canvas analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL vpn Huawei Linux