資源簡介
基于python3.6的tkinter庫制作的繪圖小程序,源于《python寶典》的例子。能繪制直線、矩形、橢圓和四分之一圓。
代碼片段和文件信息
#?-*-?coding:utf-8?-*-
#?file:?tkinterDraw.py
#
import?tkinter
class?MyButton:
????def?__init__(selfrootcanvaslabeltype):
????????self.root?=?root
????????self.canvas?=?canvas
????????self.label?=?label
????????if?type?==?0:
????????????button?=?tkinter.Button(roottext?=‘Draw?Line‘command?=?self.DrawLine)
????????elif?type?==?1:
????????????button?=?tkinter.Button(roottext?=‘Draw?Arc‘command?=?self.DrawArc)
????????elif?type?==?2:
????????????button?=?tkinter.Button(roottext?=‘Draw?Rectangle‘command?=?self.DrawRec)
????????elif?type?==?3:
????????????button?=?tkinter.Button(roottext?=‘Draw?Oval‘command?=?self.DrawOval)
????????button.pack(side?=?‘left‘)
????????
????def?DrawLine(self):
????????self.label.text.set(‘Draw?Line‘)
????????self.canvas.SetStatus
評論
共有 條評論