mirror of
https://github.com/python/cpython.git
synced 2025-11-02 06:31:29 +00:00
Lots of good UI working, but not yet update-while-dragging
This commit is contained in:
parent
46670a2d42
commit
399f10cd66
1 changed files with 31 additions and 13 deletions
|
|
@ -16,8 +16,10 @@ def __init__(self, switchboard, parent=None):
|
||||||
#
|
#
|
||||||
# create the canvas which holds everything, and its scrollbar
|
# create the canvas which holds everything, and its scrollbar
|
||||||
#
|
#
|
||||||
canvas = self.__canvas = Canvas(root, width=160, height=300)
|
frame = self.__frame = Frame(root)
|
||||||
self.__scrollbar = Scrollbar(root)
|
frame.pack()
|
||||||
|
canvas = self.__canvas = Canvas(frame, width=160, height=300)
|
||||||
|
self.__scrollbar = Scrollbar(frame)
|
||||||
self.__scrollbar.pack(fill=Y, side=RIGHT)
|
self.__scrollbar.pack(fill=Y, side=RIGHT)
|
||||||
canvas.pack(fill=BOTH, expand=1)
|
canvas.pack(fill=BOTH, expand=1)
|
||||||
canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
|
canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
|
||||||
|
|
@ -43,7 +45,8 @@ def __init__(self, switchboard, parent=None):
|
||||||
textend+3, row*20 + 23,
|
textend+3, row*20 + 23,
|
||||||
outline='',
|
outline='',
|
||||||
tags=(exactcolor,))
|
tags=(exactcolor,))
|
||||||
canvas.tag_bind(boxid, '<ButtonPress>', self.__onselection)
|
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
|
||||||
|
|
@ -53,8 +56,16 @@ def __init__(self, switchboard, parent=None):
|
||||||
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 __onselection(self, event=None):
|
def __onmotion(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)
|
||||||
|
|
@ -64,17 +75,12 @@ def __onselection(self, event=None):
|
||||||
if boxid in self.__bboxes:
|
if boxid in self.__bboxes:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print 'No box found!'
|
## print 'No box found!'
|
||||||
return
|
return
|
||||||
tags = canvas.gettags(boxid)
|
if self.__uwd.get():
|
||||||
for t in tags:
|
self.__onrelease(event)
|
||||||
if t[0] == '#':
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
print 'No color tag found!'
|
self.__selectbox(boxid)
|
||||||
return
|
|
||||||
red, green, blue = ColorDB.rrggbb_to_triplet(t)
|
|
||||||
self.__sb.update_views(red, green, blue)
|
|
||||||
|
|
||||||
def __selectbox(self, boxid):
|
def __selectbox(self, boxid):
|
||||||
canvas = self.__canvas
|
canvas = self.__canvas
|
||||||
|
|
@ -84,6 +90,18 @@ def __selectbox(self, boxid):
|
||||||
self.__lastbox = boxid
|
self.__lastbox = boxid
|
||||||
canvas.itemconfigure(boxid, outline='black')
|
canvas.itemconfigure(boxid, outline='black')
|
||||||
|
|
||||||
|
def __onrelease(self, event=None):
|
||||||
|
if self.__lastbox:
|
||||||
|
tags = self.__canvas.gettags(self.__lastbox)
|
||||||
|
for t in tags:
|
||||||
|
if t[0] == '#':
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
## print 'No color tag found!'
|
||||||
|
return
|
||||||
|
red, green, blue = ColorDB.rrggbb_to_triplet(t)
|
||||||
|
self.__sb.update_views(red, green, blue)
|
||||||
|
|
||||||
def __quit(self, event=None):
|
def __quit(self, event=None):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue