def __init__( self, settings ): self.window = settings[WINDOW] Controller.__init__( self, GameScreen( self.window.screenDimensions ) ) self.level = 1 self.type = GAME self.nextLevel = None self.playerCount = settings[PLAYERS] + 1 self.mapper = MapBuilder( self.window.brickDimensions, [self.window.brickZone, self.window.brickZoneDimensions]) self.score = MODES[settings[MODE]]( "black", (self.window.screenDimensions[X]/2, SCORE_BUFFER/2), self.playerCount, self ) ''' for p in range( self.playerCount ): axis = racketDetails[p]['axis'] self.rackets.append( Racket( axis, racketDetails[p]['color'], racketDetails[p]['position'], self.window.racketDimensions[axis], self.window.screenSize ) ) #racketDetails[p]['axis']( racketDetails[p]['color'], racketDetails[p]['position'], self.window. ) ) self.players.append( Player( p, self.rackets[p] ) ) self.walls[p] = False ''' self.racketMover = RacketController( self.window.racketPosition, self.window.ballPosition ) results = self.racketMover.buildRackets( self.playerCount, self.window.racketDimensions, self.window.screenSize ) self.bricks = [] self.walls = results[WALLS] self.rackets = results[RACKETS] self.players = results[PLAYERS] self.balls = [ Ball( self.racketMover.racketDetails[p]['ballposition'], self.players[p], self, self.window.ballDimensions, self.window.screenSize ) for p in range( self.playerCount ) ] self.gameOver = False self.start()
def __init__(self, joints, kp=None, kd=None, gpos_des=None, gvel_des=None, name=None): Controller.__init__(self, name=name) self._cndof = 0 dof_map = [] for j in joints: if not isinstance(j, LinearConfigurationSpaceJoint): raise ValueError('Joints must be LinearConfigurationSpaceJoint instances') else: self._cndof += j.ndof dof_map.extend(range(j.dof.start, j.dof.stop)) self._dof_map = array(dof_map) self.joints = joints if kp is None: self.kp = zeros((self._cndof, self._cndof)) else : self.kp = array(kp).reshape((self._cndof, self._cndof)) if kd is None: self.kd = zeros((self._cndof, self._cndof)) else : self.kd = array(kd).reshape((self._cndof, self._cndof)) if gpos_des is None: self.gpos_des = zeros(self._cndof) else: self.gpos_des = array(gpos_des).reshape(self._cndof) if gvel_des is None: self.gvel_des = zeros(self._cndof) else: self.gvel_des = array(gvel_des).reshape(self._cndof)
class Game: running = True def __init__(self, resolution): pygame.init() self.resolution = resolution self.screen = pygame.display.set_mode(resolution) pygame.display.set_caption("2DMaze Game") self.controller = Controller(resolution, self.screen) def main(self): clock = pygame.time.Clock() self.screen.fill(Drawer.white) while self.running: #handle the events should_quit = self.controller.handle_events() if should_quit: break #Run calculations to determine where objects move, #what happens when objects colli6de, etc. self.controller.update_game_status() #Clear the screen self.screen.fill(Drawer.white) #Draw everything self.controller.draw() pygame.display.flip() # Limit to 15 frames per second clock.tick(15)
def main(): """ Run the server """ DB_URL = "sqlite:///todo.db" controller = Controller(DB_URL) controller.bootstrap() app = create_app(controller) waitress.serve(app, host='0.0.0.0', port=8080)
def __init__( self, settings ): self.window = settings[WINDOW] Controller.__init__( self, EditorScreen( self.window.screenDimensions, [self.window.brickZone, self.window.brickZoneDimensions] ) ) self.type = EDITOR self.bricks = [] self.mapper = MapBuilder( self.window.brickDimensions, [self.window.brickZone, self.window.brickZoneDimensions]) self.mapper.newTemplate() self.score = EditorMode( "black", (self.window.screenDimensions[0]/2, SCORE_BUFFER/2), 0, self )
def showUI(): if chimera.nogui: tk.Tk().withdraw() global ui if not ui: ui = PropKaDialog() model = ViewModel(gui=ui) controller = Controller(gui=ui, model=model) ui.enter() controller.set_mvc()
def showUI(*args, **kwargs): if chimera.nogui: tk.Tk().withdraw() ui = QMSetupDialog(*args, **kwargs) model = Model(gui=ui) controller = Controller(gui=ui, model=model) ui.enter()
def showUI(): if chimera.nogui: tk.Tk().withdraw() global ui if not ui: ui = PLIPInputDialog() _ = Controller(gui=ui) ui.enter()
def showUI(): if chimera.nogui: tk.Tk().withdraw() global ui if not ui: ui = PoPMuSiCExtension() model = Model(gui=ui) controller = Controller(gui=ui, model=model) ui.enter()
def showUI(*args, **kwargs): if chimera.nogui: tk.Tk().withdraw() model = Model() global ui if not ui: ui = DummyDialog(*args, **kwargs) model.gui = ui controller = Controller(gui=ui, model=model) ui.enter()
def __init__( self, settings ): #display='main', dimensions=MENU_DIMENSIONS ): Controller.__init__( self, MenuScreen( settings[DIMENSIONS] )) self.type = MENU if len( settings ) == 3: self.scores = settings[SCORES] else: self.scores = None self.menuStack = [] self.menuList = {'main':menu1, 'settings':menu2, 'scores':menu3} self.menu = Menu( settings[DISPLAY], self.menuList[ settings[DISPLAY] ] ) self.screen.screen.blit( self.menu.image, MENU_POSITION ) self.initGame = 0 self.currentOption = 0 self.onSubOption = False #Selecting a suboption? (As opposed to a main option) self.pointer = Pointer( "images/pointer.gif", self.menu.positionMap, self.currentOption ) self.subPointer = Pointer( "images/subpointer.gif", self.menu.subPositionMap, self.currentOption, visible=False ) #change to "images/subpointer.gif" self.selected = None
def showUI(callback=None, *args, **kwargs): """ Requested by Chimera way-of-doing-things """ if chimera.nogui: tk.Tk().withdraw() global ui if not ui: # Edit this to reflect the name of the class! ui = MMSetupDialog(*args, **kwargs) model = Model(gui=ui) controller = Controller(gui=ui, model=model) ui.enter() if callback: ui.addCallback(callback)
def __init__(self, resolution): pygame.init() self.resolution = resolution self.screen = pygame.display.set_mode(resolution) pygame.display.set_caption("2DMaze Game") self.controller = Controller(resolution, self.screen)
def __init__(self, world, gravity=-9.81, name=None): assert isinstance(world, World) self._bodies = world.ground.iter_descendant_bodies self.gravity = float(gravity) Controller.__init__(self, name=name)
def Apply(self): self.controller = Controller(self) self.vibrations = self.controller.run()
def main(): db_url = "sqlite:///fos2.db" print("Connecting to {}".format(db_url)) fos = Controller(db_url) fos.bootstrap() main_user_interface(fos)
from core import Controller controller = Controller() def start(): controller.autodiscover_modules() controller.start() def stop(): controller.stop() if __name__ == '__main__': start()
def __init__(self, gravity=-9.81, name=None): self.gravity = float(gravity) Controller.__init__(self, name=name)
def load_controller(self): binary, dat = prefs.get_preferences() return Controller(gui=self, nciplot_binary=binary, nciplot_dat=dat)
class NormalModesConfigDialog(TangramBaseDialog): buttons = ('Run', 'Close') help = "https://github.com/insilichem/tangram_normalmodes" VERSION = '0.0.1' VERSION_URL = "https://api.github.com/repos/insilichem/tangram_normalmodes/releases/latest" def __init__(self, parent=None, engine='prody', *args, **kwargs): # GUI init self.title = 'Calculate Normal Modes with ' + engine.title() self.parent = parent self.engine = engine if engine == 'prody': self.fill_in_ui = self._fillInUI_Prody else: self.fill_in_ui = self._fillInUI_Gaussian self.lennard_jones = False self.mass_weighted = False super(NormalModesConfigDialog, self).__init__(resizable=False, *args, **kwargs) def _fillInUI_Prody(self, parent): # # Algorithm selection # self.canvas.columnconfigure(1, weight=1) row = 0 self.ui_algorithms_menu_lbl = tk.Label(self.canvas, text='Algorithm:', anchor='e') self.ui_algorithms_menu = Pmw.OptionMenu( self.canvas, items=[ 'Full atom', 'Extend from C-alpha', 'Group by residues', 'Group by mass', 'Group by graph' ], command=self._algorithms_menu_cb) self.ui_algorithms_param = Pmw.EntryField(self.canvas, entry_width=3, validate={ 'validator': 'integer', 'min': 1 }, labelpos='w', label_text='#:') self.ui_algorithms_param.setvalue(1) self.ui_algorithms_menu_lbl.grid(row=row, column=0, sticky='we', padx=3, pady=3) self.ui_algorithms_menu.grid(row=row, column=1, sticky='we', padx=3, pady=3, columnspan=2) # # Number of modes & Molecule Minimization # row += 1 self.ui_n_modes_lbl = tk.Label(self.canvas, text='# Modes:', anchor='e') self.ui_n_modes = Pmw.EntryField(self.canvas, entry_width=3, validate={ 'validator': 'integer', 'min': 1 }) self.ui_n_modes.setvalue(20) self.ui_n_modes_lbl.grid(column=0, row=row, sticky='we', padx=3, pady=3) self.ui_n_modes.grid(column=1, row=row, sticky='news', padx=3) self.ui_minimize_btn = tk.Button( self.canvas, text="Minimize", ) #command=lambda: chimera.dialogs.display(mmmdDialog.name)) self.ui_minimize_btn.grid(column=2, row=row, sticky='we', padx=3, pady=3) # # Cutoff # row += 1 self.ui_cutoff_lbl = tk.Label(self.canvas, text='Cutoff:', anchor='e') self.ui_cutoff = Pmw.EntryField(self.canvas, entry_width=3, validate={ 'validator': 'real', 'min': 4.0 }) self.ui_cutoff.setvalue(15.0) self.ui_cutoff_lbl.grid(column=0, row=row, sticky='we', padx=3, pady=3) self.ui_cutoff.grid(column=1, row=row, sticky='news', padx=3) # # Cutoff # row += 1 self.ui_gamma_lbl = tk.Label(self.canvas, text='Gamma LJ:', anchor='e') self.ui_gamma = Pmw.EntryField(self.canvas, entry_width=3, validate={ 'validator': 'real', 'min': 0.0 }) self.ui_gamma.setvalue(1.0) self.ui_gamma_lbl.grid(column=0, row=row, sticky='we', padx=3, pady=3) self.ui_gamma.grid(column=1, row=row, sticky='news', padx=3) # # Optional Selections: Lennard-Jones and mass-weighted hessian # row += 1 self.ui_extra_options = Pmw.Group(self.canvas, tag_text='Options') self.ui_extra_options.grid(column=0, row=row, columnspan=3, sticky='nsew', padx=5, pady=5) self.ui_extra_options_chk = Pmw.RadioSelect( self.ui_extra_options.interior(), buttontype='checkbutton') self.ui_extra_options_chk.add('Mass-Weighted') self.ui_extra_options_chk.grid(column=0, row=0, sticky='we') # # Model selection # row += 1 self.ui_molecules_lbl = tk.Label(self.canvas, text="Select model:", anchor='e') self.ui_molecules_lbl.grid(column=0, row=row, padx=3) self.ui_molecules = MoleculeScrolledListBox( self.canvas, listbox_selectmode="single") self.ui_molecules.grid(column=1, row=row, columnspan=3, sticky='nsew', padx=3, pady=3) def _fillInUI_Gaussian(self, parent): row = 0 parent.columnconfigure(0, weight=1) self.ui_gaussian_grp = Pmw.Group(self.canvas, tag_text='Open Gaussian output file') self.ui_gaussian_grp.grid(column=0, row=row, columnspan=2, sticky='nsew', padx=5, pady=5) self.ui_gaussian_grp.columnconfigure(0, weight=1) self.ui_gaussian_grp.columnconfigure(1, weight=0) self.ui_gaussian_file_entry = Pmw.EntryField( self.ui_gaussian_grp.interior()) self.ui_gaussian_file_entry.pack(side='left', expand=True, fill='both', padx=5, pady=5) self.ui_gaussian_btn = tk.Button(self.ui_gaussian_grp.interior(), text='...', command=self._load_file) self.ui_gaussian_btn.pack(side='right', padx=5, pady=5) def Apply(self): self.controller = Controller(self) self.vibrations = self.controller.run() def Run(self): self.Apply() self.Close() def _load_file(self, *a, **kw): path = askopenfilename() if path: self.ui_gaussian_file_entry.setvalue(path) def _algorithms_menu_cb(self, *a, **kw): value = self.ui_algorithms_menu.getvalue() if value.startswith('Group by'): self.ui_algorithms_param.grid(row=0, column=2, sticky='ew', padx=5) if value == 'Group by residues': self.ui_algorithms_param.configure(label_text='# residues:') elif value == 'Group by mass': self.ui_algorithms_param.configure(label_text='# groups:') else: self.ui_algorithms_param.grid_forget()