class TestCursorMovement(unittest.TestCase): @vals([Cursor.MoveLeft, Cursor.MoveRight, Cursor.MoveUp, Cursor.MoveDown]) def test_MovementEmptyContent(self, cursorFunc): contents = [[]] expectedCursor = Cursor(0, 0) cursor = Cursor(0, 0) cursorFunc(cursor, contents) self.assertEqual(cursor, expectedCursor) def name_test(original_name, cursorFunc, expectedCursor): return '{0}_Cursor_{1}_{2}_{3}'.format(original_name, cursorFunc.__name__, str(expectedCursor.x), str(expectedCursor.y)) @vals([(Cursor.MoveLeft, Cursor(0, 0)), (Cursor.MoveRight, Cursor(1, 0)), (Cursor.MoveUp, Cursor(0, 0)), (Cursor.MoveDown, Cursor(0, 0))], name=name_test) def test_MovementOneChar_StartLeft(self, cursorFunc, expectedCursor): contents = [['a']] cursor = Cursor(0, 0) cursorFunc(cursor, contents) self.assertEqual(cursor, expectedCursor) @vals([(Cursor.MoveLeft, Cursor(0, 0)), (Cursor.MoveRight, Cursor(1, 0)), (Cursor.MoveUp, Cursor(0, 0)), (Cursor.MoveDown, Cursor(0, 0))], name=name_test) def test_MovementOneChar_StartRight(self, cursorFunc, expectedCursor): contents = [['a']] cursor = Cursor(1, 0) cursorFunc(cursor, contents) self.assertEqual(cursor, expectedCursor)
def __init__(self, organizer, screenSize, camera, clock, fps): self.organizer = organizer self.screenSize = screenSize self.width = screenSize[0] self.height = screenSize[1] self.closePlatform = False #The main while loop looks if this is true or false to break out of the while loop self.clock = clock self.fps = fps self.cursor = Cursor( 0, 0, 20, self.organizer ) # Initialize a cursor in coord (0,0) with radius 20 self.pongButton = CursorRecognition( "Pong", 30, [100, 200, 200, 200], self.organizer ) # Make a button for the areaSurveillance with left corner coords (100,200) & length/width = 200 self.spaceInvadersButton = CursorRecognition("Space Invaders", 30, [500, 200, 400, 200], self.organizer) self.calibrationButton = CursorRecognition(" Calibrate", 30, [1000, 200, 300, 200], self.organizer) self.closeButton = CursorRecognition("CLOSE", 30, [1500, 50, 200, 150], self.organizer) self.camera = camera OR.calibrate(self.screenSize, self.camera, 0) # Initialize the color for controller '0' organizer.state = "calibrationTest" self.objectCoordinates, self.cameraImage = OR.getCoords( self.camera, 0) # Get the coordinates for controller '0' self.controllernr = 0
def enter(): global boss_exist, middle_boss_exist boss_exist = 0 middle_boss_exist = 0 global boss_gauge boss_gauge = 0 global hero global cursor global boss global boss_right_arm global boss_left_arm global enemy_genarate global middle_boss map = Map() cursor = Cursor() boss = Boss() boss_right_arm = Boss_right_arm() boss_left_arm = Boss_left_arm() middle_boss = Middle_boss() hero = Hero() hide_cursor() game_world.add_object(map, 0) enemy_genarate = Enemy_genarate() game_world.add_object(hero, 1) game_world.add_object(cursor, 4) game_world.add_object(enemy_genarate, 0)
def enter(): hide_cursor() global background, cursor, x, y, isCollide, isBattle, rooms, font, start, play_turn, font_size_30 isCollide = False isBattle = False play_turn = battle_state.turn background = Background() cursor = Cursor() font = load_font('font\\gothic.ttf', 20) font_size_30 = load_font('font\\gothic.ttf', 30) cursor.x, cursor.y = x, y rooms = [Room() for i in range(7)] for i in range(0, 7): rooms[i].num = i rooms[i].x, rooms[i].y = room_location_table[i][ 0], room_location_table[i][1] if not start: create_room(1, 7) else: rooms = battle_state.rooms if rooms[i].boss: del rooms rooms = [Room() for i in range(7)] for i in range(0, 7): rooms[i].num = i rooms[i].x, rooms[i].y = room_location_table[i][ 0], room_location_table[i][1] create_room(1, 7)
def process(self): # load data data = self.load() # index to elastic search print "\nStart processing" cursor = Cursor(self.es, self.data_from) cursor_num = cursor.get_new_cursor() for each_data in data: key_string = '' for each_key_string in key_value: key_string += each_data[each_key_string] hashkey = mmh3.hash(key_string) print "parsing id: ", hashkey # try to read record try: res = self.es.get( index="deltadb", doc_type="data", id=hashkey) if res["found"]: node = self.update_node(res["_source"], each_data, cursor_num) else: node = self.create_node(each_data, cursor_num) except: node = self.create_node(each_data, cursor_num) # insert back to es try: res = self.es.index(index="deltadb", doc_type="data", id=hashkey, body=node) except: continue print "\nProcess finish."
def cursor(self, query=None, order_by=None, reply=None, page_size=18, **filters): """Query resource objects. :param query: full text search query string in Xapian format :param order_by: name of property to sort by; might be prefixed by either `+` or `-` to change order's direction :param reply: list of property names to return for found objects; by default, only GUIDs will be returned; for missed properties, will be sent additional requests to a server on getting access to particular object. :param page_size: number of items in one cached page, there are might be several (at least two) pages :param filters: a dictionary of properties to filter resulting list """ from cursor import Cursor return Cursor(self.mountpoint, self.document, query, order_by, reply, page_size, **filters)
def draw_troparion(self, neumes_list: List[Neume], lyrics_list: List[Lyric], dropcap: Dropcap): """Draws a troparion with the passed text attributes. :param neumes_list: A list of neumes. :param lyrics_list: A list of Lyrics. :param dropcap: A dropcap object. """ dropcap_offset = 0 # Pop off first letter of lyrics, since it will be drawn as a dropcap if dropcap and len(lyrics_list) > 0: lyrics_list[0].text = lyrics_list[0].text[1:] lyrics_list[0].recalc_width() dropcap_offset = dropcap.width + dropcap.x_padding if neumes_list: neume_chunks = self.make_neume_chunks(neumes_list) glyph_line: List[Glyph] = self.make_glyph_list( neume_chunks, lyrics_list) lines_list: List[GlyphLine] = self.line_break( glyph_line, Cursor(dropcap_offset, 0), self.doc.width, self.styleSheet['Neumes'].leading, self.styleSheet['Neumes'].wordSpace) if len(lines_list ) > 1 or self.styleSheet['Neumes'].alignment is TA_JUSTIFY: lines_list: List[GlyphLine] = self.line_justify( lines_list, self.doc.width, dropcap_offset) tropar = Troparion(lines_list, dropcap, self.doc.width) self.story.append(tropar)
def select_all_rows(self, table): cursor = Cursor(table) leaf_node = Leaf_Node(table.get_page(cursor.page_num)) while cursor.end_of_table == False: leaf_node.get_row(cursor.cell_num).print() cursor.advance(leaf_node.num_cells)
def main(): file = sys.argv[1] contents = [[y for y in x] for x in open(file).read().split('\n')] cursor = Cursor() done = False draw(contents, cursor) while not done: if msvcrt.kbhit(): a = msvcrt.getch() b = b'\x00' if a == b'\x00' or a == b'\xe0': b = msvcrt.getch() if a == b'\x11': done = True if a == b'\xe0': { Keys.LeftArrow: cursor.MoveLeft, Keys.RightArrow: cursor.MoveRight, Keys.UpArrow: cursor.MoveUp, Keys.DownArrow: cursor.MoveDown }[b](contents) print("Last Key: {},{}".format(a, b)) print("Cursor: {}".format(cursor)) print('_________________________') draw(contents, cursor) time.sleep(0.01)
def __init__(self, screen, camera, organizer, controllernr, lastState): self.camera = camera self.screen = screen self.lastState = lastState self.backToLastState = False self.backToCalibration = False self.organizer = organizer self.firstCheck = False self.cursor = Cursor(0, 0, 20, self.organizer) self.upperLeftButton = CursorRecognition("1", 20, [50, 50, 200, 200], self.organizer) self.upperRightButton = CursorRecognition("2", 20, [1850 - 250, 50, 200, 200], self.organizer) self.lowerRightButton = CursorRecognition( "3", 20, [1850 - 250, 1080 - 250, 200, 200], self.organizer) self.lowerLeftButton = CursorRecognition( "4", 20, [50, 1080 - 250, 200, 200], self.organizer) # I hate hardcoding, resolution is 1850,1080 self.controllernr = controllernr self.objectCoordinates, self.cameraImage = OR.getCoords( self.camera, 0) # Get the coordinates for controller '0' self.allowedTime = 15 # Time to complete the calibration self.startTime = time.time( ) # Starttime when the program gets initialized self.elapsedTime = time.time() # gets updated every loop self.timer = self.elapsedTime - self.startTime # Time left
def cursor(self, filter=None, sort=None, hints=None): """ Returns a :class:`Cursor <geoscript.layer.cursor.Cursor>` over the features of the layer. *filter* is a optional :class:`Filter <geoscript.filter.Filter>` to constrain the features iterated over. *sort* is an optional tuple or ``list`` of tuples that defined the order in which features are iterated over. The first value of each tuple is the name of a field to sort on. The second value is one of the strings 'ASC' or 'DESC', representing ascending and decending sort order respectively. >>> l = Layer() >>> from geoscript import geom >>> l.add([geom.Point(1,2)]) >>> l.add([geom.Point(3,4)]) >>> l.add([geom.Point(5,6)]) >>> l.add([geom.Point(7,8)]) >>> l.add([geom.Point(9,10)]) >>> c = l.cursor() >>> f = c.next() >>> f.geom POINT (1 2) >>> f = c.next() >>> f.geom POINT (3 4) >>> features = c.read(2) >>> len(features) 2 >>> features[0].geom POINT (5 6) >>> features[1].geom POINT (7 8) >>> features = c.read(2) >>> len(features) 1 >>> features[0].geom POINT (9 10) >>> c.close() """ f = Filter(filter) if filter else Filter.PASS q = DefaultQuery(self.name, f._filter) if sort: sort = sort if isinstance(sort, list) else [sort] sortBy = [] ff = _filterFactory for s in sort: s = s if isinstance(s, tuple) else [s, 'ASC'] sortBy.append(ff.sort(s[0], SortOrder.valueOf(s[1]))) q.setSortBy(sortBy) if self.proj: q.coordinateSystem = self.proj._crs if hints is not None: q.setHints(Hints(hints)) fcol = self._source.getFeatures(q) #r = self._source.dataStore.getFeatureReader(q,Transaction.AUTO_COMMIT) return Cursor(fcol, self)
def __init__(self,screen,camera,organizer): boundaryOffset = [50,50] boundaryThickness = 10 self.screen = screen self.width = screen.get_width() self.height = screen.get_height() self.backToHomeScreen = False boundaryLength = self.width-2*boundaryOffset[0] self.upperboundary = Boundary(boundaryOffset[0],boundaryOffset[1],boundaryThickness,boundaryLength) self.lowerboundary = Boundary(boundaryOffset[0],self.height-boundaryOffset[1],boundaryThickness,boundaryLength) self.organizer = organizer self.ball = Ball(int(self.width/5),int(self.height/5),20) paddleWidth = 10 paddleHeight = 100 cursorRadius = 20 self.leftPaddle = Paddle(10,self.height/2,paddleHeight,paddleWidth) self.rightPaddle = Paddle(self.width-10-paddleWidth,self.height/2,paddleHeight,paddleWidth) self.score = Score(self) self.components = (self.upperboundary,self.lowerboundary,self.ball,self.leftPaddle,self.rightPaddle,self.score) self.cursor = Cursor(int(self.width/2),int(self.height/2), cursorRadius,self.organizer) self.drawCursor = False #Buttons self.selectSpeedButton = CursorRecognition("Select speed",30, [200, self.height/2-50, 360,100],self.organizer) #Triggerare in state "menu" - yellow square self.speedOneButton = CursorRecognition("1",30, [int((self.width/6)*1)-50, int(self.height/2)-150, 150,150],self.organizer) # Number 1 to 5: square to select speed in state "select_speed" self.speedTwoButton = CursorRecognition("2",30, [int((self.width/6)*2)-50, int(self.height/2)+150, 150,150],self.organizer) self.speedThreeButton = CursorRecognition("3",30, [int((self.width/6)*3)-50, int(self.height/2)-150, 150,150],self.organizer) self.speedFourButton = CursorRecognition("4",30, [int((self.width/6)*4)-50, int(self.height/2)+150, 150,150],self.organizer) self.speedFiveButton = CursorRecognition("5",30, [int((self.width/6)*5)-50, int(self.height/2)-150, 150,150],self.organizer) # Triggers square to repeat the game in state "endgame" self.restartButton = CursorRecognition("Restart", 30,[int((self.width/6)*5),int((self.width/6)*2),200,150],self.organizer) self.homeScreenButton = CursorRecognition("Home screen", 30,[200,int((self.width/6)*2),350,150],self.organizer) self.stopGameButton = CursorRecognition("STOP",30,[int(self.width/2-90),100,180,100],self.organizer) #camera and objectrecognition self.camera = camera OR.calibrate([self.width, self.height], self.camera, 1) # Initialize the color for second controller '1' # mainModel.controllernr=1 # mainModel.organizer.state == "calibrationTest" # mainModel.controllernr = 0 self.objectCoordinatesRight, self.cameraImage = OR.getCoords(self.camera,0) #gets coordinates of the two objects from the python file ObjectRecogImplementation.py self.objectCoordinatesLeft = OR.getCoords(self.camera,1) #initialize the sprite groups for collision detection self.boundaryGroup = pygame.sprite.Group() self.boundaryGroup.add(self.upperboundary) self.boundaryGroup.add(self.lowerboundary) self.paddleGroup = pygame.sprite.Group() self.paddleGroup.add(self.leftPaddle) self.paddleGroup.add(self.rightPaddle) #Initialize the sounds dir_path = os.path.dirname(os.path.realpath(__file__)) self.boundarySound = pygame.mixer.Sound(dir_path+"/data/boundaryBounce.wav") self.paddleSound = pygame.mixer.Sound(dir_path+"/data/paddleBounce.wav") self.deathSound = pygame.mixer.Sound(dir_path+"/data/death.wav")
def __init__(self, filename=None): self.__sheet = Sheet() self.__cursor = Cursor() self.__io = FileIO(filename) self.__programIsRunning = True self.__lastCommand = "" self.load()
def __init__(self): """ inits a new instance of Document class with attributes characters, cursor and filename """ self.characters = [] self.cursor = Cursor(self) self.filename = ''
def __init__(self,screen,camera,organizer): self.camera = camera self.screen = screen self.organizer = organizer self.backToHomeScreen = False self.firstCheck = False self.cursor = Cursor(0,0,20,self.organizer) self.upperLeftButton = CursorRecognition("1",30, [10,10,200,200],self.organizer)
def enter(): global bgm, image, cursor image = load_image("image\\title_state.png") bgm = load_music('sound\\title_music.mp3') cursor = Cursor() bgm.set_volume(64) bgm.repeat_play() hide_cursor() pass
def __init__(self): self.__message_queue = [] self.__cur_stat_surf = None self.__actors = [] self.__items = [] self.__gfx = None self.__quit_loop = False self.__last_id = 0 self.__id_gen = self.__gen_id() self.__actors_on_screen = [] self.__timer = 0 self.__world_time = 0 self.__load_fonts() self.__build_surf_cache() self.__set_game_instance() self.__player_actions = PlayerActions(self) self.__state_worker = StateWorker(self) self.__actor_grid = [] self.__item_grid = [] for y in xrange(200): aline = [] iline = [] for x in xrange(200): aline.append([]) iline.append([]) self.__actor_grid.append(aline) self.__item_grid.append(iline) self.map = None self.dungeon = dungeon.DungeonsOfGogadan() self.quit_mes = QUIT self.stats = [ att.Att('Strength', 'Important for Melee-Fighter', 20), att.Att('Endurance', 'Important for Melee-Fighter'), att.Att('Mind', 'Important for Spellcaster'), att.Att('Health', 'How much can you take?', 45) ] self.camera = Camera(20, 26) self.state = S_RUN self.__await_target = None Debug.init_debug(self) Debug.debug('init pygame') pygame.init() self.screen = pygame.display.set_mode((1024, 768)) self.__clock = pygame.time.Clock() self.item_to_throw = None self.cursor = Cursor(self) self._items_to_choose = {} self._symbols = [] c = 'abcdefghijklmonpqrstuvwxyz' for s in c: self._symbols.append(s)
def build_until_square_satisfies_criteria(end, check, calculate): squares = SquareMap() cursor = Cursor(mode=Mode.build_x, x=0, y=0, max_degree=0) square: Square while cursor.id == 1 or not check(square, end): square = Square(id=cursor.id, x=cursor.x, y=cursor.y, data=calculate(squares, cursor.x, cursor.y)) squares.add(square) cursor.move_cursor() return squares
def __init__(self): self._window = sf.RenderWindow( sf.VideoMode(settings.windowWidth, settings.windowHeight), "BaconBulb") self._window.vertical_synchronization = True self._window.framerate_limit = 60 self._window.mouse_cursor_visible = False self._cursor = Cursor(self._window) self._game_menu = GameMenu(self._window)
def parse_non_empty(self, start, level): grammars = Cursor(self.grammars) result = False end = start while grammars.not_empty() and not result: (result, end) = grammars.head().parse(start, level + 1) if not result: grammars = grammars.tail() return (result, end)
def line_justify(line_list: List[GlyphLine], max_line_width: int, first_line_x_offset: int) -> List[GlyphLine]: """Justify a line of neumes by adjusting space between each neume group. :param line_list: A list of glyphs :param max_line_width: Max width a line of neumes can take up. :param first_line_x_offset: Offset of first line, usually from a dropcap. :return line_list: The modified line_list with neume spacing adjusted. """ for line_index, line in enumerate(line_list): # Calc width of each chunk (and count how many chunks) total_chunk_width = sum(glyph.width for glyph in line) # Skip if last line if line_index + 1 == len(line_list): continue # Subtract total from line_width (gets space remaining) space_remaining = (max_line_width - first_line_x_offset) - total_chunk_width # Divide by number of chunks in line glyph_spacing = space_remaining / len(line) cr = Cursor(0, 0) for glyph in line: adj_lyric_pos, adj_neume_pos = 0, 0 neume_width = getattr(glyph.neume_chunk, 'width', 0) lyric_width = getattr(glyph.lyric, 'width', 0) if neume_width >= lyric_width: # center lyrics adj_lyric_pos = (glyph.width - lyric_width) / 2. # special cases primary_neume = glyph.neume_chunk[0] if primary_neume.char == '/': # If variea, center lyric under neume chunk without vareia adj_lyric_pos += primary_neume.width / 2. elif primary_neume.char == '_': # If syneches elaphron, center lyric under elaphron apostr_width = pdfmetrics.stringWidth( '!', primary_neume.font_family, primary_neume.font_size) adj_lyric_pos += apostr_width / 2. else: # center neume adj_neume_pos = (glyph.width - neume_width) / 2. glyph.neume_chunk_pos[0] = cr.x + adj_neume_pos glyph.lyric_pos[0] = cr.x + adj_lyric_pos cr.x += glyph.width + glyph_spacing # After first line (dropcap), set first line offset to zero first_line_x_offset = 0 return line_list
def __init__(self, w, h): pygame.init() self.size = w, h self.screen = pygame.display.set_mode(self.size) pygame.display.set_caption(TITLE) pygame.display.flip() self.hero_is_died = pygame.sprite.Sprite() self.hero_is_died.image = pygame.image.load("data/hero_died.png") self.hero_is_died.rect = self.hero_is_died.image.get_rect() self.hero_is_win = pygame.sprite.Sprite() self.hero_is_win.image = pygame.image.load("data/win.png") self.hero_is_win.rect = self.hero_is_died.image.get_rect() self.dead = pygame.sprite.Group() self.win_sp = pygame.sprite.Group() self.hero_is_win.add(self.win_sp) self.hero_is_died.add(self.dead) self.camera = Camera(w, h) self.win_m, self.dead_m = False, False self.music = [ pygame.mixer.Sound("data/background_music_1.ogg"), pygame.mixer.Sound("data/background_music_2.ogg"), pygame.mixer.Sound("data/background_music_3.ogg") ] self.menu_music = pygame.mixer.Sound("data/music/main_menu.ogg") self.victory_music = pygame.mixer.Sound("data/Victory.wav") self.dead_music = pygame.mixer.Sound("data/dead.wav") self.menu_music.play(-1) self.hero_sprite = pygame.sprite.Group() self.enemy_sprites = pygame.sprite.Group() self.boss_sprite = pygame.sprite.Group() self.platform_sprites = pygame.sprite.Group() self.all_sprites = pygame.sprite.Group() self.princess_sprite = pygame.sprite.Group() self.info_sprites = pygame.sprite.Group() self.background_sprite = pygame.sprite.Group() self.buttons = pygame.sprite.Group() self.level_names = ["intro", "1", "2", "final"] self.level_state = 0 self.new_game_btn = Button(self.buttons, "new_game_btn.png", "new_game_btn_2.png", 208, 93, "bookFlip2.ogg", "new_game") self.hero = Hero(self.hero_sprite, 60, 60, Sounds().return_dict_of_sounds()) self.hero.add(self.all_sprites) self.cursor_group = pygame.sprite.Group() self.cursor = Cursor(self.cursor_group) self.main_menu = True self.bg = Background(self.background_sprite) self.main_img = pygame.image.load("data/main_menu.png") pygame.mouse.set_visible(False) self.clock = pygame.time.Clock() self.fps = 40 self.just_music = None self.left_state, self.up_state, self.attack = None, None, None self.running = True
def fork(self, thread_task, is_deep_copy=False): namespace = self.namespace.fork(is_deep_copy) scheduler = self.__class__(namespace=namespace, thread_task=thread_task, cursor=Cursor(thread_task.getNet()), scheduler_parent=self) self.namespace.vars[CHILDREN][thread_task] = { 'namespace': namespace, 'scheduler': scheduler, 'process': None } return scheduler
def __init__(self, stdscr): # Set member values self.screen = stdscr self.height, self.width = self.screen.getmaxyx() self.file = text.TextFile("cursor.py") self.quit = False self.cursor = Cursor(self.file) self.status = "" # Set curses to non-blocking input self.screen.nodelay(True) self.screen.timeout(0)
def __init__(self, opciones): self.fondo = pygame.image.load("imagen/fondo-menu.jpg").convert() self.fuente = pygame.font.Font('fuentes/ninja-turtles-regular.otf', 80) self.texto = self.fuente.render('TURTLE NINJA ', True, Color.VERDE) self.opciones = list() self.cursor = Cursor() self.seleccionado = 0 self.total = len(opciones) self.mantiene_pulsado = False self.sonido_menu = pygame.mixer.Sound('audio/an_8_bit_story.ogg') self.sonido_menu.play(loops=-1) self.construir_opciones(opciones)
def clearLevel(self): """Tworzy pusty poziom.""" self._level = [[[Field((x, y)) for x in xrange(MAP_SIZE)] for y in xrange(MAP_SIZE)]] self._map = Map(self._engine, self, self._level, True) self._cursor = Cursor(self._engine, self._map) self._minimap = Minimap(self._engine, self._map) self._tiles = TilesGrid(self._engine, self, self._map) self._menu = EditorMenu(self._engine, self) self._submodules = (self._map, self._minimap, self._tiles, self._menu, self._cursor) self._refresh = True
def find(self, *args, **kwargs): if not 'slave_okay' in kwargs and hasattr(self, 'slave_okay'): kwargs['slave_okay'] = self.slave_okay if not 'read_preference' in kwargs and hasattr(self, 'read_preference'): kwargs['read_preference'] = self.read_preference if not 'tag_sets' in kwargs and hasattr(self, 'tag_sets'): kwargs['tag_sets'] = self.tag_sets if not 'secondary_acceptable_latency_ms' in kwargs and\ hasattr(self, 'secondary_acceptable_latency_ms'): kwargs['secondary_acceptable_latency_ms'] = ( self.secondary_acceptable_latency_ms) return Cursor(self, *args, **kwargs)
def __init__(self, _engine): super(Scene, self).__init__() self._ais = [] self._engine = _engine self._resx, self._resy = _engine.getResolution() self.surface = pygame.Surface((self._resx, self._resy)) drawText(self.surface, "Wczytywanie mapy...", 48, (255, 255, 255), (self._resx / 2, self._resy / 2)) self._map = Map(_engine) self._hub = Hub(_engine, self._map) self._cursor = Cursor(_engine, self._map) self._ais.append(AI(_engine, self._map, _engine.players[0], 0)) self._ais.append(AI(_engine, self._map, _engine.players[1], 1))
def __init__(self, size=9): self.players = [Player('B', 300), Player('W', 300)] self.currentPlayer = 0 self.board = Board(size) self.territories = Board(size) self.previousBoard = self.board.getMatrix() self.currentBoard = self.board.getMatrix() self.cursor = Cursor(self.board) self.attemptedPlace = False self.handler = EventHandler() self.UI = UIMatch(size, self.handler) self.newGame = False self.exit = False
def grab_pointer(self, window, cursor="left_ptr", confine_to=None): """Grab pointer on a window.""" from cursor import Cursor confine_to = confine_to or window self.core.GrabPointer(False, window, xcb.xproto.EventMask.ButtonPress | xcb.xproto.EventMask.ButtonRelease | xcb.xproto.EventMask.PointerMotion, xcb.xproto.GrabMode.Async, xcb.xproto.GrabMode.Async, confine_to, Cursor(window.colormap, cursor), xcb.xproto.Time.CurrentTime)