Skip to main content

form for tkinter

Project description

tkinter_form

tk_form is a simple module that helps you to create forms in tkinter easily and quickly from a base dictionary, saving certain repetitive tasks in the creation of a form and adding the verification of integer and float variables. In simple words it is similar to having a tkinter variable. Its value is a dictionary.

Install

pip install tkinter_form

Tutorial

Fast Example

import tkinter as tk

from tkinter_form import Form



class App(tk.Tk):

    def __init__(self) -> None:

        super().__init__()

        estruct = {

            "high": 1.0,

            "width": 1.0,

            "round": False,

            "type of calculation": ["calculate area", "calculate perimeter"],

            "result": "",

        }

        self.form = Form(

            self,

            name_form="calculations of a rectangle",

            form_dict=estruct,

            name_config="calculate",

            button=True

        )

        self.form.pack()

        self.button = self.form.button



        self.button.config(command=self.calculate)

        self.mainloop()

    def calculate(self):

        """

        Calculate values rectangle

        """

        dict_vals = self.form.get()

        if dict_vals["type of calculation"] == "calculate area":

            value = dict_vals["high"] * dict_vals["width"]

        elif dict_vals["type of calculation"] == "calculate perimeter":

            value = 2 * dict_vals["high"] + 2 * dict_vals["width"]

        else:

            value = 0

        if dict_vals["round"]:

            value = round(value)

        result = {"result": str(value)}

        self.form.set(result)

if __name__ == "__main__":

    App()

With these lines we create the interface that performs the calculations of area and perimeter of a rectangle. This frees us the declaration of the labels and other objects returning a ttk.LabelFrame with the additional methods set(), get() and the attributes widgets and button.

example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkinter_form-0.1.4.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

tkinter_form-0.1.4.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file tkinter_form-0.1.4.1.tar.gz.

File metadata

  • Download URL: tkinter_form-0.1.4.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for tkinter_form-0.1.4.1.tar.gz
Algorithm Hash digest
SHA256 d2232ef4dadb4b5cb4a24304ba7447e108f7a17e896e570d5658f2e53282d326
MD5 c92ad9b780480a111d75f3a5eb7f1c8d
BLAKE2b-256 dbc8fe2a3673402cfef50df6ee723de4d4463a273324644f7a2a99669cc474ef

See more details on using hashes here.

File details

Details for the file tkinter_form-0.1.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tkinter_form-0.1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a61d0252570554cd0ffdda8267f15fe9d1b433cc93411ec6db0d73f33f8e0ae3
MD5 a2c8ab6a205c3cf4b486008231d19057
BLAKE2b-256 9be0e880fcc60c4d596e9c49e871df546dbedd8f8093b8c3ef69efb126795834

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page