############################################################################# ## This file is part of the Ostendo Resource Manager. ## ##-------------------------------------------------------------------------## ## Copyright 2007-2008 Bryce Schroeder ## ## bryce.schroeder@gmail.com ## ## http://www.ferazelhosting.net/~bryce/ ## ##-------------------------------------------------------------------------## ## This program is free software: you can redistribute it and/or modify ## ## it under the terms of the GNU General Public License as published by ## ## the Free Software Foundation, either version 3 of the License, or ## ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## ## along with this program. If not, see . ## ############################################################################# #TODO - determine if this is finished or not! from .standard_interpreters import Resource, R from .g import g import cStringIO import pygame, interface module = type(pygame) class Interface(Resource): MANDATORY = ['code'] #OPTIONAL = ['meta'] def init(self): self.meta = {} if self.parts.has_key('meta'): self.meta = self.process_meta(self.parts['meta']) locals = {} exec self.parts['code'] in globals(), locals # allow the user to specifiy multiple windows # and inital parameters via this mechaism. self.setup = locals['setup'] # there is now the matter of possibly an event handler. handler = self.meta.get("handler", None) if handler: self.handler = locals[handler]() else: self.handler = None # maybe there are premade configurations? self.configs = locals.get("configurations", None) self.locals = locals self.setup.func_globals.update(locals) def make(self, group=None): """ Bind this window to a Window Group layer. If group is None, a new one will be created and returned. """ if not group: group = interface.WindowGroup() for window in self.setup(): group.add(window) if self.handler: self.handler.load() group.add_event_handler(self.handler) if self.configs: for k,v in self.configs().items(): group.add_configuration(k,v) group.request_focus(None) return group