1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
from Tkinter import *
import Pmw
Pmw.initialise()
class Paint(Pmw.ScrolledCanvas,Frame):
def __init__(self,fen=None):
Frame.__init__(self)
self.master.title('Paint v1.4')
Pmw.ScrolledCanvas.__init__(self,
usehullsize = 1, hull_width =500, hull_height =300,
canvas_bg ='white', canvasmargin =10,
borderframe =1,
borderframe_borderwidth =3)
self.configure(vscrollmode ='dynamic', hscrollmode ='dynamic')
self.pack(side = BOTTOM,padx =5, pady =5, expand =YES, fill =BOTH)
self.can = self.interior()
self.can.create_rectangle(0,0,0,0,fill='white',width=0)
self.can.create_rectangle(501,301,501,301,fill='white',width = 0)
self.can.bind('<B1-Motion>',self.modif)
self.can.bind('<ButtonPress-1>',self.clic)
self.can.bind('<B3-Motion>',self.modif2)
self.can.bind('<ButtonPress-3>',self.clic)
self.can.focus_set()
self.resizescrollregion()
self.grandeListe=[]
self.epaisseur=1
def clic(self,event):
self.x=event.x
self.y=event.y
self.l=[]
try:
self.epaisseur = self.epaisseur2.choix()
except:
1
def modif(self,event):
try:
self.coul= self.coul2.choix()
except:
self.coul= 'black'
x=event.x
y=event.y
a = self.can.create_line(x,y,self.x,self.y,fill=self.coul,width=self.epaisseur)#,outline="red")
self.l.append(a)
self.x=event.x
self.y=event.y
def modif2(self,event):
try:
self.dcoul= self.dcoul2.choix()
except:
self.dcoul= 'white'
x=event.x
y=event.y
a=self.can.create_line(x,y,self.x,self.y,fill=self.dcoul,width=self.epaisseur)#,outline="red")
self.l.append(a)
self.x=event.x
self.y=event.y
if __name__ == '__main__':
app=Paint().mainloop() |
Partager