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 import random win_width = 600 win_height = 480 win_bg_color = (0, 0, 0) dice_results = [4, 6, 8, 10, 12,20] dice_count = [ 0, 1] def roll_dice(): print("Type of dice: D", side_dropdown.getSelected()) print("Number of dice: ", numdice_dropdown.getSelected()) results = [] for dice in range(0, numdice_dropdown.getSelected()): results.append(random.randint(1, side_dropdown.getSelected())) print(results) pygame.init() window = pygame.display.set_mode((win_width, win_height)) pygame.display.set_caption('Dice Roll') icon = pygame.image.load(os.path.join("icon", "dieicon_64x.png")) icon.convert_alpha() pygame.display.set_icon(icon) side_dropdown = Dropdown( window, 120, 10, 150, 50, name='How many sides', choices=[ 'D4', 'D6', 'D8', 'D10', 'D12', 'D20', ], borderRadius=3, colour=pygame.Color(200, 200, 200), values=[4, 6, 8, 10, 12, 20], direction='down', textHAlign='left' ) numdice_dropdown = Dropdown( window, 320, 10, 150, 50, name='Number of Dice', choices=[ '1', '2', ], borderRadius=3, colour=pygame.Color(200, 200, 200), values=[1, 2], direction='down', textHAlign='left' ) button = Button( window, 200, 300, 200, 50, text='Roll', fontSize=50, textColor=("red"), margin=20, inactiveColour=(243, 243, 243), pressedColour=(0, 255, 0), radius=5, onClick=roll_dice, font=pygame.font.SysFont('calibri', 30), textVAlign='bottom', ) run = True while run: events = pygame.event.get() for event in events: if event.type == pygame.QUIT: pygame.quit() run = False quit() window.fill(win_bg_color) pygame_widgets.update(events) pygame.display.update()