diff --git a/PyGame/practice/button.png b/PyGame/practice/button.png new file mode 100644 index 0000000..5e60599 Binary files /dev/null and b/PyGame/practice/button.png differ diff --git a/PyGame/practice/dropdwn.py b/PyGame/practice/dropdwn.py new file mode 100644 index 0000000..fe697c2 --- /dev/null +++ b/PyGame/practice/dropdwn.py @@ -0,0 +1,34 @@ +import os +os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" +import pygame_widgets +import pygame +from pygame_widgets.button import Button +from pygame_widgets.dropdown import Dropdown + +pygame.init() + +win_width = 600 +win_height = 480 +win_bg_color = (102, 255, 255) + +window = pygame.display.set_mode((win_width, win_height)) +pygame.display.set_caption('Dice Roll') + +window.fill(win_bg_color) + + +run = True +while run: + events = pygame.event.get() + for event in events: + if event.type == pygame.QUIT: + pygame.quit() + run = False + quit() + + + pygame_widgets.update(events) + pygame.display.update() + + + diff --git a/PyGame/practice/prac.py b/PyGame/practice/prac.py index 5445a92..522bb2a 100644 --- a/PyGame/practice/prac.py +++ b/PyGame/practice/prac.py @@ -1,4 +1,5 @@ import pygame +import sys import pygame_menu pygame.init() @@ -12,17 +13,33 @@ screen.fill(color) pygame.display.set_caption('Dice Roll') clock = pygame.time.Clock() +# button.png is 200x61 +roll_img = pygame.image.load('button.png').convert_alpha() + +class Button(): + def __init__(self, x, y, image): + self.image = image + self.rect = self.image.get_rect() + self.rect.topleft = (x, y) + + def draw(self): + screen.blit(self.image, (self.rect.x, self.rect.y)) + + +roll_button = Button(((screen_width // 2) // 2) - (roll_img.get_width() // 2), 200, roll_img) + def set_number_dice(value: str, die_number: int): # Do the job here ! pass def set_dice_sides(value: str, sides: int): # Do the job here ! pass - - +roll_button.draw() run = True while run == True: + + for event in pygame.event.get(): if event.type == pygame.QUIT: run = False