<commit_before>#! /usr/bin/env python
# -*- python -*-
# -*- coding: utf-8 -*-

import puc


class Main(puc.Frame):
    """Main frame object class."""
    def __init__(self, parent: puc.Frame, controller: puc.Tk):
        puc.Frame.__init__(self, parent)

        self.lblTitle = puc.Label(self, text = puc.messages["program.title"],
                                  style="PUCT.TLabel")

        self.cmbLang = puc.Combobox(self, state="readonly", width=2)
        self.cmbLang.bind("<<ComboboxSelected>>", controller.change_lang)
        self.cmbLang["values"] = puc.langs
        self.cmbLang.set(puc.settings["lang"])

        self.lblLang = puc.Label(self, text = puc.lang["lang"], style="PUCL.TLabel")

        self.btnConvert = puc.Button(
            self,
            text = puc.messages["main.button.convert"],
            command = lambda: controller.show_frame(puc.Converter))

        self.btnUnits = puc.Button(self, text = puc.messages["main.button.units"],
                                   command = lambda: controller.show_frame(puc.Units))

        self.btnSave = puc.Button(self, text = puc.messages["main.button.save"],
                                  command = controller.save_data)

        self.btnSave.state(["disabled"])

        self.btnAbout = puc.Button(
            self,
            text = puc.messages["main.button.about"],
            command = lambda: puc.msgBox.showinfo(
                title = puc.messages["main.button.about"],
                message = puc.messages["program.title"] + "\n\n"
                        + "{:>11}".format(puc.messages["program.version"] +":  ")
                        + puc.__version__
                        + "\n" + "{:>13}".format(puc.messages["program.author"] +":  ")
                        + puc.__author__))

        self.btnClose = puc.Button(self, text = puc.messages["button.close"],
                                   command = controller.close)

        # If no datafaile found, then disable converting button (no data!)
        self.btnConvert.state(["!disabled" if controller.df_exists else "disabled"])

        # Finally show labels and buttons (adds to the grid)
        self.lblTitle.grid(row=0, column=0, columnspan=3, padx=10, pady=10, sticky="nw")
        self.cmbLang.grid(row=0, column=3, padx=20, sticky="se")
        self.lblLang.grid(row=1, column=3, padx=20, sticky="ne")
        self.btnConvert.grid(row=2, column=0, padx=10, pady=15, sticky="we")
        self.btnUnits.grid(row=2, column=1, padx=10, pady=15, sticky="we")
        self.btnSave.grid(row=2, column=3, padx=20, pady=15, sticky="we")
        self.btnAbout.grid(row=3, column=1, padx=10, pady=35, sticky="swe")
        self.btnClose.grid(row=3, column=3, padx=20, pady=35, sticky="se")

        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.columnconfigure(3, weight=1)
        self.columnconfigure(4, weight=1)


    def change_lang(self):
        self.lblTitle.config(text = puc.messages["program.title"])
        self.lblLang.config(text = puc.lang["lang"])
        self.btnConvert.config(text = puc.messages["main.button.convert"])
        self.btnUnits.config(text = puc.messages["main.button.units"])
        self.btnSave.config(text = puc.messages["main.button.save"])
        self.btnAbout.config(text = puc.messages["main.button.about"])
        self.btnClose.config(text = puc.messages["button.close"])<commit_msg>Add doc-comment to the function `change_lang`<commit_after>#! /usr/bin/env python
# -*- python -*-
# -*- coding: utf-8 -*-

import puc


class Main(puc.Frame):
    """Main frame object class."""
    def __init__(self, parent: puc.Frame, controller: puc.Tk):
        puc.Frame.__init__(self, parent)

        self.lblTitle = puc.Label(self, text = puc.messages["program.title"],
                                  style="PUCT.TLabel")

        self.cmbLang = puc.Combobox(self, state="readonly", width=2)
        self.cmbLang.bind("<<ComboboxSelected>>", controller.change_lang)
        self.cmbLang["values"] = puc.langs
        self.cmbLang.set(puc.settings["lang"])

        self.lblLang = puc.Label(self, text = puc.lang["lang"], style="PUCL.TLabel")

        self.btnConvert = puc.Button(
            self,
            text = puc.messages["main.button.convert"],
            command = lambda: controller.show_frame(puc.Converter))

        self.btnUnits = puc.Button(self, text = puc.messages["main.button.units"],
                                   command = lambda: controller.show_frame(puc.Units))

        self.btnSave = puc.Button(self, text = puc.messages["main.button.save"],
                                  command = controller.save_data)

        self.btnSave.state(["disabled"])

        self.btnAbout = puc.Button(
            self,
            text = puc.messages["main.button.about"],
            command = lambda: puc.msgBox.showinfo(
                title = puc.messages["main.button.about"],
                message = puc.messages["program.title"] + "\n\n"
                        + "{:>11}".format(puc.messages["program.version"] +":  ")
                        + puc.__version__
                        + "\n" + "{:>13}".format(puc.messages["program.author"] +":  ")
                        + puc.__author__))

        self.btnClose = puc.Button(self, text = puc.messages["button.close"],
                                   command = controller.close)

        # If no datafaile found, then disable converting button (no data!)
        self.btnConvert.state(["!disabled" if controller.df_exists else "disabled"])

        # Finally show labels and buttons (adds to the grid)
        self.lblTitle.grid(row=0, column=0, columnspan=3, padx=10, pady=10, sticky="nw")
        self.cmbLang.grid(row=0, column=3, padx=20, sticky="se")
        self.lblLang.grid(row=1, column=3, padx=20, sticky="ne")
        self.btnConvert.grid(row=2, column=0, padx=10, pady=15, sticky="we")
        self.btnUnits.grid(row=2, column=1, padx=10, pady=15, sticky="we")
        self.btnSave.grid(row=2, column=3, padx=20, pady=15, sticky="we")
        self.btnAbout.grid(row=3, column=1, padx=10, pady=35, sticky="swe")
        self.btnClose.grid(row=3, column=3, padx=20, pady=35, sticky="se")

        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.columnconfigure(3, weight=1)
        self.columnconfigure(4, weight=1)


    def change_lang(self):
        '''Changes frames language.'''
        self.lblTitle.config(text = puc.messages["program.title"])
        self.lblLang.config(text = puc.lang["lang"])
        self.btnConvert.config(text = puc.messages["main.button.convert"])
        self.btnUnits.config(text = puc.messages["main.button.units"])
        self.btnSave.config(text = puc.messages["main.button.save"])
        self.btnAbout.config(text = puc.messages["main.button.about"])
        self.btnClose.config(text = puc.messages["button.close"])
{'fraction_non_alphanumeric': 0.1558626584983616, 'fraction_numerical': 0.017381393360877618, 'mean_word_length': 2.4028114396509936, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4248575', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2207, 'n_words': 359}