Latest web development tutorials

Pythonは演習58、

Pythonの100リー Pythonの100リー

タイトル:長方形、正方形で描画、絵画の学校。

プログラム解析:

rectangle(int left, int top, int right, int bottom)

パラメータ説明:(左、上)左直交座標、(右、下)矩形のサイズを決定することができるどちらも右下の直交座標、

ソースコード:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    from Tkinter import *
    root = Tk()
    root.title('Canvas')
    canvas = Canvas(root,width = 400,height = 400,bg = 'yellow')
    x0 = 263
    y0 = 263
    y1 = 275
    x1 = 275
    for i in range(19):
        canvas.create_rectangle(x0,y0,x1,y1)
        x0 -= 5
        y0 -= 5
        x1 += 5
        y1 += 5
        
    canvas.pack()
    root.mainloop()

上の例の出力は、次のとおりです。

Pythonの100リー Pythonの100リー