mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
changed transparent color value from None to "transparent", fixed type hints, added color type and value checking
This commit is contained in:
@@ -44,3 +44,18 @@ class CTkAppearanceModeBaseClass:
|
||||
return color[self.__appearance_mode]
|
||||
else:
|
||||
return color
|
||||
|
||||
@staticmethod
|
||||
def _check_color_type(color: any, transparency: bool = False):
|
||||
if color is None:
|
||||
raise ValueError(f"color is None, for transparency set color='transparent'")
|
||||
elif isinstance(color, (tuple, list)) and (color[0] == "transparent" or color[1] == "transparent"):
|
||||
raise ValueError(f"transparency is not allowed in tuple color {color}, use 'transparent'")
|
||||
elif color == "transparent" and transparency is False:
|
||||
raise ValueError(f"transparency is not allowed for this attribute")
|
||||
elif isinstance(color, str):
|
||||
return color
|
||||
elif isinstance(color, (tuple, list)) and len(color) == 2 and isinstance(color[0], str) and isinstance(color[1], str):
|
||||
return color
|
||||
else:
|
||||
raise ValueError(f"color {color} must be string ('transparent' or 'color-name' or 'hex-color') or tuple of two strings, not {type(color)}")
|
||||
|
||||
Reference in New Issue
Block a user