Skip to content

Commit

Permalink
Fix error on python 3.8. refs alejandroautalan/pygubu-designer#253
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroautalan committed May 17, 2024
1 parent 173b47e commit b0932a9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pygubu/forms/ttkwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ class TtkWidgetViewManager(TkWidgetViewManager):
def mark_invalid(self, widget: ttk.Widget, state: bool):
style: str = widget.cget("style")
if style:
style = style.removeprefix("Error.")
# remove prefix if exists.
prefix = "Error."
if style.startswith(prefix):
style = style[len(prefix) :]
if state:
style = f"Error.{style}"
style = f"{prefix}{style}"
widget.configure(style=style)


Expand All @@ -33,8 +36,14 @@ class TtkWidgetInfoViewManager:
def _set_style(self, widget, mode: str):
style: str = widget.cget("style")
if style:
style = style.removeprefix("Error.")
style = style.removeprefix("Help.")
# remove prefix if exists
prefix = "Error."
if style.startswith(prefix):
style = style[len(prefix) :]
# remove prefix if exists
prefix = "Help."
if style.startswith(prefix):
style = style[len(prefix) :]
style = f"{mode}.{style}"
widget.configure(style=style)

Expand Down

0 comments on commit b0932a9

Please sign in to comment.