def test_feature_move_2_pawns_and_strike(self): input = ['Batman', 'Superman', 'a2', 'a4', 'b7', 'b5', 'a4', 'b5', 'quit'] ui.input = lambda x: input.pop(0) test_ui = ui.UI() test_ui.start() assert test_ui.game.board[3][1].colour == 'White' assert isinstance(test_ui.game.board[3][1], pawn.Pawn)
def main(): repo = repository.Repository() contr = controller.Controller(repo) view = ui.UI(contr, repo) view.menu()
def test_get_names(self): input = ['Batman', 'Superman'] ui.input = lambda x: input.pop(0) test_ui = ui.UI() output = test_ui.get_names() assert output[0] == 'Batman' assert output[1] == 'Superman'
def generate(input, algorithm): # based on input, generate custom or random board of specific level if input == 'easy' or input == 'medium' or input == 'hard' or input == 'expert': board = game.user_input('r', input) else: board = game.user_input('c', input) # clues (numbers given on board at the start) clues = [] for row in range(9): for col in range(9): if board[row][col] != 0: clues.append([row, col]) # create second frame top = Toplevel() # sudoku ui - the board window = ui.UI(top, board, clues) # start the solving algorithm start_button = Button(top, text="Start", width=10, command=lambda: start(board, window, top, algorithm)) start_button.pack() # close the second frame and go back to home back_button = Button(top, text="Go Back", width=10, command=top.destroy) back_button.pack(pady=(0, 10))
def runGame(): pygame.init() cfg = config.Config() # config 实例 screen = pygame.display.set_mode( (cfg.screen_width, cfg.screen_height)) # 设置背景 stats = state.Stats(cfg) player_ship = ship.Ship(screen) # ship 实例 common_bullets = Group() # 创建子弹编组 super_bullets = Group() targets = Group() # function.createTargets(cfg, screen, player_ship, targets) pygame.display.set_caption(cfg.title) pygame.display.set_icon(pygame.image.load('resource/ship.bmp')) # print('InitSuccess') start_button = ui.UI(screen, 'Start') while True: function.checkEvent(cfg, screen, player_ship, common_bullets, super_bullets, stats, start_button, targets) if stats.game_activate: player_ship.update() # 玩家ship位置刷新 function.updateBullets(cfg, common_bullets, targets, super_bullets, screen, player_ship, stats) function.updateTargets(cfg, targets, player_ship, stats, common_bullets, screen) function.updateScreen(screen, cfg, player_ship, common_bullets, targets, super_bullets, start_button, stats)
def __init__(self): # FLUFF self.name = "" self.character_class = "" self.character_race = "" self.inventory = inventory.Inventory() # LEVELING UP self.level = 1 self.points = 0 self.current_experience = 0 self.next_lvl_experience = 15 # BASIC STATS self.strength = 1 self.dexterity = 1 self.intelligence = 1 # HP AND MANA self.max_hp = 10 self.current_hp = 10 self.max_mana = 10 self.current_mana = 10 # ATTACK self.weapon = weapons.WeaponsPool.weapons[1] self.attack = self.strength + self.weapon.attack # DEFENCE self.head = armors.ArmorsPool.armors[0] self.torso = armors.ArmorsPool.armors[1] self.arms = armors.ArmorsPool.armors[2] self.legs = armors.ArmorsPool.armors[3] self.shield = armors.ArmorsPool.armors[4] self.armor = self.head.armor + self.torso.armor + self.arms.armor + self.legs.armor + self.shield.armor # ADVANCED STATS self.speed = self.dexterity * 7 self.dodge_chance = int(self.dexterity - self.armor // 2) # UI self.ui = ui.UI()
def start(self, bgui=True): confjson = {} try: f = utils.file_open('config.json') confjson = json.loads(f.read()) f.close() except Exception: None prmsui = {} if "name" in confjson: self._name = unicode(confjson["name"]) prmsui["title"] = self._get_message('configureTitle') if "topinfo" in confjson: prmsui["topinfo"] = confjson["topinfo"] if "topimage" in confjson: prmsui[ "topimage"] = u"ui" + utils.path_sep + u"images" + utils.path_sep + u"custom" + utils.path_sep + confjson[ "topimage"] applg = gdi._get_logo_from_conf( confjson, u"ui" + utils.path_sep + u"images" + utils.path_sep + u"custom" + utils.path_sep) if applg != "": prmsui["logo"] = applg if "leftcolor" in confjson: prmsui["leftcolor"] = confjson["leftcolor"] self._uinterface = ui.UI(prmsui, self.step_init) self._uinterface.start(bgui) self.close_req()
def main_loop(stdscr, world): ''' :param stdscr: standard screen created by curses' wrapper. :param world: the world on which the simulation will run. :return: (nothing). ''' # Initialize UI. u_i = ui.UI(stdscr, world) # Main world loop. end_loop = False while not end_loop: # Display the world as it is now. user_break = u_i.draw() # Check conditions to go on. end_loop = user_break or world.is_end_loop() if not end_loop: # Evolve world by one time-fixed step. t_start = time.time() world.step() if world.spf is not None: # No full-speed mode; keep time-step duration. t_end = time.time() time.sleep(max(0, world.spf - (t_end - t_start)))
def __init__(self, first_scene="title_screen", name="Adventure", reset_save=False): self.ui = ui.UI() self.name = name self.game_variables = {} self.dj = music.DJ(self, 0.8) self.background_dj = music.DJ(self, 0.1) self.save_path = pyglet.resource.get_settings_path(self.name) util.mkdir_if_absent(self.save_path) if reset_save: try: shutil.rmtree(os.path.join(self.save_path, "autosave")) except OSError: pass # Directory didn't exist but we don't care self.scene_handler = scenehandler.SceneHandler(self) scn = self.load() or scene.Scene(first_scene, self.scene_handler, self.ui) self.scene_handler.set_first_scene(scn) self.update = self.scene_handler.update
def main(): ### YOUR MAIN CODE GOES HERE a1ece = ui.UI() if len(sys.argv) == 2 and sys.argv[1]=='-v': a1ece.debugOn() a1ece.run() # return exit code 0 on successful termination sys.exit(0)
def __init__(self): self.ui = ui.UI() self.world = world.generate_world() events.events.add_callback(events.EventType.TILE_REVEALED, self.handle_tile_reveal) self.update_fov() events.events.do_move_event(self.world.player, None) self.ui.render()
def __init__(self, width, height): # init vars self.uiobj = ui.UI(width, height) self.userinputobj = userinput.UserInput() self.gameobj = entity.Game(entity.Player(), entity.Player()) self.logicobj = logic.Logic() # update ui at start self.uiobj.update(self.gameobj, userinput)
def __init__(self, controllable_entity=None, game_map=None): Controllable.__init__(self, game_map, StateMove(self)) self.add_unit(controllable_entity) self.keys_pressed = [] #self.controllable_entity = controllable_entity self.has_update = 1 self.end_turn = 0 self.fov = [] self.ui = ui.UI()
def load(self): self.mBKImage = self.mGame.imageLoader.load(self.mGame.imageDir + 'game.png') dragon = Actor.player.Player(self) self.addActor('player', dragon) self.map = MapInfo.map.Map(self) self.mUI = ui.UI(self, dragon, gameframework.canvasWidth / 2 + 130, gameframework.canvasHeight - 60) self.addActor('ui', self.mUI) self.mBgm = load_music(self.mGame.soundDir + 'gamePage.mp3') self.mBgm.set_volume(64) self.mBgm.repeat_play()
def __init__(self, prefix, client, status='{}help'): self.prefix = prefix self.status = status.format(self.prefix) self.client = client if " " in self.prefix: self.self_destruct() self.Token = customToken.Token("db/token.txt") self.UI = ui.UI(discord.Embed, "db/ui.cfg") self.Poll = poll.Poll(self.UI, "db/polls.json") self.Commands = commands.Commands(self.client, self.Poll, self.UI)
def main(): settings.init() random.seed(time.time()) # print settings.UI_BASEMAP[1][250] GUI = ui.UI() # run(GUI) painterThread = threading.Thread(target=GUI.processMessage) painterThread.setDaemon(True) painterThread.start() # GUI.processMessage() GUI.mainloop()
def enter(): global backgrounds, paths, obstacles, line, cookie, select_cookie, timer, jelly_line, jelly_file global button, score_font, score_font_back, coin_image, jelly_image, obs_sound backgrounds = background.Background() game_world.add_object(backgrounds, 0) if scene_lobby.select_cookie == 1: cookie = cookie_brave.Brave() cookie.newPosition(200, 70 + 115) elif scene_lobby.select_cookie == 2: cookie = cookie_bright.Bright() cookie.newPosition(200, 70 + 115) game_world.add_object(cookie, 2) obstacle_init() jelly_init() for item in jellies: game_world.add_object(item, 1) item.initialize() paths = [path.Path(n) for n in range(2)] for i in paths: game_world.add_object(i, 0) game_world.add_object(scene_lobby.life_num, 2) timer = 0 scene_lobby.bgm = load_music('sound/Cookie Run Ovenbreak - Theme Song Breakout 1.mp3') scene_lobby.bgm.get_volume() scene_lobby.bgm.repeat_play() button = ui.UI() game_world.add_object(button, 2) if score_font == None: score_font = load_font('font/Maplestory Light.ttf', 20) if coin_image == None: coin_image = load_image('resource/Cookie Skill Effects and Jellies/jelly/silver coin.png') if jelly_image == None: jelly_image = load_image('resource/Cookie Skill Effects and Jellies/jelly/simple jelly.png') if obs_sound == None: obs_sound = load_wav('sound/effect sound/g_obs1.wav') obs_sound.set_volume(60) cookie.score = 0
def on_init(self): """game init""" # pylint: disable=E1121 # pylint: disable=W0201 pygame.init() pygame.display.set_caption("snek 2d 0.1") info = pygame.display.Info() self.screenSize = (info.current_w, info.current_h) self.draw_surface = pygame.Surface(self.drawSize) self.resize(1280, 720) self._running = True self.clock = pygame.time.Clock() self.ui = ui.UI(self) self.player = player.Player(self, 100, 20) self.loadMap("levels/level1.json")
def start(self, sizeunit=15): self.gameengine = gameengine.GameEngine(Nx=self.Nx, Ny=self.Ny, player=self.player, timeperiod=0.5) self.gameengine.start() area = self.gameengine.getarea() self.ui = ui.UI(pressaction=self.player.setdirection, area=area, sizeunit=sizeunit) self.ui.start() while self.gameengine.update(): self.ui.setarea(area=self.gameengine.getarea()) self.ui.gameend(self.gameengine.getscore())
def __init__(self): self.version = __version__ self.inited = 0 self.running = 0 # Set default variables self.path = os.path.dirname(os.path.realpath(__file__)) self.files = [] self.current_file = 0 self.status_msg = "" self.last_input = None self.global_buffer = [] self.init_keys() # Define core operations self.operations = { "help": self.help, "save_file": self.save_file, "run_command": self.run_command, "find": self.find, "go_to": self.go_to, "open": self.open, "close_file": self.close_file, "new_file": self.new_file, "ask_exit": self.ask_exit, "prev_file": self.prev_file, "next_file": self.next_file, "save_file_as": self.save_file_as, "reload_file": self.reload_file, "toggle_mouse": self.toggle_mouse, "toggle_fullscreen": self.toggle_fullscreen, } # Load core components self.logger = Logger() self.config = Config(self) self.config.load() self.ui = ui.UI(self) # Load user interface # Load extension modules self.modules = modules.ModuleLoader(self) self.modules.load() # Indicate that windows etc. have been created. self.inited = 1
def run(self): # Get ourselves a UI self.ui = ui.UI(client=True, parent=self, force_curses=self.args.curses, log_lines=self.args.log_lines) self.ui.title("PTP Client version %s (protocol version %d)" % (ptptest.__version__, PTP_CLIENTVER), stdout=True) self.ui.log("Our socket is %s %s" % (self.addr, self.port), stdout=True) eventlet.spawn(self._read_loop) if self.stun: self.stun.set_ui(self.ui) eventlet.spawn(self.stun.run) # Add our servers to the peer list with self._slock: for sk in self.servers: server = self.servers[sk] self.ui.peer_add(group='server', sin=server['sin']) server_ts = 0 client_ts = 0 while self.running: ts = time.time() if ts - server_ts > 7: server_ts = ts # Send our server beacons self._server_beacons() if ts - client_ts > 0.5: client_ts = ts # Send a message to the clients self._client_beacons() # Wait a moment eventlet.sleep(0.05) # Shutting down, try to tell servers self._server_beacons(shutdown=True)
def start(self, sizeunit=100): self.gameengine = GameEngine(state_shape=self.state_shape, player=self.player) self.gameengine.start() boardinfo = self.gameengine.get_board() self.ui = ui.UI(pressaction=self.player.setdirection, boardinfo=boardinfo, sizeunit=sizeunit) self.ui.start() while not self.gameengine.update(): self.ui.setboard(boardinfo=self.gameengine.get_board()) self.ui.gameend(self.gameengine.get_score()) if self.verbose: print('Game End with score: {0}'.format( self.gameengine.get_score()))
def __init__(self, ip): self.station_dict = self.get_stations() self.ip = ip self.last_station = "Unknown" self.last_playing_state = False self.logger = get_logger() self.logger.debug("My ip is: " + self.ip) for zone in soco.discover(interface_addr=self.ip): info = zone.get_speaker_info() if info["zone_name"] == "West" or info["zone_name"] == "East": self.main_group = zone.group self.main_player: SoCo = self.main_group.coordinator self.logger.debug("Current Soco version is: " + str(soco.__version__)) my_ui = ui.UI(self, self.station_dict) my_ui.start()
def run(self): # Spawn a UI self.ui = ui.UI(server=True, parent=self, force_curses=self.args.curses, log_lines=self.args.log_lines) self.ui.title("PTP Server version %s (protocol version %d)" % (ptptest.__version__, PTP_SERVERVER), stdout=True) self.ui.log("Our socket is %s %s" % (self.addr, self.port), stdout=True) self.ui.set_address(self.addr, self.port) eventlet.spawn(self._read_loop) if self.stun: self.stun.set_ui(self.ui) eventlet.spawn(self.stun.run) client_ts = 0 while self.running: ts = time.time() if ts - client_ts > 13: client_ts = ts # Send our beacons to the clients self._client_beacons() # See if any clients need to be expired with self._clock: remove = [] for k in self.clients: client = self.clients[k] if 'ts' not in client or client['ts'] + 30 < ts: remove.append(k) for k in remove: self.ui.log("Expiring client %s" % k) self.ui.peer_del(group='client', sin=self.clients[k]['sin']) del(self.clients[k]) # Wait a moment eventlet.sleep(1)
def start(self, bgui=True): confjson = {} try: f = utils.file_open('config.json') confjson = json.loads(f.read()) f.close() except Exception: None prmsui = {} if "name" in confjson: self._name = unicode(confjson["name"]) prmsui["title"] = self._get_message('configureTitle') if "topinfo" in confjson: prmsui["topinfo"] = confjson["topinfo"] if "topimage" in confjson: prmsui["topimage"] = confjson["topimage"] if "logo" in confjson: prmsui["logo"] = confjson["logo"] if "leftcolor" in confjson: prmsui["leftcolor"] = confjson["leftcolor"] self._uinterface = ui.UI(prmsui, self.step_init) self._uinterface.start(bgui) self.close_req()
import maya.cmds import maya.api.OpenMaya import PySide2.QtWidgets import utils import ui if __name__ == '__main__': # Create the Qt Application app = ui.UI.QApplication.instance() # Create and show the form form = ui.UI() form.show() form.populate_items()
#os.system("echo 1 > /sys/class/gpio/gpio202/value") class Wrapper(): def __init__(self, logger): self.logger = logger def write(self, data): self.logger.info(data) # # log stdout and stderr # sys.stdout = Wrapper(logging.getLogger('STDOUT')) sys.stderr = Wrapper(logging.getLogger('STDERR')) i = ui.UI() tick = LoopingCall(i.mainUiLoop) tick.start(1.0 / 5) usb_handler.setF(i) flash_handler.setF(i) usb = LoopingCall(usb_handler.usb_loop) usb.start(0.5) n = LoopingCall(ssh_do.check_net) n.start(10) i.write("Flasher ready") reactor.run()
import ui from game import Game from solver import Solver if __name__ == '__main__': game = Game() game.load("./data/board05_extreme.txt") solver = Solver(game.board) app = ui.UI(game, solver) app.on_execute()
def ui_setup(event_queue): root = Tk() root.geometry("450x300") game_ui = ui.UI(root, event_queue) game_ui.pack(fill=BOTH, expand=True) return root, game_ui
#Create a stream from which we will receive new requests streamP = streamProvider.StreamProvider() stream = streamP.getStream() #Create a queue onto which we will load new requests queue = Queue.Queue() #Thread to move requests from the stream to the queue listener = eventListener.EventListener(stream, queue) #Our list of mappings -- input string to output midi note. config = configHandler.ConfigHandler('midiPresenterMapping.csv') #UI model = uiModel.UIModel(config) dialog = ui.UI(model) #Processing thread to do bulk of work. -- Receive incoming items from the queue, decide how they should be handled, and notify the UI. queueProcessor.QueueProcessor(queue, config, model, midiHandler) #blocking -- control passes to the UI. dialog.run() print 'end prog' #Cleanup streamP.killStream() sys.exit()