X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/346a9b8e1fcfe30629f0d1ee4675e9e8f89890cf..4c4732c6ed8cb0aaa70fb2d4c6e5a958868c5349:/src/pgu/gui/app.py?ds=inline diff --git a/src/pgu/gui/app.py b/src/pgu/gui/app.py deleted file mode 100644 index 857af98..0000000 --- a/src/pgu/gui/app.py +++ /dev/null @@ -1,279 +0,0 @@ -""" -""" -import pygame -from pygame.locals import * - -import pguglobals -import container -from const import * - -class App(container.Container): - """The top-level widget for an application. - -
App(theme=None)- -
- app = gui.App()
- app.run(widget=widget,screen=screen)
-
-
- Integrated Example
-
- app = gui.App()
- gui.init(widget=widget)
- while 1:
- for e in pygame.event.get():
- app.event(e)
- app.update(screen)
-
-
-
-
- """
- def __init__(self,theme=None,**params):
- self.set_global_app()
-
- if theme == None:
- from theme import Theme
- theme = Theme()
- self.theme = theme
-
- params['decorate'] = 'app'
- container.Container.__init__(self,**params)
- self._quit = False
- self.widget = None
- self._chsize = False
- self._repaint = False
-
- self.screen = None
- self.container = None
- self.events = []
-
- def set_global_app(self):
- # Keep a global reference to this application instance so that PGU
- # components can easily find it.
- pguglobals.app = self
- # For backwards compatibility we keep a reference in the class
- # itself too.
- App.app = self
-
- def resize(self):
-
- screen = self.screen
- w = self.widget
- wsize = 0
-
- #5 cases
-
- #input screen is already set use its size
- if screen:
- self.screen = screen
- width,height = screen.get_width(),screen.get_height()
-
- #display.screen
- elif pygame.display.get_surface():
- screen = pygame.display.get_surface()
- self.screen = screen
- width,height = screen.get_width(),screen.get_height()
-
- #app has width,height
- elif self.style.width != 0 and self.style.height != 0:
- screen = pygame.display.set_mode((self.style.width,self.style.height),SWSURFACE)
- self.screen = screen
- width,height = screen.get_width(),screen.get_height()
-
- #widget has width,height, or its own size..
- else:
- wsize = 1
- width,height = w.rect.w,w.rect.h = w.resize()
- #w._resize()
- screen = pygame.display.set_mode((width,height),SWSURFACE)
- self.screen = screen
-
- #use screen to set up size of this widget
- self.style.width,self.style.height = width,height
- self.rect.w,self.rect.h = width,height
- self.rect.x,self.rect.y = 0,0
-
- w.rect.x,w.rect.y = 0,0
- w.rect.w,w.rect.h = w.resize(width,height)
-
- for w in self.windows:
- w.rect.w,w.rect.h = w.resize()
-
- self._chsize = False
-
-
- def init(self,widget=None,screen=None): #TODO widget= could conflict with module widget
- """Initialize the application.
-
- App.init(widget=None,screen=None)- -
App.event(e)- -
Automatically calls App.init and then forever loops App.event and App.update
- -Desktop()- """ - def __init__(self,**params): - params.setdefault('cls','desktop') - App.__init__(self,**params)