DEV Community

dhakshinesh
dhakshinesh

Posted on β€’ Edited on

4 2

Tkinter, Creating Forms

NOTE

If you are coming here for the first time or have no idea about tkinter, checkout the Getting Started dev-post

In this tutorial we will be creating a simple signup form which contains some text field, Checkbox, and a submit button.

Entry Widget

The entry widget is used for creating input fields.
Syntax :

#text field : username
Label(root, text="Username").grid(row = 0,column = 0)
Entry(root).grid(row = 0,column = 1)
#text field : password
Label(root, text="Password").grid(row = 1,column = 0)
Entry(root).grid(row = 1,column = 1)
Enter fullscreen mode Exit fullscreen mode

Here, I'm using grid placement which allows us to place all items in a tabular manner.

CheckButton Widget

Using this widget, we can create a simple checkbox which we can toggle on or off.

Syntax:

#Checkbox field
Checkbutton(root,text="Remember?").grid(row=2, column=1)
Enter fullscreen mode Exit fullscreen mode

The text variable basically replaces the Label widget's role and also acts as a checkbox whenever you click on the text which makes your application more accessible.

Button Widget

As you already know, the Button widget is basically a button ;)

#Submit button
Button(root, text = 'Submit').grid(row=3, column=0)
Enter fullscreen mode Exit fullscreen mode

That's it. You can make it more beautiful by making the form centered and then adding some colors to it too.

I've made a GitHub repository too. (feel free to make some PR's) :
Tkinter-Creating-Forms

Top comments (0)

Image of Docusign

πŸ› οΈ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more