Added highlight colors to the set_index_color method. Parms highlight_text_color & highlight_background_color control changing the highlight colors
This commit is contained in:
parent
393050c1ae
commit
77ea65b8de
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
version = __version__ = "4.61.0.195 Unreleased"
|
||||
version = __version__ = "4.61.0.196 Unreleased"
|
||||
|
||||
_change_log = """
|
||||
Changelog since 4.60.0 released to PyPI on 8-May-2022
|
||||
|
@ -462,6 +462,9 @@ _change_log = """
|
|||
Added Listbox.select_index and Listbox.set_index_color
|
||||
4.61.0.195
|
||||
New Udemy Coupon
|
||||
4.61.0.196
|
||||
Added highlight colors to the set_index_color method. Parms highlight_text_color & highlight_background_color control changing the highlight colors
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
@ -3332,7 +3335,6 @@ class Listbox(Element):
|
|||
return value
|
||||
|
||||
|
||||
|
||||
def select_index(self, index, highlight_text_color=None, highlight_background_color=None):
|
||||
"""
|
||||
Selects an index while providing capability to setting the selected color for the index to specific text/background color
|
||||
|
@ -3359,31 +3361,25 @@ class Listbox(Element):
|
|||
self.TKListbox.selection_set(index, index)
|
||||
|
||||
if highlight_text_color is not None:
|
||||
text_color = highlight_text_color
|
||||
else:
|
||||
text_color = None
|
||||
|
||||
self.widget.itemconfig(index, selectforeground=highlight_text_color)
|
||||
if highlight_background_color is not None:
|
||||
background_color = highlight_background_color
|
||||
else:
|
||||
background_color = None
|
||||
|
||||
if text_color is not None:
|
||||
self.widget.itemconfig(index, selectforeground=text_color)
|
||||
if background_color is not None:
|
||||
self.widget.itemconfig(index, selectbackground=background_color)
|
||||
self.widget.itemconfig(index, selectbackground=highlight_background_color)
|
||||
|
||||
|
||||
def set_index_color(self, index, text_color=None, background_color=None):
|
||||
def set_index_color(self, index, text_color=None, background_color=None, highlight_text_color=None, highlight_background_color=None):
|
||||
"""
|
||||
Sets the color of a specific item without selecting it
|
||||
|
||||
:param index: specifies which item to change. index starts at 0 and goes to length of values list minus one
|
||||
:type index: (int)
|
||||
:param text_color: color of the text for this item
|
||||
:type text_color: (str)
|
||||
:param background_color: color of the background for this item
|
||||
:type background_color: (str)
|
||||
:param index: specifies which item to change. index starts at 0 and goes to length of values list minus one
|
||||
:type index: (int)
|
||||
:param text_color: color of the text for this item
|
||||
:type text_color: (str)
|
||||
:param background_color: color of the background for this item
|
||||
:type background_color: (str)
|
||||
:param highlight_text_color: color of the text when this item is selected.
|
||||
:type highlight_text_color: (str)
|
||||
:param highlight_background_color: color of the background when this item is selected
|
||||
:type highlight_background_color: (str)
|
||||
"""
|
||||
|
||||
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
|
||||
|
@ -3397,11 +3393,15 @@ class Listbox(Element):
|
|||
_error_popup_with_traceback('Index {} is out of range for Listbox.set_index_color. Max allowed index is {}.'.format(index, len(self.Values)-1))
|
||||
return
|
||||
|
||||
|
||||
if text_color is not None:
|
||||
self.widget.itemconfig(index, fg=text_color)
|
||||
if background_color is not None:
|
||||
self.widget.itemconfig(index, bg=background_color)
|
||||
if highlight_text_color is not None:
|
||||
self.widget.itemconfig(index, selectforeground=highlight_text_color)
|
||||
if highlight_background_color is not None:
|
||||
self.widget.itemconfig(index, selectbackground=highlight_background_color)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue