def reset_bg_and_fg_grids(self): self.bg_map_grid = glooey.Board() # self.chunk_size[0], self.chunk_size[1], 32, 64) self.fg_map_grid = glooey.Board() for i in range(self.chunk_size[0]): for j in range(self.chunk_size[1]): # before update we need to init the map with grass. # 0,0 = tile_half_width, tile_half_height # 2,1 = 64, 16 x = 808 - self.tile_half_width + \ ((i * self.tile_half_width) - (j * self.tile_half_width)) y = 912 - self.tile_half_height - \ ((i * self.tile_half_height) + (j * self.tile_half_height)) # print('trying',x,y) bg_mp = MapTile(i, j, 't_grass.png') # can't be none so show transparent tile. fg_mp = MapTile(i, j, 'blank.png') self.bg_map_grid.add(widget=bg_mp, rect=glooey.Rect(x, y, 32, 16)) self.fg_map_grid.add(widget=fg_mp, rect=glooey.Rect(x, y, 32, 16)) self.plane = Plane(self.folder_name)
def __init__(self, position): super().__init__() if isinstance(position, tuple): self.x = position[0] self.y = position[1] else: self.x = 0 self.y = 0 self.background = Slot() self.button = AddButton((self.x, self.y)) self.board = glooey.Board() self.board.add(self.button, bottom=50, left_percent=.8) self.add_back(self.background) self.add_front(self.board)
def __init__(self, position, name=None): super().__init__() self.x = position[0] self.y = position[1] self.output_filename = None if name != None: self.name = checkNameAvailability(name) self.name_label = Text(self.name) else: self.name = checkNameAvailability("CharacterInput") self.name_label = Text(self.name) self.add_back(Slot()) self.hbox = self.HBox() self.board = glooey.Board() self.button = DelButton(position) self.options_button = OptionsButton(position) # Create Left Side of Character Select self.left = self.CharacterInput() # Create Right Side of the widget self.right = ScrollBox() self.right.set_height_hint( Globals._important_vars['window'].get_size()[0] / 6) self.grid = Grid() self.changeCharacter("Kirby") self.right.add(self.grid) self.hbox.add(self.left) self.hbox.add(self.right, 'expand') self.board.add(self.button, bottom=50, left_percent=.4) self.board.add(self.options_button, bottom=50, left_percent=.3) self.board.add(self.name_label, bottom_percent=.90, center_x_percent=.25) self.add_front(self.hbox) self.add_front(self.board)
def __init__(self, position, name=None): super().__init__() self.x = position[0] self.y = position[1] if name != None: self.name = checkNameAvailability(name) self.name_label = Text(self.name) else: self.name = checkNameAvailability("Names") self.name_label = Text(self.name) self.add_back(Slot()) self.grid = glooey.Grid(5, 5) self.grid.set_cell_alignment('center') self.board = glooey.Board() self.remove_button = DelButton(position) self.options_button = OptionsButton(position) self.grid.set_row_height(1, 20) self.grid.set_row_height(2, 5) self.grid.set_row_height(3, 20) self.grid.set_col_width(1, 200) self.grid.set_col_width(3, 200) self.grid[1, 1] = self.player_one_input = TextInput() self.grid[1, 3] = self.player_two_input = TextInput() self.grid[3, 1] = Text("Player 1 Name") self.grid[3, 2] = glooey.Image( pyglet.resource.texture( "Widgets/Textures/SelectWidgetDialog/PlayerName.png")) self.grid[3, 3] = Text("Player 2 Name") self.board.add(self.remove_button, bottom=50, left_percent=.8) self.board.add(self.options_button, bottom=50, left_percent=.7) self.board.add(self.name_label, bottom_percent=.9, center_x_percent=.5) self.add_front(self.grid) self.add_front(self.board)
#!/usr/bin/env python3 import pyglet import glooey import run_demos from vecrec import Vector, Rect window = pyglet.window.Window() gui = glooey.Gui(window) frame = glooey.Frame() frame.decoration.outline = 'green' board = glooey.Board() widget = glooey.EventLogger(50, 50, 'orange') frame.add(board) gui.add(frame) def test_scalar_position_arguments(): board.move(widget, left=0, bottom=0) yield "Put the widget in the bottom left corner." board.move(widget, right=400, top=300) yield "Put the widget in the top right corner." board.move(widget, center_x=200, center_y=150) yield "Put the widget in the center." def test_vector_position_arguments(): board.move(widget, bottom_left=(0, 0))