Ejemplo n.º 1
0
def welcome_screen():
  welcome_word = TextPygame("Welcome to PruVide", screen, CURRENT_TIME, font = 20, textpos = (85,10,15,130))
  image = pygame.image.load("/home/pi/all_projects/pru_vide/pruvide_gui/images/cooking_ingredients.jpg")
  image_rotated = pygame.transform.rotate(image,90)
  imagepos = image_rotated.get_rect()
  screen.blit(image_rotated,(0,20,80,120))
  welcome_word.render_and_draw()
  pygame.display.update()
Ejemplo n.º 2
0
class MenuSystem:
  def __init__(self, screen, menu_items, font = 24):
    self.screen = screen
    self.font_size = font
    self.current_item = 0
    self.font = pygame.font.Font(None, font)
    self.centerx = 30
    self.starty = 15
    self.menu_objects = deque()
    self.menu_items = deque(menu_items)
    self.padding = 5
    self.make_menu_objects()

  def place_carrot(self):
    pos = self.menu_objects[0].textpos
    x = pos[0]
    y = pos[1] + pos[3]
    self.carrot = TextPygame(">", self.screen, (x,y) , prefix = "", textpos = ())

  def make_menu_objects(self):
    self.menu_objects = deque()
    currenty = self.starty
    self.menu_objects.append(TextPygame(self.menu_items[0], self.screen, (currenty, self.centerx),
      prefix = "", textpos = ()))
    for item in itertools.islice(self.menu_items, 1, len(self.menu_items)):
      currenty = (self.font_size/2) + currenty + self.padding
      self.menu_objects.append(TextPygame(item, self.screen,
            (currenty, self.centerx) , prefix = "", textpos = ()))

  def return_current(self):
    print self.menu_items[0]

  def up_menu(self):
    self.menu_items.rotate(-1)
    self.make_menu_objects()

  def down_menu(self):
    self.menu_items.rotate(1)
    self.make_menu_objects()

  def clear_screen(self):
    self.screen.fill((250,250,250))
    pygame.display.update()

  def draw_menu(self):
    self.clear_screen()
    for item in self.menu_objects:
      item.render_and_draw()
    self.place_carrot()
    self.carrot.render_and_draw()
Ejemplo n.º 3
0
class MenuSystem:
  def __init__(self, screen, menu_dict, font = 24):
    self.screen = screen
    self.font_size = font
    self.current_item = 0
    self.font = pygame.font.Font(None, font)
    self.centerx = 30
    self.starty = 15
    self.full_menu = menu_dict
    self.menu_objects = deque()
    self.current_selection = ""
    self.menu_items = deque(make_menu_level())
    self.padding = 5
    self.make_menu_objects()

  def set_new_menu(self, menu_items):
    self.menu_items = deque(menu_items)
    self.make_menu_objects()

  def make_menu_level(self):
    level = []
    for k,v in self.full_menu.items():
      level.append(v)
    return level

  def select_menu_item(self):
    # get new level items.
    # set current selection
    # make menu_objects
    # draw_menu selections

  def back_menu_item(self):
    # get new level items.
    # set current selection
    # make menu_objects
    # draw_menu selections


  def place_carrot(self):
    pos = self.menu_objects[0].textpos
    x = pos[0]
    y = pos[1] + pos[3]
    self.carrot = TextPygame(">", self.screen, (x,y) , prefix = "", textpos = ())

  def make_menu_objects(self):
    self.menu_objects = deque()
    currenty = self.starty
    self.menu_objects.append(TextPygame(self.menu_items[0], self.screen, (currenty, self.centerx),
      prefix = "", textpos = ()))
    for item in itertools.islice(self.menu_items, 1, len(self.menu_items)):
      currenty = (self.font_size/2) + currenty + self.padding
      self.menu_objects.append(TextPygame(item, self.screen,
            (currenty, self.centerx) , prefix = "", textpos = ()))


  def return_current(self):
    return self.menu_items[0]

  def up_menu(self):
    self.menu_items.rotate(-1)
    self.make_menu_objects()

  def down_menu(self):
    self.menu_items.rotate(1)
    self.make_menu_objects()

  def clear_screen(self):
    self.screen.fill((250,250,250))
    pygame.display.update()

  def draw_menu(self):
    self.clear_screen()
    for item in self.menu_objects:
      item.render_and_draw()
    self.place_carrot()
    self.carrot.render_and_draw()
Ejemplo n.º 4
0
def one_item(default_settings):
  blah = TextPygame(**default_settings)
  blah.render_and_draw()
  return blah