Commit 83c68bf1 authored by redmood's avatar redmood

stack overflow issue

parent ba38ba21
#-*- coding: utf-8 -*-
import pygame
from graphics.pygame_window_settings import WindowSettings
from gui.pygame_color import PygameColor
from gui.pygame_button import PygameButton
from gui.pygame_view import PygameView
from pygame.locals import QUIT
WINDOW_WIDTH = 700
WINDOW_HEIGHT = 700
ws = WindowSettings(window_width=700, window_height=700)
pygame.init()
#initialising main screen
screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
screen = pygame.display.set_mode((ws.window_width, ws.window_height))
screen.fill(PygameColor.WHITE)
view = PygameView()
button = PygameButton(coords=(200, 200), background_color=PygameColor.YELLOW1, on_focus_background_color=PygameColor.INDIGO, font_family='comicsansms', font_size=30, text='Test Button', border_thickness=0)
#view.add_widget(view, 'dylan_button')
widgets = {'test_button': button}
view.draw(screen)
view.add_widget(view, 'dylan_button')
#view.draw(screen)
for key in view.widgets:
widget = view.widgets[key]
widget.draw(screen)
pygame.display.flip()
clock = pygame.time.Clock()
......
from dataclasses import dataclass
@dataclass
class WindowSettings:
window_width: int
window_height: int
window_title: str='Pygame'
import pygame
from gui.pygame_color import PygameColor
from gui.pygame_widget import PygameWidget
import logging
_logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
class PygameButton:
class PygameButton(PygameWidget):
"""
Represents a button, for pygame
......
......@@ -14,4 +14,5 @@ class PygameView:
def draw(self, screen):
_logger.debug("widgets : {}".format(self.widgets))
for widget_name in self.widgets:
self.widgets[widget_name].draw(screen)
widget = self.widgets[widget_name]
widget.draw(screen)
from abc import ABC, abstractmethod
import pygame
class PygameWidget(ABC):
@abstractmethod
def draw(self):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment