DEV Community


Posted on • Updated on

Tkinter, Creating Forms


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.


#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) :

Top comments (0)