New direction with pygame wideget
This commit is contained in:
parent
9d12890ee3
commit
78aceadf5b
BIN
PyGame/practice/button.png
Normal file
BIN
PyGame/practice/button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
34
PyGame/practice/dropdwn.py
Normal file
34
PyGame/practice/dropdwn.py
Normal file
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pygame
|
import pygame
|
||||||
|
import sys
|
||||||
import pygame_menu
|
import pygame_menu
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
|
@ -12,17 +13,33 @@ screen.fill(color)
|
||||||
pygame.display.set_caption('Dice Roll')
|
pygame.display.set_caption('Dice Roll')
|
||||||
clock = pygame.time.Clock()
|
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):
|
def set_number_dice(value: str, die_number: int):
|
||||||
# Do the job here !
|
# Do the job here !
|
||||||
pass
|
pass
|
||||||
def set_dice_sides(value: str, sides: int):
|
def set_dice_sides(value: str, sides: int):
|
||||||
# Do the job here !
|
# Do the job here !
|
||||||
pass
|
pass
|
||||||
|
roll_button.draw()
|
||||||
|
|
||||||
|
|
||||||
run = True
|
run = True
|
||||||
while run == True:
|
while run == True:
|
||||||
|
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
run = False
|
run = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user