예제 #1
0
 def __init__(self):
     self.menu_controller = MenuController()
     self.category_controller = CategoryController()
     self.product_controller = ProductController()
     self.substitute_controller = SubstituteController()
     self.message_controller = MessageController()
     self.run()
    def __init__(self):
        self.user = MenuController.log_in()
        if self.user is None:
            sys.exit()

        if isinstance(self.user, Client):
            self.menu_controller = ClientController(self.user)
        elif isinstance(self.user, Mechanic):
            self.menu_controller = MechanicController(self.user)
        else:
            raise Exception('What!!!')
예제 #3
0
from utils.dbus_services import (DeepinMovieServie, check_multiple_instances,
                                 DeepinMovieInterface, session_bus, DBUS_PATH)

if __name__ == "__main__":
    result = check_multiple_instances()
    if result:
        dbus_service = DeepinMovieServie(app)
        session_bus.registerObject(DBUS_PATH, dbus_service)
    else:
        if not config.playerMultipleProgramsAllowed:
            dbus_interface = DeepinMovieInterface()
            dbus_interface.play(json.dumps(sys.argv[1:]))
            os._exit(0)

    windowView = Window(result or len(sys.argv) > 1)
    menu_controller = MenuController()
    file_monitor = FileMonitor()
    findVideoThreadManager = FindVideoThreadManager()
    subtitleParser = Parser()
    settings = DMSettings()
    app._extra_window = weakref.ref(windowView)

    qml_context = windowView.rootContext()

    qml_context.setContextProperty("config", config)
    qml_context.setContextProperty("_settings", settings)
    qml_context.setContextProperty("_utils", utils)
    qml_context.setContextProperty("_findVideoThreadManager",
                                   findVideoThreadManager)
    qml_context.setContextProperty("_file_monitor", file_monitor)
    qml_context.setContextProperty("_database", database)
예제 #4
0
파일: main.py 프로젝트: MaukWM/GameJam2019
import pygame
try:
    from tkinter.simpledialog import askstring
    import tkinter
except Exception:
    pass

from controllers.menu_controller import MenuController
from constants import SCREEN_WIDTH, SCREEN_HEIGHT


if __name__ == "__main__":
    name = ""
    try:
        root = tkinter.Tk()
        name = askstring("Name", "What's your name?")
        root.withdraw()
    except Exception:
        name = "I have no tkinter"

    pygame.init()
    window = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32)
    pygame.font.init()

    menu_controller = MenuController(name)
    menu_controller.run()

예제 #5
0
class OpenFoodFacts:
    """

    The OpenFoodFacts object initializes and runs the application.

    Attributes:
        menu_controller (menu_controller.MenuController):
            The menu controller.
        category_controller (category_controller.CategoryController):
            The category controller.
        product_controller (product_controller.ProductController):
            The product controller.
        substitute_controller (substitute_controller.SubstituteController):
            The substitute controller.
        message_controller(message_controller)
            The message controller.
    """
    def __init__(self):
        self.menu_controller = MenuController()
        self.category_controller = CategoryController()
        self.product_controller = ProductController()
        self.substitute_controller = SubstituteController()
        self.message_controller = MessageController()
        self.run()

    def replace_product(self):
        '''

        Replace a product by a substitute.

        This method processes the replacement of a product by a substitute.
        The user chooses a category, a product from the selected catagory
        and a substitute for this product. A save menu is then displayed and
        the user can choose to save the substitute. Finally, the substitute is
        saved if the user has choosen to do so.
        If there is no product or substitute selected, this method ends.
        '''
        category = self.category_controller.select_category()
        product = self.product_controller.select_product(category)
        if product:
            substitute = self.product_controller.select_substitute(
                product, category)
            if substitute:
                self.substitute_controller.display_substitute(
                    product, substitute, category)
                option = self.menu_controller.select_save_option()
                if option != 0:
                    self.substitute_controller.set_substitute(
                        product, substitute)

    def display_substitutes(self):
        '''Displays all the subtitutes and their substitued products.'''
        self.substitute_controller.display_substitutes()

    def reset_database(self):
        '''

        Resets the database.

        This method displays a database reset message, resets the tables of
        the database and adds the categories and products to the database.
        '''
        database = Database()
        self.message_controller.display_database_reset_message()
        database.reset_tables()
        self.category_controller.set_categories()
        categories = self.category_controller.get_categories()
        products = self.product_controller.get_products(categories)
        self.product_controller.set_products(products)

    def run(self):
        '''

        Runs the application.

        This method processes the main menu.
        The user can choose to replace a product by a substitute, display all
        the substitutes and their substitued products, reset the database and
        exit the application.
        '''
        option = -1
        while option != 0:
            option = self.menu_controller.select_main_option()
            if option == 1:
                self.replace_product()
            elif option == 2:
                self.display_substitutes()
            elif option == 9:
                self.reset_database()