<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: dhakshinesh</title>
    <description>The latest articles on Forem by dhakshinesh (@dhakshinesh).</description>
    <link>https://forem.com/dhakshinesh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F514534%2Fd20b85e9-e0db-460a-9a67-41f81ec1d97d.jpg</url>
      <title>Forem: dhakshinesh</title>
      <link>https://forem.com/dhakshinesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dhakshinesh"/>
    <language>en</language>
    <item>
      <title>Tkinter, Creating Forms</title>
      <dc:creator>dhakshinesh</dc:creator>
      <pubDate>Tue, 18 Jan 2022 15:26:47 +0000</pubDate>
      <link>https://forem.com/dhakshinesh/tkinter-creating-forms-2ghp</link>
      <guid>https://forem.com/dhakshinesh/tkinter-creating-forms-2ghp</guid>
      <description>&lt;h2&gt;
  
  
  NOTE
&lt;/h2&gt;

&lt;p&gt;If you are coming here for the first time or have no idea about tkinter, checkout the Getting Started &lt;a href="https://dev.to/dhakshinesh/creating-your-first-application-on-python-using-tkinter-131g"&gt;dev-post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial we will be creating a simple signup form which contains some text field, Checkbox, and a submit button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Entry Widget
&lt;/h2&gt;

&lt;p&gt;The entry widget is used for creating input fields.&lt;br&gt;
Syntax :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#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)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, I'm using grid placement which allows us to place all items in a tabular manner.&lt;/p&gt;

&lt;h2&gt;
  
  
  CheckButton Widget
&lt;/h2&gt;

&lt;p&gt;Using this widget, we can create a simple checkbox which we can toggle on or off.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Checkbox field
Checkbutton(root,text="Remember?").grid(row=2, column=1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Button Widget
&lt;/h2&gt;

&lt;p&gt;As you already know, the Button widget is basically a button ;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Submit button
Button(root, text = 'Submit').grid(row=3, column=0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. You can make it more beautiful by making the form centered and then adding some colors to it too.&lt;/p&gt;

&lt;p&gt;I've made a GitHub repository too. (feel free to make some PR's) :&lt;br&gt;
&lt;a href="https://github.com/dhakshinesh/Tkinter-Creating-Forms"&gt;Tkinter-Creating-Forms&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tkinter</category>
      <category>python</category>
      <category>tutorial</category>
      <category>forms</category>
    </item>
    <item>
      <title>Creating Your First Application On Python Using Tkinter</title>
      <dc:creator>dhakshinesh</dc:creator>
      <pubDate>Thu, 23 Dec 2021 12:23:09 +0000</pubDate>
      <link>https://forem.com/dhakshinesh/creating-your-first-application-on-python-using-tkinter-131g</link>
      <guid>https://forem.com/dhakshinesh/creating-your-first-application-on-python-using-tkinter-131g</guid>
      <description>&lt;h2&gt;
  
  
  What is Tkinter
&lt;/h2&gt;

&lt;p&gt;For those who don't know what tkinter is, It is basically a python module for making GUI(Graphical User Interface), in which we can do all the beautiful things on the frontend and hide your messy backend code😅..&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;First off to get started, we need to Install Tkinter using pip&lt;br&gt;
On your terminal type,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install tk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: You will need the latest version of python(3.9.0) or higher.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now to the fun stuff 👾👾..
&lt;/h3&gt;

&lt;p&gt;After installing tkinter, you are ready to make your first python application. &lt;br&gt;
On your text-editor, create a python file(.py) and then you'll be needing the following code to set up tkinter on your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#importing the tkinter module
from tkinter import *
import tkinter

#assigning a "root" as the main window for our application
root = tkinter.Tk()

root.mainloop()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you run the following code, you can see a window as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rARZCG6v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpn2kq5xpmpvtnilxz6a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rARZCG6v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpn2kq5xpmpvtnilxz6a.png" alt="Tkinter Application window" width="246" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the place all of our widgets which are the elements are going to be shown.&lt;/p&gt;

&lt;p&gt;Before we go ahead, We need to make a fixed size for our application.&lt;br&gt;
Just after assigning the root = tkinter.Tk() add,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root.geometry('500x500')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is better than making a "Hello World!" program?
&lt;/h3&gt;

&lt;p&gt;Now we're going to a widget by tkinter which lets us make some cool text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Just a basic text.
Label(root, text="Hello World!").pack()

#Just a basic text but bigger.
Label(root, text="Hello World!", font=20).pack()

#A bold text with a different font
Label(root, text="Hello World!", font=('Jokerman',25,'bold')).pack()

#A text with red background
Label(root, text="Hello World!",bg='red', font=10 ).pack()

#A text with red color
Label(root, text="Hello World!",fg='red', font=10 ).pack()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the complete code of the program that we just made,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#importing the tkinter module
from tkinter import *
import tkinter

root = tkinter.Tk()
root.geometry('500x500')
#Main
#Just a basic text.
Label(root, text="Hello World!").pack()
#Just a basic text but bigger.
Label(root, text="Hello World!", font=20).pack()
#A bold text with a different font
Label(root, text="Hello World!", font=('Jokerman',25,'bold')).pack()
#A text with red background
Label(root, text="Hello World!",bg='red', font=10 ).pack()
#A text with red color
Label(root, text="Hello World!",fg='red', font=10 ).pack()
root.mainloop()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the output of the following code,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NuqAtM_V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmbat77n7jrfvqoi96op.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NuqAtM_V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmbat77n7jrfvqoi96op.png" alt="Hello World!" width="353" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Congrats🎉🎉 you've successfully made your first python application!
&lt;/h3&gt;

&lt;p&gt;That's it for this tutorial on making your first application, If you want to see more widgets by tkinter you can check &lt;a href="https://www.dummies.com/article/technology/programming-web-design/python/using-tkinter-widgets-in-python-141443"&gt;this link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And by the way this is my first dev-post, I would really like to see what you think about it.😄&lt;/p&gt;

</description>
      <category>firstyearincode</category>
      <category>python</category>
      <category>tutorial</category>
      <category>tkinter</category>
    </item>
  </channel>
</rss>
