Beispiel #1
0
    def __init__(self, *args, **kwargs):

        super().__init__(*args, **kwargs)
        self.cont1 = Frame(self)
        self.cont2 = Frame(self)
        self.ingredient_autocompletes = db.get_all_ingredient_names()
        self.recipe_autocompletes = db.get_all_recipe_names()

        for label in ("name", "amount", "unit"):
            la = Label(self.cont2)
            la.configure(text=label)
            la.pack(side=LEFT, fill=BOTH, expand=YES)
        self.cont2.pack(side=TOP, fill=BOTH, expand=YES)

        self.name_entry = Entry(self.cont1)
        self.name_entry.pack(side=LEFT)
        self.name_entry.bind("<KeyRelease>", self.te_function)
        self.name_entry.bind("<Tab>", self.te_tab_down)
        self.name_entry.bind("<Up>", self.te_arrow)
        self.name_entry.bind("<Down>", self.te_arrow)
        # override behaviour where tab selects the next widget
        # returning "break" stops the event from propagating

        self.amount_entry = Entry(self.cont1)
        self.amount_entry.pack(side=LEFT)

        self.unit_entry = Entry(self.cont1)
        self.unit_entry.pack(side=LEFT)

        self.unit_entry.bind("<Return>", self.master.master.add_entry)
        # NOTE: "<Enter>" means when the mouse enters the widget
        self.unit_entry.bind("<Tab>", self.unit_tab_down)

        self.cont1.pack(side=TOP)

        self.checkbox_var = IntVar()
        self.speculative_container = Frame(self)
        self.spec_label = Label(self.speculative_container, text="Speculative")
        self.spec_label.pack(side=LEFT)
        self.spec_checkbox = Checkbutton(self.speculative_container,
                                         variable=self.checkbox_var)
        self.spec_checkbox.pack(side=LEFT)
        self.speculative_container.pack(side=TOP)

        self.content = ""
        self.unit = None
        self.vessel = None

        self.lb = Listbox(self, exportselection=0)
        self.lb.pack(side=TOP, fill=BOTH, expand=YES, pady=10)
        for word in self.ingredient_autocompletes:
            self.lb.insert(0, word)
        self.lb.selection_set(0)

        self.recipe_box = Listbox(self, exportselection=0)
        self.recipe_box.pack(side=TOP, fill=BOTH, expand=YES)
        for word in db.get_all_recipe_names():
            self.recipe_box.insert(0, word)
        self.recipe_box.selection_set(0)
Beispiel #2
0
 def rpc_get_recipe_names(self):
     return str(db.get_all_recipe_names())
Beispiel #3
0
 def rpc_get_recipe_names(self):
     names = db.get_all_recipe_names()
     return names
Beispiel #4
0
    def refresh_autocompletes(self):

        self.ingredient_autocompletes = db.get_all_ingredient_names()
        self.recipe_autocompletes = db.get_all_recipe_names()