def run(self, base_paths): """Run dddoc on the modules below the given path. Args: base_paths Paths to build the documentation for. Returns: Return code of the application. Is 0 for no problem, and 1 on errors and warnings. """ print 'Scanning modules...' app = core.App() if self.cache_only: for fn in app.cache.content.iterkeys(): core.parseFile(fn, app.cache) else: # Scan some/all modules. for path in base_paths: os.path.normpath(path) app.loadFiles(path) # Scan doc directories. for doc_dir in self.doc_dirs: print 'Scanning %s...' % doc_dir app.loadFiles(doc_dir) app.loadingComplete() # Actually build the HTML files. print 'Creating HTML Documentation...' tpl_path = os.path.abspath( os.path.join(os.path.dirname(__file__), 'tpl')) res = html.createDocs(app.error_logger, app.dddoc_tree, tpl_path, self.out_dir) # Done, print end message. print 'Documentation created/updated.' return res
import sys import core import state class StartUp(state.State): pass config = {"screen_size": (1024, 768), "bgcolor": (150, 150, 150)} if __name__ == "__main__": startup = StartUp() app = core.App(config=config) sys.exit(app.run_with_state(startup))
(i * self.space, self.size[1])) @staticmethod def get_cpos(pos): return (int(pos[0] / 20 + 0.5) * 20, int(pos[1] / 20 + 0.5) * 20) def update(self, events): super(Board, self).update(events) for event in events: if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: pos = event.pos if self.rect.collidepoint(pos): pygame.draw.circle(self.image, utils.colors.black, Board.get_cpos(pos), self.space // 2) class GameScene(state.Scene): def __init__(self): super(GameScene, self).__init__() self.board = Board(core.get_config().board_size) self.register_display(self.board) self.register_update(self.board) if __name__ == '__main__': app = core.App(config={'board_size': (710, 600)}) scene = GameScene() sys.exit(app.run_with_state(scene))
class MyState(state.State): def enter(self): self.balls = [Ball() for i in range(4)] for index, ball in enumerate(self.balls): ball.rect.topleft = (index % 3 * 200, index // 3 * 200) self.app = core.App.instance() self.app.screen.fill((255, 255, 255)) def update(self, events): super(MyState, self).update(events) self.app.screen.fill((255, 255, 255)) for ball in self.balls: ball.move() for ball in self.balls[:]: self.balls.remove(ball) for ballx in self.balls: if ball.dis(ballx) <= 120: ball.reverse() self.balls.append(ball) for ball in self.balls: self.app.screen.blit(ball.image, ball.rect) pygame.display.flip() if __name__ == "__main__": startup = MyState() app = core.App() sys.exit(app.run_with_state(startup))