Skip to content

Commit

Permalink
style: Improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaokang2022 committed Jan 10, 2025
1 parent 7009e01 commit 2e28218
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions tkintertools/standard/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

__all__ = [
"BaseFeature",
"LabelFeature",
"ButtonFeature",
"Underline",
Expand All @@ -15,6 +14,7 @@
"ProgressBarFeature",
"InputBoxFeature",
"SliderFeature",
"SegmentedButtonFeature",
"SpinBoxFeature",
]

Expand All @@ -30,13 +30,6 @@
from ..toolbox import utility


class BaseFeature(virtual.Feature):
"""Base Feature"""

def _motion(self, event: tkinter.Event) -> bool:
return self.widget.shapes[0].detect(event.x, event.y)


class LabelFeature(virtual.Feature):
"""Feature of Label"""

Expand Down Expand Up @@ -472,6 +465,13 @@ def _button_release_1(self, _: tkinter.Event) -> bool:
self.widget.update("hover")


class SegmentedButtonFeature(virtual.Feature):
"""Feature of SegmentedButton"""

def _motion(self, event: tkinter.Event) -> bool:
return self.widget.shapes[0].detect(event.x, event.y)


class SpinBoxFeature(virtual.Feature):
"""Feature of SpinBox"""

Expand Down
10 changes: 5 additions & 5 deletions tkintertools/standard/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"LabelStyle",
"OptionButtonStyle",
"ProgressBarStyle",
"RadioGroupStyle",
"RadioBoxStyle",
"SegmentedButtonStyle",
"SliderStyle",
"SwitchStyle",
Expand Down Expand Up @@ -473,7 +473,7 @@ class CheckBoxStyle(ToggleButtonStyle):
}


class RadioGroupStyle(virtual.Style):
class RadioBoxStyle(virtual.Style):
"""Style of RadioGroup"""

light = {
Expand Down Expand Up @@ -619,16 +619,16 @@ class UnderlineButtonStyle(TextStyle):
light = {
"Information": {
"normal": {"fill": "#1A1A1A"},
"hover": {"fill": "blue"},
"active": {"fill": "purple"},
"hover": {"fill": "royalblue"},
"active": {"fill": "#787878"},
}
}

dark = {
"Information": {
"normal": {"fill": "#F1F1F1"},
"hover": {"fill": "royalblue"},
"active": {"fill": "purple"},
"active": {"fill": "#787878"},
}
}

Expand Down
4 changes: 2 additions & 2 deletions tkintertools/standard/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def __init__(
capture_events=capture_events, gradient_animation=gradient_animation,
auto_update=auto_update, style=style)
if style is None:
self.style = styles.RadioGroupStyle(self)
self.style = styles.RadioBoxStyle(self)
if configs.Env.system == "Windows10":
shapes.Rectangle(self, name=".out")
shapes.Rectangle(
Expand Down Expand Up @@ -1142,7 +1142,7 @@ def __init__(
self.command = command
if default is not None:
self.set(default)
self.feature = features.BaseFeature(self)
self.feature = features.SegmentedButtonFeature(self)

def get(self) -> int | None:
"""Get the index of the child toggle button with a value of True. If not, None is
Expand Down

0 comments on commit 2e28218

Please sign in to comment.