zoukankan      html  css  js  c++  java
  • python实验一:画图

    题目:画图,学用rectangle画方形。

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

    参数说明:(left ,top )为矩形的左上坐标,(right,bottom)为矩形的右下坐标,两者可确定一个矩形的大小

    Canvas

    #!usr/bin/env python
    # -*- coding: utf-8 -*-
    
    if __name__ == '__main__':        
    	from Tkinter import *    #导入库
    	root = Tk()          #创建一个根窗口,其它事件将在这之上
    	root.title('Canvas')     #定义窗口标题
    	canvas = Canvas(root, width = 400,height = 400,bg = 'yellow')  #在根窗口上绘制宽高400 背景颜色为黄色的窗口
    	x0 = 200
    	y0 = 200
    	y1 = 200
    	x1 = 200    #初始点设置
    	for i in range(19):    #进入循环,调用create_rectangle函数绘制矩形框
    		canvas.create_rectangle(x0, y0, x1, y1) 
    		x0 -= 5
    		y0 -= 5
    		x1 += 5
    		y1 += 5
    
    	canvas.pack()    #绘制图案显示
    	root.mainloop()    #根窗口事件循环
    

     效果图:

     

  • 相关阅读:
    我开博客了,啦啦啦.
    cf593div2
    Comet OJ
    cf591div2abc
    cfround586ac
    cf589div2
    cf573div2
    Codeforces Round #569 (Div. 2)
    uva11729 水题
    luogu1984 [SDOI2008] 烧水问题
  • 原文地址:https://www.cnblogs.com/rohero/p/6144869.html
Copyright © 2011-2022 走看看