Input element - fix for bug with text color & logic wasn't quite right with the "read for disabled" stuff in the update as well as when making window

This commit is contained in:
PySimpleGUI 2023-05-11 15:37:47 -04:00
parent 43c49380a2
commit 2e6b74f0f1
1 changed files with 22 additions and 9 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.61.0.177 Unreleased" version = __version__ = "4.61.0.178 Unreleased"
_change_log = """ _change_log = """
Changelog since 4.60.0 released to PyPI on 8-May-2022 Changelog since 4.60.0 released to PyPI on 8-May-2022
@ -424,6 +424,8 @@ _change_log = """
Improved linux distro detection Improved linux distro detection
4.61.0.177 4.61.0.177
Custom Titlebar - Support for disabling resizing (maximizing too), support for disable minimize and disable close Custom Titlebar - Support for disabling resizing (maximizing too), support for disable minimize and disable close
4.61.0.178
Input element - fix for bug with text color & logic wasn't quite right with the "read for disabled" stuff in the update as well as when making window
""" """
__version__ = version.split()[0] # For PEP 396 and PEP 345 __version__ = version.split()[0] # For PEP 396 and PEP 345
@ -2519,11 +2521,25 @@ class Input(Element):
_error_popup_with_traceback('Error in Input.update - The window was closed') _error_popup_with_traceback('Error in Input.update - The window was closed')
return return
if background_color not in (None, COLOR_SYSTEM_DEFAULT):
self.TKEntry.configure(background=background_color)
self.BackgroundColor = background_color
if text_color not in (None, COLOR_SYSTEM_DEFAULT):
self.TKEntry.configure(fg=text_color)
self.TextColor = text_color
if disabled is True: if disabled is True:
self.TKEntry['state'] = 'readonly' if self.UseReadonlyForDisable else 'disabled' if self.UseReadonlyForDisable:
self.TKEntry.configure(fg=self.disabled_readonly_text_color)
self.TKEntry['state'] = 'readonly'
else:
self.TKEntry.configure(fg=self.TextColor)
self.TKEntry['state'] = 'disabled'
self.Disabled = True
elif disabled is False: elif disabled is False:
self.TKEntry['state'] = 'readonly' if self.ReadOnly else 'normal' self.TKEntry['state'] = 'normal'
self.Disabled = disabled if disabled is not None else self.Disabled self.TKEntry.configure(fg=self.TextColor)
self.Disabled = False
if readonly is True: if readonly is True:
self.TKEntry['state'] = 'readonly' self.TKEntry['state'] = 'readonly'
@ -2532,10 +2548,7 @@ class Input(Element):
if background_color not in (None, COLOR_SYSTEM_DEFAULT):
self.TKEntry.configure(background=background_color)
if text_color not in (None, COLOR_SYSTEM_DEFAULT):
self.TKEntry.configure(fg=text_color)
if value is not None: if value is not None:
if paste is not True: if paste is not True:
try: try:
@ -16730,7 +16743,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKEntry.configure(selectforeground=element.selected_text_color) element.TKEntry.configure(selectforeground=element.selected_text_color)
if element.disabled_readonly_background_color not in (None, COLOR_SYSTEM_DEFAULT): if element.disabled_readonly_background_color not in (None, COLOR_SYSTEM_DEFAULT):
element.TKEntry.config(readonlybackground=element.disabled_readonly_background_color) element.TKEntry.config(readonlybackground=element.disabled_readonly_background_color)
if element.disabled_readonly_text_color not in (None, COLOR_SYSTEM_DEFAULT): if element.disabled_readonly_text_color not in (None, COLOR_SYSTEM_DEFAULT) and element.Disabled:
element.TKEntry.config(fg=element.disabled_readonly_text_color) element.TKEntry.config(fg=element.disabled_readonly_text_color)
element.Widget.config(highlightthickness=0) element.Widget.config(highlightthickness=0)