×
Python 基础教程Python 简介Python 环境搭建Python 中文编码Python 基础语法Python 变量类型Python 运算符Python 条件语句Python 循环语句Python While循环语句Python for 循环语句Python 循环嵌套Python break 语句Python continue 语句Python pass 语句Python 数字Python 字符串Python 列表(Lists)Python 元组Python 字典(Dictionary)Python 日期和时间Python 函数Python 模块Python 文件I/OPython File(文件) 方法Python 异常处理Python OS 文件/目录方法Python 内置函数

Python 高级教程

Python 面向对象Python 正则表达式Python CGI编程python MysqlPython SMTPPython 多线程Python XML解析python GUI编程(Tkinter)Python 2.x与3​​.x版本区别Python IDEPython JSONPython 100例

Python 练习实例58


Python 100例Python 100例


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

程序分析:

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

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

实例(Python 2.0+)

#!/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例


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)