Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProgressBar determinate_speed divided by 50 #2606

Open
erukami opened this issue Oct 10, 2024 · 1 comment
Open

ProgressBar determinate_speed divided by 50 #2606

erukami opened this issue Oct 10, 2024 · 1 comment

Comments

@erukami
Copy link

erukami commented Oct 10, 2024

In the step method of ctk_progessbar.py, the determinate_speed attribute is being divided by 50. I may have missed it in the documentation, but I did not see a purpose for this.

def step(self):
    """ increase progress """
    if self._mode == "determinate":
        self._determinate_value += self._determinate_speed / 50
        if self._determinate_value > 1:
            self._determinate_value -= 1
        self._draw()
    else:
        self._indeterminate_value += self._indeterminate_speed
        self._draw()

This presents an issue if manually using the step method and configuring the determinate_speed based on an incrementer:

import customtkinter

app = customtkinter.CTk()
progress = customtkinter.CTkProgressBar(app, mode="determinate", determinate_speed=.25)
progress.set(0)

print("Determinate speed is .25")
for i in range(1,5):
    progress.step()
    speed = progress.get()
    print(f"Incremented to {speed} instead of {speed * 50}")

Result:

Determinate speed is .25
Incremented to 0.005 instead of 0.25
Incremented to 0.01 instead of 0.5
Incremented to 0.015 instead of 0.75
Incremented to 0.02 instead of 1.0

Maybe it is a carryover from the _internal_loop method and not intentional?

def _internal_loop(self):
   if self._loop_running:
        if self._mode == "determinate":
            self._determinate_value += self._determinate_speed / 50
            if self._determinate_value > 1:
                self._determinate_value -= 1
            self._draw()
            self._loop_after_id = self.after(20, self._internal_loop)
        else:
            self._indeterminate_value += self._indeterminate_speed
            self._draw()
            self._loop_after_id = self.after(20, self._internal_loop)
@DenishKakadiya
Copy link

Because of dividing by 50, step increament in each step is also double of what determinate_speed is set.

  • For determinate_speed = 10, it gives increament of 0.2, instead of 0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants