Commit 83a9162a authored by Barry Warsaw's avatar Barry Warsaw

Got click on working. Dragging is disabled for now

parent dfd2039f
...@@ -46,7 +46,6 @@ class ListViewer: ...@@ -46,7 +46,6 @@ class ListViewer:
outline='', outline='',
tags=(exactcolor,)) tags=(exactcolor,))
canvas.bind('<ButtonRelease>', self.__onrelease) canvas.bind('<ButtonRelease>', self.__onrelease)
canvas.bind('<Motion>', self.__onmotion)
bboxes.append(boxid) bboxes.append(boxid)
if textend+3 > widest: if textend+3 > widest:
widest = textend+3 widest = textend+3
...@@ -56,16 +55,8 @@ class ListViewer: ...@@ -56,16 +55,8 @@ class ListViewer:
for box in bboxes: for box in bboxes:
x1, y1, x2, y2 = canvas.coords(box) x1, y1, x2, y2 = canvas.coords(box)
canvas.coords(box, x1, y1, widest, y2) canvas.coords(box, x1, y1, widest, y2)
#
# Update while dragging?
#
self.__uwd = BooleanVar()
self.__uwdbtn = Checkbutton(root,
text='Update while dragging',
variable=self.__uwd)
self.__uwdbtn.pack()
def __onmotion(self, event=None): def __onrelease(self, event=None):
canvas = self.__canvas canvas = self.__canvas
# find the current box # find the current box
x = canvas.canvasx(event.x) x = canvas.canvasx(event.x)
...@@ -77,22 +68,7 @@ class ListViewer: ...@@ -77,22 +68,7 @@ class ListViewer:
else: else:
## print 'No box found!' ## print 'No box found!'
return return
if self.__uwd.get(): tags = self.__canvas.gettags(boxid)
self.__onrelease(event)
else:
self.__selectbox(boxid)
def __selectbox(self, boxid):
canvas = self.__canvas
# turn off the last box
if self.__lastbox:
canvas.itemconfigure(self.__lastbox, outline='')
self.__lastbox = boxid
canvas.itemconfigure(boxid, outline='black')
def __onrelease(self, event=None):
if self.__lastbox:
tags = self.__canvas.gettags(self.__lastbox)
for t in tags: for t in tags:
if t[0] == '#': if t[0] == '#':
break break
...@@ -112,5 +88,11 @@ class ListViewer: ...@@ -112,5 +88,11 @@ class ListViewer:
self.__root.deiconify() self.__root.deiconify()
def update_yourself(self, red, green, blue): def update_yourself(self, red, green, blue):
colorname = ColorDB.triplet_to_rrggbb((red, green, blue)) canvas = self.__canvas
self.__selectbox(colorname) # turn off the last box
if self.__lastbox:
canvas.itemconfigure(self.__lastbox, outline='')
# turn on the current box
colortag = ColorDB.triplet_to_rrggbb((red, green, blue))
canvas.itemconfigure(colortag, outline='black')
self.__lastbox = colortag
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment