mirror of
https://github.com/Sosokker/Packaged-Food-Explorer.git
synced 2025-12-19 05:04:06 +01:00
27 lines
727 B
Python
27 lines
727 B
Python
# controller.py
|
|
|
|
import tkinter as tk
|
|
from model import FoodSearch
|
|
from view import AppView
|
|
|
|
class AppController:
|
|
def __init__(self, master):
|
|
self.master = master
|
|
self.food_search = FoodSearch('food_data.db')
|
|
self.view = AppView(master, self)
|
|
|
|
def search(self, query):
|
|
results = self.food_search.search(query)
|
|
self.view.update_results(results)
|
|
|
|
def clear_results(self):
|
|
self.view.clear_results()
|
|
|
|
def on_item_selected(self, event):
|
|
widget = event.widget
|
|
selection = widget.curselection()
|
|
if selection:
|
|
index = selection[0]
|
|
value = widget.get(index)
|
|
self.view.show_image(value)
|