@@ -27,7 +27,8 @@ def __init__(self,root,canvas,pts,radius=4):
2727 self .inside_poly = False
2828 self .down_inside_poly = False
2929 self .select_poly = False
30-
30+ #self.colors = ["yellow","red","gray","green"]
31+ self .colors = ["#FF0000" ,"#FFFF00" ,"#00FF00" ,"#0000FF" ,"#800000" ,"#00FFFF" ,"#FFFFFF" ,"#800080" ]
3132 # Add points to list of points
3233 self .initialize_points ()
3334 #flatten = lambda l: [item for sublist in l for item in sublist]
@@ -103,11 +104,17 @@ def flatten(self):
103104 # draw circular point widgets on the canvas
104105 def initialize_points (self ):
105106 for i in range (len (self .pt_coords )):
107+ if i < len (self .colors ):
108+ fill_color = self .colors [i ]
109+ else :
110+ fill_color = "green"
106111 self .points .append (
107112 self .canvas .create_oval (
108113 self .pt_coords [i ][0 ]- self .radius ,self .pt_coords [i ][1 ]- self .radius ,
109114 self .pt_coords [i ][0 ]+ self .radius ,self .pt_coords [i ][1 ]+ self .radius ,
110- fill = "green" ,
115+ activefill = fill_color ,
116+ fill = fill_color ,
117+ disabledfill = "blue" ,
111118 tag = "Point"
112119 )
113120 )
@@ -142,11 +149,12 @@ def unshow_type(self):
142149
143150 # Triggered when cursor enters the bound widget(A point in our case)
144151 def enter (self ,event ):
145- self .canvas .itemconfigure (CURRENT ,fill = "blue" )
152+ # self.canvas.itemconfigure(CURRENT,fill="blue")
146153 self .loc = 1
147154
148155 def leave (self ,event ):
149- self .canvas .itemconfigure (CURRENT ,fill = "green" )
156+ #self.canvas.itemconfigure(CURRENT,fill="green")
157+ pass
150158
151159 # Updates location of each point according to the coordinates in self.coords
152160 def draw_points (self ):
@@ -180,15 +188,15 @@ def update_polygon(self):
180188 def down (self ,event ):
181189 self .point_in_use = event .widget
182190 event .widget .bind ("<B1-Motion>" ,self .motion )
183- self .canvas .itemconfigure (CURRENT ,fill = "red " )
191+ # self.canvas.itemconfigure(CURRENT,fill = "black ")
184192
185193 # Triggered when a point is press and moved
186194 def motion (self ,event ):
187195 #if self.select_poly:
188196 # self.unshow_type()
189197 self .root .config (cursor = "crosshair" )
190198 self .point_in_use = event .widget
191- self .point_in_use .itemconfigure (CURRENT ,fill = "red " )
199+ # self.point_in_use.itemconfigure(CURRENT,fill = "black ")
192200 x ,y = self .point_in_use .canvasx (event .x ), self .point_in_use .canvasy (event .y )
193201 pt = self .canvas .find_withtag ("current" )[0 ]
194202 self .update_point (
@@ -204,7 +212,7 @@ def motion(self,event):
204212 def chkup (self ,event ):
205213 event .widget .unbind ("<B1-Motion>" )
206214 self .root .config (cursor = "" )
207- self .canvas .itemconfigure (CURRENT ,fill = "green" )
215+ # self.canvas.itemconfigure(CURRENT,fill="green")
208216 #if self.select_poly:
209217 # self.show_type()
210218
0 commit comments