コード例 #1
0
 def __init__(self, parent, position_in_grid):
     self.parent = parent
     if self.parent:
         self.position_in_grid = position_in_grid
         self.dimensions = [
             self.parent.grid.cell_size[0], self.parent.grid.cell_size[1]
         ]
         self.x_positions = [
             x for x in range(0, self.parent.dimensions[0],
                              self.dimensions[0])
         ]
         self.y_positions = [
             x for x in range(0, self.parent.dimensions[1],
                              self.dimensions[1])
         ]
         try:
             self.pos = [
                 self.x_positions[self.position_in_grid[0]] +
                 self.parent.pos[0],
                 self.y_positions[self.position_in_grid[1]] +
                 self.parent.pos[1]
             ]
         except IndexError as e:
             raise Exception(
                 "The parent component's grid does not have such position: {error}."
                 .format(error=str(self.position_in_grid)))
     else:
         self.pos = (0, 0)
         self.dimensions = (0, 0)
     RectWidget.__init__(self, self.pos, self.dimensions, self.parent)
     self.rect = core.Rectangle(self.color, self.pos, self.dimensions)
コード例 #2
0
 def set_image_dimensions(self, d):
     if self.image:
         self.image = pygame.transform.scale(self.image, d)
         self.rect = core.Rectangle(
             self.color, self.pos,
             [self.image.get_width(),
              self.image.get_height()], self.width)
コード例 #3
0
 def set_span(self, span):
     self.span = [span[0] + 1, span[1] + 1]
     self.span_w = sum([self.dimensions[0] for w in range(self.span[0])])
     self.span_h = sum([self.dimensions[1] for h in range(self.span[1])])
     self.dimensions = [self.span_w, self.span_h]
     self.rect = core.Rectangle(self.color, self.pos, self.dimensions,
                                self.width)
     if hasattr(self, "text"): self.set_text(self.text)
コード例 #4
0
 def set_border(self, color, width=8):
     if width == 0:
         raise Exception(
             "Border width cannot be 0, otherwise it will eclipse the underlying rect."
         )
     border_dimensions = [
         self.dimensions[0] + (width * 2), self.dimensions[1] + (width * 2)
     ]
     border_pos = [self.pos[0] - width, self.pos[1] - width]
     self.border = core.Rectangle(color, self.pos, self.dimensions, width)
コード例 #5
0
 def set_carret(self, color, pos, dimensions, width):
     self.carret_color = color
     self.carret_pos = pos
     self.carret_dimensions = dimensions
     self.carret_width = width
     self.carret = core.Rectangle(self.carret_color, self.carret_pos,
                                  self.carret_dimensions, self.carret_width)
     self.carret_counter = 0
     self.carret_blinking_state_manager = False
     self.set_carret_blinking_speed(75)
コード例 #6
0
 def __init__(self,
              grid=None,
              parent=None,
              position_in_grid=None,
              pos=None):
     if pos:
         self.pos = pos
     else:
         self.pos = (0, 0)
     self.grid = grid
     self.dimensions = (self.grid.grid_size[0] * self.grid.cell_size[0],
                        self.grid.grid_size[1] * self.grid.cell_size[1])
     self.x_positions = [
         x for x in range(0, self.dimensions[0], self.grid.cell_size[0])
     ]
     self.y_positions = [
         x for x in range(0, self.dimensions[1], self.grid.cell_size[1])
     ]
     if (parent and position_in_grid):
         self.parent = parent
         self.position_in_grid = position_in_grid
         parents = rpc(parent)
         lastParent = parents[len(parents) - 1]
         self.x_positions = [
             x for x in range(0, lastParent.dimensions[0],
                              lastParent.grid.cell_size[0])
         ]
         self.y_positions = [
             x for x in range(0, lastParent.dimensions[1],
                              lastParent.grid.cell_size[1])
         ]
         self.dimensions = [
             lastParent.grid.cell_size[0], lastParent.grid.cell_size[1]
         ]
         self.pos = (self.x_positions[self.position_in_grid[0]] +
                     lastParent.pos[0],
                     self.y_positions[self.position_in_grid[1]] +
                     lastParent.pos[1])
     else:
         self.position_in_grid = (0, 0)
     RectWidget.__init__(self, self.pos, self.dimensions)
     self.rect = core.Rectangle(self.color, self.pos, self.dimensions,
                                self.width)
コード例 #7
0
 def set_width(self, width):
     self.width = width
     self.rect = core.Rectangle(self.color, self.pos, self.dimensions,
                                self.width)
コード例 #8
0
 def set_color(self, rgba):
     self.color = rgba
     self.rect = core.Rectangle(self.color, self.pos, self.dimensions,
                                self.width)