I'm trying to figure out how to make the progress bar fill the scale not from 100% maximum, but from the maximum value I set. Because even after the definition maximum_progress on 10, and current_progress in 10, scale filling on 10%, not 100%, as I want.
import pygame
import pygame_gui as pg
pygame.init()
window_surface = pygame.display.set_mode((800, 600))
background = pygame.Surface((800, 600))
background.fill(pygame.Color('#000000'))
manager = pg.UIManager((800, 600))
pg.elements.ui_button.UIButton(pygame.Rect((300, 100), (200, 50)), manager=manager, text='+1')
class MyProgressBar(pg.elements.UIProgressBar):
def __init__(self, x, y, w, h, ui_manager):
super().__init__(relative_rect=pygame.Rect((x, y), (w, h)), manager=ui_manager)
self.current_progress = 0
self.maximum_progress = 10
def status_text(self):
return f"{self.current_progress:0.1f}/{self.maximum_progress:0.1f}"
def set_current_progress(self, progress):
self.current_progress = progress
self.percent_full = progress
prog = 0
progressbar = MyProgressBar(300, 200, 200, 50, manager)
is_running = True
clock = pygame.time.Clock()
while is_running:
time_delta = clock.tick(60) / 1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if event.type == pg.UI_BUTTON_PRESSED:
prog += 1
manager.process_events(event)
progressbar.set_current_progress(prog)
progressbar.redraw()
manager.update(time_delta)
window_surface.blit(background, (0, 0))
manager.draw_ui(window_surface)
pygame.display.update()
Perhaps there is some method or variable that is not mentioned in the documentation. Or mentioned in the description of another element, as it was with UIDropDownMenu and parametr "list_item_height". I will be grateful for any hint.