import tkinter

from constants import GPA_MAPPING

# widgets.py - Implements a custom GUI widget 'ModuleWidget'
# TODO: Remove all 'pass' statements and complete the implementation based on class description

class ModuleWidget:
    """A supplier class for displaying a module and returning the GPA value.
    """
    def __init__(self, master, command):
        self.__module = None
        self.__command = command
        self.__gpa = -1

        self.setup_ui(master)
        self.set_module(self.__module)

    def set_module(self, module = None):
        # TODO: When module is provided:
        #       - Update UI to display module information
        #       - Enable option menu
        #       Else
        #       - Clear entry content
        #       - Disable option menu
        #       Finally, update self.__module
        pass

    def get_frame(self):
        return self.__frame

    def get_gpa(self):
        return self.__gpa

    def setup_ui(self, master):
        # Variables
        # TODO: Implement tkinter.StringVar for the widgets in this class

        # Contianer
        self.__frame = tkinter.Frame(master)

        # Module name
        # TODO: Implement tkinter.Entry __ent_name
        
        # Module credit
        # TODO: Implement tkinter.Entry __ent_credit

        # Grade
        # TODO: Implement tkinter.OptionMenu __om_grade

    def on_grade_changed(self, _):
        # TODO: Get GPA based on combo box value
        pass
