Tkinter画布-Canvas
语法:
这里是一个简单的语法来创建这个widget:
w = Canvas ( master, option=value, ... )
参数:
master: 这代表了父窗口.
options: 下面是这个小工具最常用的选项列表。这些选项可以作为键 - 值对以逗号分隔.
| Option | Description |
|---|---|
| bd | Border width in pixels. Default is 2. |
| bg | Normal background color. |
| confine | If true (the default), the canvas cannot be scrolled outside of the scrollregion. |
| cursor | Cursor used in the canvas like arrow, circle, dot etc. |
| height | Size of the canvas in the Y dimension. |
| highlightcolor | Color shown in the focus highlight. |
| relief | Relief specifies the type of the border. Some of the values are SUNKEN, RAISED, GROOVE, and RIDGE. |
| scrollregion | A tuple (w, n, e, s) that defines over how large an area the canvas can be scrolled, where w is the left side, n the top, e the right side, and s the bottom. |
| width | Size of the canvas in the X dimension. |
| xscrollincrement | If you set this option to some positive dimension, the canvas can be positioned only on multiples of that distance, and the value will be used for scrolling by scrolling units, such as when the user clicks on the arrows at the ends of a scrollbar. |
| xscrollcommand | If the canvas is scrollable, this attribute should be the .set() method of the horizontal scrollbar. |
| yscrollincrement | Works like xscrollincrement, but governs vertical movement. |
| yscrollcommand | If the canvas is scrollable, this attribute should be the .set() method of the vertical scrollbar. |
Canvas的widget可以支持以下标准的条目:
arc .创建弧项目,它可以是一个和弦,饼图扇区,或是一个简单的弧.
coord = 10, 50, 240, 210
arc = canvas.create_arc(coord, start=0, extent=150, fill="blue")
image . 创建一个图像的项目,它可以是位图图像或是照片图像类的一个实例.
filename = PhotoImage(file = "sunshine.gif")
image = canvas.create_image(50, 50, anchor=NE, image=filename)
line . 创建一条线条目.
line = canvas.create_line(x0, y0, x1, y1, ..., xn, yn, options)
oval . 在给定的坐标创建一个圆或椭圆。它的坐标两双。为椭圆的边界矩形左上角和底部右下角.
oval = canvas.create_oval(x0, y0, x1, y1, options)
polygon . 创建一个多边形的项目,必须有至少三个顶点.
oval = canvas.create_polygon(x0, y0, x1, y1,...xn, yn, options)
例子:
自行尝试下面的例子:
import Tkinter
import tkMessageBox top = Tkinter.Tk() C = Tkinter.Canvas(top, bg="blue", height=250, width=300) coord = 10, 50, 240, 210
arc = C.create_arc(coord, start=0, extent=150, fill="red") C.pack()
top.mainloop()
这将产生以下结果:
Tkinter画布-Canvas的更多相关文章
- pywin32获得tkinter的Canvas窗口句柄,并在上面绘图
上一篇博文获得主窗口句柄使用的是root.frame或者通过子控件调用master.frame方法,但是子控件本身没有frame方法.那么怎么获得子控件的句柄呢?试过了很多办法,想过把Canvas当作 ...
- HTML 5 画布(canvas)
canvas 元素使用 JavaScript 在网页上绘制图像,本身是没有绘图能力. canvas 是一个矩形区域,可以控制其每一像素. canvas 拥有多种绘制路径.矩形.圆形.字符以及添加图像的 ...
- HTML5画布Canvas
一.Canvas概念介绍 1.概念 Canvas : 画布 2.作用 : HTML5 Canvas 元素用于图形的绘制, 通过脚本(通常是JavaScript)来完成.它本身只是个图形容器,必须使用脚 ...
- HTML5画布(CANVAS)速查简表
HTML5画布(CANVAS)速查简表 http://www.webhek.com/misc/html5-canvas-cheat-sheet/
- PHP《将画布(canvas)图像保存成本地图片的方法》
用PHP将网页上的Canvas图像保存到服务器上的方法 2014年6月27日 歪脖骇客 发表回复 8 在几年前HTML5还没有流行的时候,我们的项目经理曾经向我提出这样一个需求:让项目评审专家们在评审 ...
- 转载:将画布(canvas)图像保存成本地图片的方法
之前我曾介绍过如何将HTML5画布(canvas)内容转变成图片形式,方法十分简单.但后来我发现只将canvas内容转变成图片输出还不够,如何能将转变后的图片保存到本地呢? 其实,这个方法也是非常简单 ...
- 面向画布(Canvas)的JavaScript库
面向画布(Canvas)的JavaScript库 总结 每个库各有特色,根据需求选择 学习要点 面向画布(Canvas)的JavaScript库 EaselJS 是一个封装了 HTML5 画布(C ...
- 学习前端第二天心得体会(初步了解HTML5的部分API以及画布Canvas)
一.HTML5部分API 1.选择器querySelector和querySelectorAll 1.1.querySelector:返回文档中匹配指定的CSS选择器的第一元素. document. ...
- java 图形化小工具Abstract Window Toolit :画笔Graphics,画布Canvas(),弹球小游戏
画笔Graphics Java中提供了Graphics类,他是一个抽象的画笔,可以在Canvas组件(画布)上绘制丰富多彩的几何图和位图. Graphics常用的画图方法如下: drawLine(): ...
随机推荐
- asp.net 输入框在chrome中无法关闭自动提示
将asp:TextBox 的属性AutoCompleteType设为Disabled,希望在chrome中点击记住用户名密码后输入框不再自动提示,但不起作用. 解决方法: <asp:TextBo ...
- python爬虫入门(1)-urllib模块
作用:用于读取来自网上(服务器上)的数据 基本方法:urllib.request.urlopen(url,data=None,[]timeout]*,cafile=None,cadefault=F ...
- 网络编程 socket编程 - Asyncsocke
简单的聊天程序:http://blog.csdn.net/chang6520/article/details/7967662 iPhone的标准推荐是CFNetwork 库编程,其封装好的开源库是 c ...
- Notes on UE4-Blender workflow
In UE4: When you import a rigged model (mesh parents armature) to UE4, it will be converted to a Ske ...
- Canvas 与 SVG 的区别
这个说实话,我只用过canvas画过一些简单的图形,复杂的不懂,之所以列出来,是因为之前在面试中有被问到,在这里mark一下,后期深化. 以下的内容全部来自于w3school http://www.w ...
- dom4j 改变XML声明和编码格式
dom4j 改变XML编码 Element rootElement = document.addElement("data"); document.setXMLEncoding(& ...
- Android Hook神器:XPosed入门与登陆劫持演示
前段时间写了一篇关于Cydia Substrate广告注入的文章,大家都直呼过瘾.但是,真正了解这一方面的同学应该知道,其实还有一个比Cydia Substrate更出名的工具:XPosed. 不是因 ...
- 使 32 位程序使用大于 2GB 的内存
不管在 32 位 Windows 上还是在 64 位 Windows 上,32 位的应用程序都只能使用最大 2GB 的内存,这是我们司空见惯的一个设定.但其实 Windows 提供了一些方法让我们打破 ...
- 《DSP using MATLAB》示例 Example 9.6
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- <mvc:annotation-driven>注册了什么
前言 上一篇文章dispatcherservlet初始化中提到,如果没有配置handlermapping就会采取默认的策略进行配置handlermapping,这篇文章就要讲述mvc:annotati ...