コード例 #1
0
ファイル: bartender.py プロジェクト: BlueSausage/Bartender
    def filterDrinks(self):
        """
                Removes any drinks that can't be handled by the current pump configuration
        """
        drinks = []
        for d in drink_list:
            drinks.append(MenuItem(d['name'], d['ingredients'], False))

        n = 0
        k = 0
        ingredients = 0
        while n < len(drinks):
            while k < len(list(drinks.__getitem__(n).ingredients)):
                for p in sorted(self.pump_configuration):
                    if self.pump_configuration[p]['value'] is not None:
                        if list(drinks.__getitem__(n).ingredients).__getitem__(k) == self.pump_configuration[p]['value']:
                            ingredients += 1
                k += 1
            if len(list(drinks.__getitem__(n).ingredients)) == ingredients:
                drinks.__getitem__(n).visible = True
            ingredients = 0
            k = 0
            n += 1

        return drinks
コード例 #2
0
 def addItem(self, name, description, vegetarian, price):
     # type: (str, str, bool, float) -> None
     menuItem = MenuItem(name, description, vegetarian, price)
     if self.numberOfItems >= DinerMenu.MAX_ITEMS:
         print "Sorry menu is full"
     else:
         self.menuItems[self.numberOfItems] = menuItem
         self.numberOfItems += 1
コード例 #3
0
ファイル: mainMenu.py プロジェクト: shivamdesai/PotRacer
    def __init__(self, size, ui):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.imageCache = Screen.imageCache
        MenuItem.resolution = Screen.resolution

        self.menuItems = []
        self.title = MenuItem('POTracer',(self.resolution[0]//2,int(self.resolution[1]/4)), scaleSize=1.5)
        self.addMenuItem(MenuItem('Play',(int(self.resolution[0]*(1/3.0)),self.resolution[1]//2,)))
        #self.addMenuItem(MenuItem('Options',(int(self.resolution[0]*.5),self.resolution[1]//2)))
        self.addMenuItem(MenuItem('Exit',(int(self.resolution[0]*(2/3.0)),self.resolution[1]//2)))

        self.organizeMenuItems()
コード例 #4
0
def initializeMenu():
    # Populate menu items
    MenuItem(['Set timelapse', 'Raspberry info'])  # Root menu, no parent set
    MenuItem(['Frame interval', '# frames', 'Start timelapse'],
             'Set timelapse')
    MenuItem(['IP address'], 'Raspberry info')

    # Set allowed values of relevant menu items.
    menu = MenuItem.items
    menu['Frame interval'].allowedValues = list(
        chain(
            range(0, 60, 5),  # every 5 s up till 1 min
            range(60, 60 * 60, 60),  # every min up till 1 h
            range(60 * 60, 60 * 60 * 24 + 60 * 60,
                  60 * 60)))  # every h up till and including 1 day
    menu['# frames'].allowedValues = list(
        chain(range(1, 100), range(100, 1000, 100), range(1000, 10000, 1000),
              range(10000, 100000, 10000)))
    menu['Start timelapse'].allowedValues = [True, False]

    # Set default values of relevant menu items
    menu['Frame interval'].value = 5
    menu['# frames'].value = 20
    menu['Start timelapse'].value = False
コード例 #5
0
    def test(self):
        pancakeHouseMenu = Menu("PANCAKE HOUSE MENU", "Breakfast")
        dinerMenu = Menu("DINER MENU", "Lunch")
        cafeMenu = Menu("CAFE MENU", "Dinner")
        dessertMenu = Menu("DESSERT MENU", "Dessert of course")
        coffeeMenu = Menu("COFFEE MENU",
                          "Stuff to go with your afternoon coffee")

        allMenus = Menu("ALL MENUS", "All menus combined")
        allMenus.add(pancakeHouseMenu)
        allMenus.add(dinerMenu)
        allMenus.add(cafeMenu)

        pancakeHouseMenu.add(
            MenuItem("K&B's Pancake Breakfast",
                     "Pancakes with scrambled eggs, and toast", True, 2.99))

        pancakeHouseMenu.add(
            MenuItem("Regular Pancake Breakfast",
                     "Pancakes with fried eggs, sausage", False, 2.99))

        pancakeHouseMenu.add(
            MenuItem(
                "Blueberry Pancakes",
                "Pancakes made with fresh blueberries, and blueberry syrup",
                True, 3.49))

        pancakeHouseMenu.add(
            MenuItem(
                "Waffles",
                "Waffles, with your choice of blueberries or strawberries",
                True, 3.59))

        dinerMenu.add(
            MenuItem("Vegetarian BLT",
                     "(Fakin') Bacon with lettuce & tomato on whole wheat",
                     True, 2.99))

        dinerMenu.add(
            MenuItem("BLT", "Bacon with lettuce & tomato on whole wheat",
                     False, 2.99))

        dinerMenu.add(
            MenuItem("Soup of the day",
                     "Soup of the day, with a side of potato salad", False,
                     3.29))

        dinerMenu.add(
            MenuItem(
                "Hotdog",
                "A hot dog, with saurkraut, relish, onions, topped with cheese",
                False, 3.05))

        dinerMenu.add(
            MenuItem("Steamed Veggies and Brown Rice",
                     "Steamed vegetables over brown rice", True, 3.99))

        dinerMenu.add(
            MenuItem(
                "Pasta",
                "Spaghetti with Marinara Sauce, and a slice of sourdough bread",
                True, 3.89))

        dinerMenu.add(dessertMenu)
        dessertMenu.add(
            MenuItem(
                "Apple Pie",
                "Apple pie with a flakey crust, topped with vanilla icecream",
                True, 1.59))

        dessertMenu.add(
            MenuItem(
                "Cheesecake",
                "Creamy New York cheesecake, with a chocolate graham crust",
                True, 1.99))
        dessertMenu.add(
            MenuItem("Sorbet", "A scoop of raspberry and a scoop of lime",
                     True, 1.89))

        cafeMenu.add(
            MenuItem(
                "Veggie Burger and Air Fries",
                "Veggie burger on a whole wheat bun, lettuce, tomato, and fries",
                True, 3.99))

        cafeMenu.add(
            MenuItem("Soup of the day",
                     "A cup of the soup of the day, with a side salad", False,
                     3.69))

        cafeMenu.add(
            MenuItem(
                "Burrito",
                "A large burrito, with whole pinto beans, salsa, guacamole",
                True, 4.29))

        cafeMenu.add(coffeeMenu)
        coffeeMenu.add(
            MenuItem("Coffee Cake",
                     "Crumbly cake topped with cinnamon and walnuts", True,
                     1.59))
        coffeeMenu.add(
            MenuItem(
                "Bagel",
                "Flavors include sesame, poppyseed, cinnamon raisin, pumpkin",
                False, 0.69))
        coffeeMenu.add(
            MenuItem("Biscotti", "Three almond or hazelnut biscotti cookies",
                     True, 0.89))

        waitress = Waitress(allMenus)
        # waitress.printMenu()
        waitress.printVegetarianMenu()
コード例 #6
0
 def addItem(self, name, description, vegetarian, price):
     # type: (str, str, bool, float) -> None
     menuItem = MenuItem(name, description, vegetarian, price)
     self.menuItems.update({menuItem.getName(): menuItem})
コード例 #7
0
ファイル: main.py プロジェクト: dziaineka/patterns
from menu import Menu
from menuItem import MenuItem
from waitress import Waitress

# Breakfast
cupcake = MenuItem('Cupcake', True, 1.5)
coffee = MenuItem('Coffee', False, 2)
tea = MenuItem('Tea', True, 1)
cereal = MenuItem('Cereal', True, 3)
sandwich = MenuItem('Sandwich', False, 2)

# Pizza store
carbonara = MenuItem('Carbonara', False, 5)
mozarella = MenuItem('Mozarella', False, 6)
cheese_pizza = MenuItem('Cheese Pizza', True, 4)

# Sauces
spicy_sauce = MenuItem('Spicy Sauce', False, 1)
cheese_sauce = MenuItem('Cheese Sauce', False, 1)

# Sushi
nigiri = MenuItem('Nigiri', False, 3)
sashimi = MenuItem('Sashimi', True, 2)
maki = MenuItem('Maki', False, 5)
uramaki = MenuItem('Uramaki', True, 4)
temaki = MenuItem('Temaki', False, 3)

# Menus creation
breakfast = Menu('Breakfast Menu', cupcake, coffee, tea, cereal, sandwich)
sauces = Menu('Sauces Menu', spicy_sauce, cheese_sauce)
pizza = Menu('Pizza Menu', carbonara, mozarella, cheese_pizza, sauces)
コード例 #8
0
# If the MAP doesnt exist, then there may not have been a cache built
# so we go ahead and create a filtered version to cache for display
if os.path.exists(os.path.join(screensPath, 'MAP.png')) == False:
    print("Map cache missing - building")
    tempImage = pygame.image.load(os.path.join(screensPath,
                                               'rawMap.png')).convert()
    remap(tempImage)

    screen.blit(tempImage, (0, 0))
    pygame.display.update()

    pygame.image.save(tempImage, os.path.join(screensPath, "MAP.png"))

print("Building UI...")
for item in screenNames:
    menu.append(MenuItem(menuFont, item, dColor))
    pipboyScreen.append(PipboyScreen(bodyFont, item, dColor))

for item in pipboyScreen:
    print(item)
    item.loadScreenUsingTextFile(screensPath)
    item.loadScreenUsingGfxFile(screensPath)
print("... UI Build complete")

# Create the encoder
encoder = pyky040.Encoder(CLK=pin_clk, DT=pin_dt, SW=pin_sw)

# Setup and launch the thread to monitor the encoder
encoder.setup(scale_min=0,
              scale_max=len(menu) - 1,
              loop=False,
コード例 #9
0
 def addItem(self, name, description, vegetarian, price):
     # type: (str, str, bool, float) -> None
     menuItem = MenuItem(name, description, vegetarian, price)
     self.menuItems.append(menuItem)
コード例 #10
0
ファイル: mainMenu.py プロジェクト: shivamdesai/PotRacer
class MenuScreen(Screen):

    def __init__(self, size, ui):
        background = Background((0,0,0))
        Screen.__init__(self, background, size, ui)
        MenuItem.textCache = Screen.textCache
        MenuItem.imageCache = Screen.imageCache
        MenuItem.resolution = Screen.resolution

        self.menuItems = []
        self.title = MenuItem('POTracer',(self.resolution[0]//2,int(self.resolution[1]/4)), scaleSize=1.5)
        self.addMenuItem(MenuItem('Play',(int(self.resolution[0]*(1/3.0)),self.resolution[1]//2,)))
        #self.addMenuItem(MenuItem('Options',(int(self.resolution[0]*.5),self.resolution[1]//2)))
        self.addMenuItem(MenuItem('Exit',(int(self.resolution[0]*(2/3.0)),self.resolution[1]//2)))

        self.organizeMenuItems()

    def initializeCallbackDict(self):
        self.callbackDict = {}
        self.callbackDict['selectOption'] = ('deviceString', self.select)
        self.callbackDict['exit'] = ('deviceString', self.quit)
        self.callbackDict['connectionQuality'] = ('deviceString', self.printConnectionQuality)

    def addMenuItem(self,item):
        self.menuItems.append(item)

    def draw(self, surf):
        Screen.draw(self, surf)
        self.title.draw(surf)
        for menuItem in self.menuItems:
            menuItem.draw(surf)

    def select(self):
        for item in self.menuItems:
            if item.rect.collidepoint(pygame.mouse.get_pos()):
                if item.text == 'Exit':
                    self.quit()
                elif item.text == 'Play':
                    self.play()
                elif item.text == 'Options':
                    self.displayOptionsScreen()

    def organizeMenuItems(self):
        screenWidth = self.resolution[0]
        itemsLength = 0

        for item in self.menuItems:
            itemsLength += item.rect.width

        if itemsLength >= screenWidth:
            pass#FIXME, Handle this case
        else:
            itemSpace = (screenWidth-itemsLength)/(len(self.menuItems)+1)

        nextPosition = itemSpace
        for i in range(len(self.menuItems)):
            self.menuItems[i].rect.topleft = (nextPosition,self.menuItems[i].rect.topleft[1])
            nextPosition += itemSpace + self.menuItems[i].rect.width

    def quit(self):
        pygame.event.post(pygame.event.Event(pygame.QUIT,{}))

    def play(self):
        gameScreen = GameScreen(self.resolution, self._ui)
        self._ui.addActiveScreens(gameScreen)

    def displayOptionsScreen(self):
        optionsScreen = OptionsScreen(self.resolution, self._ui)
        self._ui.addActiveScreens(optionsScreen)

    def printLook(self, event):
        print event.values

    def printConnectionQuality(self, event):
        print event.values