Ejemplo n.º 1
0
 def __init__(self):
     super().__init__()
     self.TitleFont = pygame.font.SysFont("Lucida Console", 82)
     self.Font = pygame.font.SysFont("Lucida Console", 56)
     self.endtitle = self.TitleFont.render('Game Over', True, (200, 40, 20))
     self.endmsg = self.Font.render('Press Enter/Space to Continue', True,
                                    (150, 150, 150))
     self.Database = DatabaseHandler.Database()
Ejemplo n.º 2
0
    def __init__(self):
        super().__init__()
        self.backgroundColour = (200, 150, 100)
        self.Database = DatabaseHandler.Database()

        self.offset = 20
        self.Title = self.TitleFont.render('', True, (200, 200, 100))

        self.dictOptions = {
            0: ('Add Controls', self.InputControl),
            1: ('New Profile', self.InputPlayer),
            2: ('Main Menu', self.MainMenu)
        }
        # Rectangle used as border
        # Rect((left, top), (width, height))
        self.control_border = pygame.Rect((Constants.SCREEN_WIDTH / 2) - 5, 5,
                                          Constants.SCREEN_WIDTH / 2,
                                          Constants.SCREEN_HEIGHT - 10)

        self.players = self.Database.get_players()
        self.playerPointer = 0
        # Default values just in case
        self.playerText = self.Font.render(self.players[0][0], True, (0, 0, 0))
        self.controls = self.Database.read_controls_player(self.players[0][0])
        self.bindingsText = [
            self.Font.render('UP:    ', True, (0, 0, 0)),
            self.Font.render('DOWN:  ', True, (0, 0, 0)),
            self.Font.render('LEFT:  ', True, (0, 0, 0)),
            self.Font.render('RIGHT: ', True, (0, 0, 0))
        ]

        self.controlTexts = [
            self.Font.render(str(self.controls[0]), True, (0, 0, 0)),
            self.Font.render(str(self.controls[1]), True, (0, 0, 0)),
            self.Font.render(str(self.controls[2]), True, (0, 0, 0)),
            self.Font.render(str(self.controls[3]), True, (0, 0, 0))
        ]

        self.leftArrow = self.Font.render('<', True, (0, 0, 0))
        self.rightArrow = self.Font.render('>', True, (0, 0, 0))

        self.playerInput = False
        self.textinput = pygame_textinput.TextInput(
            font_family="Lucida Console", font_size=56, initial_string="Name")

        self.controlInput = False
        self.controlSelect = False
        self.controlPointer = 0
        self.controlsDatabase = self.Database.get_controls()
Ejemplo n.º 3
0
    def __init__(self):
        super().__init__()
        Database = DatabaseHandler.Database()
        self.scores = Database.read_scores()
        self.scoreRender = []
        self.Font = pygame.font.SysFont("Lucida Console", 56)
        self.TitleFont = pygame.font.SysFont("Lucida Console", 56)

        self.TItle = self.TitleFont.render('Leaderboard', True, (0, 0, 0))

        if not len(self.scores) == 0:
            amount = 5 if len(self.scores) > 5 else len(self.scores)

            for i in range(0, amount):
                self.scoreRender.append(
                    self.Font.render(
                        str(i + 1) + ': ' + str(self.scores[i][0]) + ', ' +
                        str(self.scores[i][1]), True, (0, 0, 0)))
        else:
            self.scoreRender.append(
                self.Font.render('No Scores To Display', True, (0, 0, 0)))
Ejemplo n.º 4
0
    def __init__(self, parent, *args, **kwargs):
        """
        Input: self - The object containing the frame being called, parent - the parent window of this frame
        Output: None
        Purpose: Creates the main window
        """
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.database = Database.Database(r".\Brewing.db")
        parent.title("BrewingDB")

        #handles making the recipe selection
        self.lb_selection = tk.Listbox(self, selectmode = "single")
        self.__refreshList()
        self.lb_selection.grid(row = 1, column = 0, sticky = "NESW")
        self.lb_selection.bind('<<ListboxSelect>>', self.__changeRecipe)

        #handles creation of recipe display box
        self.txt_recipe = tk.Text(self, height = 20, width = 50, wrap = tk.WORD)
        self.txt_recipe.grid(row = 1, column = 1,sticky = "NESW")
        self.txt_recipe.config(state="disabled")
        
        #configures the display box to be resizable
        self.rowconfigure(1, weight = 1)
        self.columnconfigure(1, weight = 1)

        #creates a frame for holding the options button
        self.fr_options_bar = tk.Frame(self)
        self.fr_options_bar.grid(row = 0, column =0, columnspan = 2, sticky = "NESW")
        #Creates a copy button
        self.btn_copy = ttk.Button(master=self.fr_options_bar, text="Copy", command = self.__copy)
        self.btn_copy.pack(side = "left")
        #Creates an edit button
        self.btn_edit = ttk.Button(master=self.fr_options_bar, text="Edit", command = self.__edit)
        self.btn_edit.pack(side = "left")
        #Creates a delete button
        self.btn_delete = ttk.Button(master=self.fr_options_bar, text="Delete", command = self.__delete)
        self.btn_delete.pack(side = "left")
Ejemplo n.º 5
0
    def save(self):
        """
        Input: self - The object containing the frame being called
        Returns: Nothing
        Purpose: Reads the data from all of the entry feilds and updates the respective lsits before calling setorUpdateRecipe() to insert the new information into the database.
        """
        for key in ["start", "end", "abv", "OG", "FG", "volume"]:
            self.recipe[key] = self.entrys[key].get()
        self.recipe["instructions"] = self.txt_instructions.get("1.0", tk.END)

        for index, ingredient in enumerate(self.ingredientList):
            if not ingredient:
                self.ingredientList.pop(index)
                self.IngredientFrameList.pop(index)
                continue
            if ingredient["state"] == "add" or ingredient["state"] == "current":
                for key in ["unit", "amount"]:
                    ingredient[key] = self.IngredientFrameList[index][key].get(
                    )

        self.database.setorUpdateRecipe(self.recipe, self.ingredientList)

        pass


if __name__ == "__main__":
    root = tk.Tk()
    root.title("ParentWindow")
    test = editWindow(root, 1, database.Database(r".\Brewing.db"))
    root.mainloop()
Ejemplo n.º 6
0
"""
This script calls the database handler to make a new copy of the example recipe 

"""
import DatabaseHandler as database

if __name__ == '__main__':
    db = database.Database(r".\Brewing.db")
    ingredients = [{"name":"DAP", "category":"yeast nutrient", "amount":"4", "unit":"g", "additionTime":"", "state":"add"},\
                   {"name":"Yeast Hulls", "category":"yeast nutrient", "amount":"4", "unit":"g", "additionTime":"", "state":"add"},\
                   {"name":"EC-118", "category":"yeast", "amount":"1", "unit":"pack", "additionTime":"", "state":"add"},\
                   {"name":"Organic cane sugar", "category":"sugar", "amount":"500","additionTime":"", "unit":"g","state":"add"},\
                   {"name":"Lime", "category":"fruit","amount":"1","unit":"g","additionTime":"","state":"add"}]
    recipe = {
        "name":
        "Ginger Beer",
        "version":
        -1,
        "start":
        "2021-04-28",
        "end":
        "2021-05-21",
        "abv":
        "5.0",
        "volume":
        "1",
        "instructions":
        "Bring the water to a boil, wrap the grains in cheesecloth and place them in the boiling water to steep for 15 minutes. After steeping add lime juice and allow the mixture to cool to ~20C. Transfer to your fermentation vessel of choice and pitch the yeast"
    }
    db.setorUpdateRecipe(recipe, ingredients)