mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Track color changes: disable buttons and their labels when turned off
This commit is contained in:
parent
332aa4cf0a
commit
3a476e9b35
1 changed files with 28 additions and 13 deletions
|
@ -53,7 +53,8 @@ textual displays.''')
|
||||||
# track toggle
|
# track toggle
|
||||||
self.__t = Checkbutton(root, text='Track color changes',
|
self.__t = Checkbutton(root, text='Track color changes',
|
||||||
variable=self.__trackp,
|
variable=self.__trackp,
|
||||||
relief=GROOVE)
|
relief=GROOVE,
|
||||||
|
command=self.__toggletrack)
|
||||||
self.__t.pack(fill=X, expand=YES)
|
self.__t.pack(fill=X, expand=YES)
|
||||||
frame = self.__frame = Frame(root)
|
frame = self.__frame = Frame(root)
|
||||||
frame.pack()
|
frame.pack()
|
||||||
|
@ -85,6 +86,7 @@ textual displays.''')
|
||||||
value=(row-2)*2 + col-1)
|
value=(row-2)*2 + col-1)
|
||||||
r.grid(row=row, column=col)
|
r.grid(row=row, column=col)
|
||||||
self.__radios.append(r)
|
self.__radios.append(r)
|
||||||
|
self.__toggletrack()
|
||||||
|
|
||||||
def __quit(self, event=None):
|
def __quit(self, event=None):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -98,16 +100,29 @@ textual displays.''')
|
||||||
def __forceupdate(self, event=None):
|
def __forceupdate(self, event=None):
|
||||||
self.__sb.update_views_current()
|
self.__sb.update_views_current()
|
||||||
|
|
||||||
|
def __toggletrack(self, event=None):
|
||||||
|
if self.__trackp.get():
|
||||||
|
state = NORMAL
|
||||||
|
fg = self.__radios[0]['foreground']
|
||||||
|
else:
|
||||||
|
state = DISABLED
|
||||||
|
fg = self.__radios[0]['disabledforeground']
|
||||||
|
for r in self.__radios:
|
||||||
|
r.configure(state=state)
|
||||||
|
for l in self.__labels:
|
||||||
|
l.configure(foreground=fg)
|
||||||
|
|
||||||
def update_yourself(self, red, green, blue):
|
def update_yourself(self, red, green, blue):
|
||||||
colorname = ColorDB.triplet_to_rrggbb((red, green, blue))
|
if self.__trackp.get():
|
||||||
which = self.__which.get()
|
colorname = ColorDB.triplet_to_rrggbb((red, green, blue))
|
||||||
if which == 0:
|
which = self.__which.get()
|
||||||
self.__text.configure(foreground=colorname)
|
if which == 0:
|
||||||
elif which == 1:
|
self.__text.configure(foreground=colorname)
|
||||||
self.__text.configure(background=colorname)
|
elif which == 1:
|
||||||
elif which == 2:
|
self.__text.configure(background=colorname)
|
||||||
self.__text.configure(selectforeground=colorname)
|
elif which == 2:
|
||||||
elif which == 3:
|
self.__text.configure(selectforeground=colorname)
|
||||||
self.__text.configure(selectbackground=colorname)
|
elif which == 3:
|
||||||
elif which == 5:
|
self.__text.configure(selectbackground=colorname)
|
||||||
self.__text.configure(insertbackground=colorname)
|
elif which == 5:
|
||||||
|
self.__text.configure(insertbackground=colorname)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue