class importScreen(UIObject):
    def __init__(self, master):
        super().__init__(master, controller=None)
        self.lbl_filepath = TextAndEntryfield(self.frame, "Filepath", width_num=20)
        self.lbl_group = TextAndEntryfield(self.frame, "Group", width_num=20)
        self.lbl_gender = TextAndEntryfield(self.frame, "Gender", width_num=20)
        self.lbl_db_name = TextAndEntryfield(self.frame, "Database Table", width_num=20)
        self.btn_import = ttk.Button(self.frame, text="Import", command=self.import_names)

        self.lbl_filepath.frame.grid(column=0, row=0)
        self.lbl_group.frame.grid(column=0, row=1)
        self.lbl_gender.frame.grid(column=0, row=2)
        self.lbl_db_name.frame.grid(column=0, row=3)
        self.btn_import.grid(column=0, row=4)

    def import_names(self):
        names = self.read_file(self.lbl_filepath.get())
        db = dbManager()
        db.databases[self.lbl_db_name.get()].add_all(names, group=self.lbl_group.get(), gender=self.lbl_gender.get())

    @staticmethod
    def read_file(filepath):
        f = open(filepath, 'r')
        array = []
        for line in f:
            row = line.strip()
            array.append(row)
        f.close()
        return array
    def __init__(self, master):
        super().__init__(master, controller=None)
        self.lbl_filepath = TextAndEntryfield(self.frame, "Filepath", width_num=20)
        self.lbl_group = TextAndEntryfield(self.frame, "Group", width_num=20)
        self.lbl_gender = TextAndEntryfield(self.frame, "Gender", width_num=20)
        self.lbl_db_name = TextAndEntryfield(self.frame, "Database Table", width_num=20)
        self.btn_import = ttk.Button(self.frame, text="Import", command=self.import_names)

        self.lbl_filepath.frame.grid(column=0, row=0)
        self.lbl_group.frame.grid(column=0, row=1)
        self.lbl_gender.frame.grid(column=0, row=2)
        self.lbl_db_name.frame.grid(column=0, row=3)
        self.btn_import.grid(column=0, row=4)