闲来无事,,,,一个“画图"

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

import Tkinter
class mybutton:
     def __init__(self,root,canvas,label,types):
         self.root=root
         self.canvas=canvas
         self.label=label
         if types==0:
             button=Tkinter.Button(root,text='Drawline',command=self.Drawline)
         elif types==1:
             button=Tkinter.Button(root,text='Drawarc',command=self.Drawarc)
         else :
             button=Tkinter.Button(root,text='Drawrect',command=self.Drawrect)
         button.pack(side='right')
     def Drawline(self):
         self.label.text.set('Draw line')
         self.canvas.setstatus(0)
     def  Drawarc(self):
         self.label.text.set('Draw arc')
         self.canvas.setstatus(1)
     def Drawrect(self):
         self.label.text.set('Draw rect')
         self.canvas.setstatus(2)
class mycanvas:
     def __init__(self,root):
        self.status=0
        self.draw=0
        self.root=root
        self.canvas=Tkinter.Canvas(root,bg='white',width=600,height=480)
        self.canvas.pack()
        self.canvas.bind('<ButtonRelease-1>',self.Draw)
        self.canvas.bind('<Button-2>',self.Exit)
        self.canvas.bind('<Button-3>',self.Del)
     def Draw(self,event):
        if self.draw==0:
            self.x=event.x
            self.y=event.y
            self.draw=1
        else:
            if self.status==0:
                self.canvas.create_line(self.x,self.y,event.x,event.y)
                self.draw=0
            elif self.status==1:
                self.canvas.create_arc(self.x,self.y,event.x,event.y)
                self.draw=0
            else :
                self.canvas.create_rectangle(self.x,self.y,event.x,event.y)
                self.draw=0
     def Del(self,event):
        items=self.canvas.find_all()
        for item in items:
            self.canvas.delete(item)
     def Exit(self):
        self.root.quit()
     def setstatus(self,status):
        self.status=status

class mylabel:
     def __init__(self,root):
          self.root=root
          self.canvas=canvas
          self.text=Tkinter.StringVar()
          self.text.set('draw line')
          self.label=Tkinter.Label(root,textvariable=self.text,fg='red',width=50)
          self.label.pack(side='left')
root=Tkinter.Tk()
canvas=mycanvas(root)
label=mylabel(root)
mybutton(root,canvas,label,0)
mybutton(root,canvas,label,1)
mybutton(root,canvas,label,2)
root.mainloop()