from image import Image
from slider import Slider
-
pygame.init()
screen = pygame.display.set_mode((640, 480))
a = Slider(100, 100, 100, 20, 0, 100, 50, Color.LIGHT_GRAY, Color.DARK_GRAY, 4, 5, 10)
b = Text(100, 100, "Slider", "Arial", 20, Color.BLACK)
-c = VBoxContainer(100, 100, Color.LIGHT_GRAY, Color.DARK_GRAY, 4, 5, 10, 0, True,[b,a])
+c = VBoxContainer(100, 100, Color.LIGHT_GRAY, Color.DARK_GRAY, 4, 5, 10, 0, True, [b, a])
is_running = True
while is_running:
class Slider:
slider_thickness = 4
+
def __init__(self, x, y, width, height, min_val=0, max_val=100, default=0, background_color=Color.WHITE,
slider_color=Color.BLACK, border_color=Color.BLACK, border_width=1, border_radius=0, padding=15):
self.x = x
pygame.draw.line(screen, self.border_color, (self.x, self.y + (self.height - 2 * self.padding) // 2),
(self.x + self.width - 2 * self.padding, self.y + (self.height - 2 * self.padding) // 2), 3)
pygame.draw.rect(screen, self.slider_color,
- (self.x + (self.width - 2 * self.padding) * (self.value - self.min_value) / (self.max_value - self.min_value) - self.slider_thickness//2,
+ (self.x + (self.width - 2 * self.padding) * (self.value - self.min_value) / (
+ self.max_value - self.min_value) - self.slider_thickness // 2,
self.y, self.slider_thickness, self.height - 2 * self.padding))