Skip to content

Commit

Permalink
Introduce 'progress' parameter to enable progress bar (disabled by de…
Browse files Browse the repository at this point in the history
…fault)
  • Loading branch information
pozitronik committed Nov 15, 2024
1 parent 2d69583 commit b7d2121
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
9 changes: 8 additions & 1 deletion sinner/gui/GUIForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class GUIForm(AttributeLoader):
geometry: str
state: str # currently ignored, see issue #100
sources_library: List[str]
show_progress: bool = False

_event_player_window_closed: SinnerEvent # the event when the player window is closed (forwarded via GUIModel)

Expand Down Expand Up @@ -90,6 +91,12 @@ def rules(self) -> Rules:
'attribute': 'sources_library',
'help': 'The paths to the source files/folders to use in the sources library'
},
{
'parameter': {'progress', 'show-progress'},
'default': False,
'attribute': 'show_progress',
'help': 'Show processing progress indicator (experimental)'
},
{
'module_help': 'GUI Form'
}
Expand Down Expand Up @@ -151,7 +158,7 @@ def on_player_window_key_release(event: Event) -> None: # type: ignore[type-arg
on_self_run_button_press()

# Navigation slider
self.NavigateSlider: BaseFramePosition = FrameSlider(self.NavigationFrame, from_=1, variable=self.GUIModel.position, command=lambda position: self.GUIModel.rewind(int(position)))
self.NavigateSlider: BaseFramePosition = FrameSlider(self.NavigationFrame, from_=1, variable=self.GUIModel.position, command=lambda position: self.GUIModel.rewind(int(position)), progress=self.show_progress)

# Controls frame and contents
self.BaseFrame: Frame = Frame(self.GUIWindow) # it is a frame that holds all static controls with fixed size, such as main buttons and selectors
Expand Down
26 changes: 14 additions & 12 deletions sinner/gui/controls/FramePosition/FrameSlider.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from tkinter import DISABLED, NORMAL, IntVar
from typing import Any, TypeVar, Type
from typing import Any

from customtkinter import CTkSlider

from sinner.gui.controls.FramePosition.BaseFramePosition import BaseFramePosition
from sinner.gui.controls.ProgressIndicator.BaseProgressIndicator import BaseProgressIndicator
from sinner.gui.controls.ProgressIndicator.DummyProgressIndicator import DummyProgressIndicator
from sinner.gui.controls.ProgressIndicator.SegmentedProgressBar import SegmentedProgressBar

T = TypeVar('T', bound=BaseProgressIndicator)


class FrameSlider(CTkSlider, BaseFramePosition):
progress: BaseProgressIndicator

def __init__(self, master: Any, progress: Type[T] = SegmentedProgressBar, **kwargs): # type: ignore[no-untyped-def]
def __init__(self, master: Any, progress: bool = True, **kwargs): # type: ignore[no-untyped-def]
progress_height = 10

# Инициализируем базовый слайдер с измененными параметрами
Expand All @@ -27,14 +27,16 @@ def __init__(self, master: Any, progress: Type[T] = SegmentedProgressBar, **kwar
**kwargs
)

self.progress: BaseProgressIndicator = progress(
master=self.master,
height=progress_height,
borderwidth=0,
border=0,
colors={0: 'orange', 1: 'yellow', 2: 'green', 3: 'red'}
)

if progress:
self.progress = SegmentedProgressBar(
master=self.master,
height=progress_height,
borderwidth=0,
border=0,
colors={0: 'orange', 1: 'yellow', 2: 'green', 3: 'red'}
)
else:
self.progress = DummyProgressIndicator()
self.progress.place_configure(
in_=self,
x=0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# stub to disable progress indicator, when needed
class DummyProgressIndicator(BaseProgressIndicator):
def __init__(self, **kwargs): # type: ignore[no-untyped-def]
def __init__(self, **kwargs) -> None: # type: ignore[no-untyped-def]
pass

def set_segments(self, segments: int) -> None:
Expand Down

0 comments on commit b7d2121

Please sign in to comment.