位置:首頁(yè) > 軟件操作教程 > 編程開(kāi)發(fā) > Python > 問(wèn)題詳情

Python繪制盒子

提問(wèn)人:楊紫紅發(fā)布時(shí)間:2020-11-19

import tkinter

import random


tk=tkinter.Tk()

canvas = tkinter.Canvas(tk,width=500,height=500)

canvas.pack()


def random_rectangle(width,height,fill_color):

    x1= random.randrange(width)

    y1= random.randrange(height)

    x2= x1+random.randrange(width)

    y2= y1+random.randrange(height)

    canvas.create_rectangle(x1,y1,x2,y2,fill=fill_color)


for x in range(0,100):

    random_rectangle(400,400,'#eb5699')

image.png

繼續(xù)查找其他問(wèn)題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部