

{"id":15231,"date":"2018-05-18T07:18:45","date_gmt":"2018-05-18T01:48:45","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=15231"},"modified":"2026-04-24T16:18:36","modified_gmt":"2026-04-24T10:48:36","slug":"python-gui-programming","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/","title":{"rendered":"What is Python GUI Programming &#8211; Python Tkinter Tutorial"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In this <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-tutorial-for-beginners\/\">Python<\/a><\/strong> tutorial, we will discuss different interfaces that we can use to develop a Python GUI (graphical user interface). Also, we will see many options for Python GUI Programming; of these, we will focus on Python Tkinter. Moreover, in this Python Tkinter tutorial for Python 3, we will discuss Tkinter with its 19 kinds of widgets. Along with this, we are going to learn the Tkinter download process.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">So, l<\/span><span style=\"font-weight: 400\">et\u2019s begin Python GUI Tkinter.<\/span><\/p>\n<div id=\"attachment_16329\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16329\" class=\"wp-image-16329 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg\" alt=\"Python GUI Programming with Tkinter\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-16329\" class=\"wp-caption-text\">Python GUI Programming with Python\u00a0 Tkinter<\/p><\/div>\n<h3><span style=\"font-weight: 400\">Alternatives For Python GUI Programming<\/span><\/h3>\n<p><span style=\"font-weight: 400\">The following are options for Python GUI Programming. We may use one of the following alternatives for programming a Python GUI:<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-lambda-expressions\/\">Python Lambda Expressions with Syntax and Examples<\/a><\/strong><\/p>\n<div id=\"attachment_16326\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16326\" class=\"wp-image-16326 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming.png\" alt=\"Python GUI Programming with Tkinter\" width=\"500\" height=\"500\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming.png 500w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming-150x150.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming-300x300.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Options-For-Python-GUI-Programming-100x100.png 100w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-16326\" class=\"wp-caption-text\">Options For Python GUI Programming<\/p><\/div>\n<h4><span style=\"font-weight: 400\">a. Python Tkinter<\/span><\/h4>\n<p><span style=\"font-weight: 400\">Python ships with the Tk GUI toolkit. Tkinter is an interface to this.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">b. Python PyQt<\/span><\/h4>\n<p><span style=\"font-weight: 400\">A Python binding of the cross-platform GUI toolkit Qt, PyQt, is implemented as a plug-in for Python.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">c. <\/span><span style=\"font-weight: 400\">Python\u00a0<\/span><span style=\"font-weight: 400\">wxPython<\/span><\/h4>\n<p><span style=\"font-weight: 400\">wxWidgets is a cross-platform GUI API for Python; wxPython is a wrapper for this.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">What is Python Tkinter?<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Tkinter in Python GUI Programming is a standard Python GUI library. It gives us an object-oriented interface to the Tk GUI toolkit.<\/span><\/p>\n<p><span style=\"font-weight: 400\">So, let&#8217;s start Python graphics, let\u2019s create a simple GUI application:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Import the module Tkinter.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Create the main window for the application.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Add a widget or more.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Enter the main event loop to deal with an event when it is triggered.<\/span><\/li>\n<\/ul>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/reasons-why-should-i-learn-python\/\">7 Reasons Why Should You Learn Python in 2018<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import tkinter\r\n&gt;&gt;&gt; top=tkinter.Tk()\r\n&gt;&gt;&gt; top.mainloop()<\/pre>\n<p><span style=\"font-weight: 400\">Now, this creates the following window:<\/span><\/p>\n<div id=\"attachment_15251\" style=\"width: 312px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/one.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15251\" class=\"wp-image-15251 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/one.png\" alt=\"Python GUI Tkinter- Creating Simple GUI Application\" width=\"302\" height=\"347\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/one.png 302w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/one-131x150.png 131w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/one-261x300.png 261w\" sizes=\"auto, (max-width: 302px) 100vw, 302px\" \/><\/a><p id=\"caption-attachment-15251\" class=\"wp-caption-text\">Python GUI Tkinter- Creating Simple GUI Application<\/p><\/div>\n<h3><span style=\"font-weight: 400\">Python Tkinter Widgets<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Tkinter in Python GUI Programming provides 19 kinds of widgets (controls)- buttons, labels, and more. Let&#8217;s discuss these Python Tkinter widgets in detail.<\/span><\/p>\n<h4><strong>1. Button in Python Tkinter<\/strong><\/h4>\n<p>You can add a button to your application.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; top.geometry('600x200'\r\n''\r\n&gt;&gt;&gt; def helloCallBack():\r\nmsg=messagebox.showinfo(\"Hello, User\",\"Hello, Guest\")\r\n&gt;&gt;&gt; B=Button(top,text=\"Initiate\",command=helloCallBack)\r\n&gt;&gt;&gt; B.place(x=300,y=100)<\/pre>\n<div id=\"attachment_15252\" style=\"width: 912px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15252\" class=\"wp-image-15252 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two.png\" alt=\"Python GUI Tkinter- Adding Button to application\" width=\"902\" height=\"347\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two.png 902w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two-150x58.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two-300x115.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/two-768x295.png 768w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/a><p id=\"caption-attachment-15252\" class=\"wp-caption-text\">Python GUI Tkinter- Adding Button to application<\/p><\/div>\n<p><span style=\"font-weight: 400\">Now, Clicking on the Initiate button gives us this:<\/span><\/p>\n<div id=\"attachment_15253\" style=\"width: 244px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/three.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15253\" class=\"wp-image-15253 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/three.png\" alt=\"Python GUI Tkinter\" width=\"234\" height=\"226\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/three.png 234w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/three-150x145.png 150w\" sizes=\"auto, (max-width: 234px) 100vw, 234px\" \/><\/a><p id=\"caption-attachment-15253\" class=\"wp-caption-text\">Python GUI Tkinter<\/p><\/div>\n<h4><strong>2. Canvas in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">A Canvas in Tkinter Python GUI Programming will let you draw shapes- lines, polygons, ovals, and more.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-functions\/\">Explore Python Functions with Syntax and Examples<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; from tkinter import messagebox\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; C=Canvas(top,bg=\"cyan\",height=100,width=100)\r\n&gt;&gt;&gt; coord=10,50,90,70\r\n&gt;&gt;&gt; arc=C.create_arc(coord,start=0,extent=97,fill='black')\r\n&gt;&gt;&gt; line=C.create_line(10,10,50,70,fill='white')\r\n&gt;&gt;&gt; C.pack()<\/pre>\n<div id=\"attachment_15254\" style=\"width: 191px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/four.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15254\" class=\"wp-image-15254 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/four.png\" alt=\"Python GUI Tkinter- Canvas\" width=\"181\" height=\"203\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/four.png 181w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/four-134x150.png 134w\" sizes=\"auto, (max-width: 181px) 100vw, 181px\" \/><\/a><p id=\"caption-attachment-15254\" class=\"wp-caption-text\">Python GUI Tkinter- Canvas<\/p><\/div>\n<h4><strong>3. Checkbutton in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">A Checkbutton is an option that a user\u00a0can choose to select or leave. They can select as many checkboxes at once as they want to.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-features\/\">Explore 13 Unique Features of Python Programming Language<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; CheckVar1=IntVar()\r\n&gt;&gt;&gt; CheckVar2=IntVar()\r\n&gt;&gt;&gt; C1=Checkbutton\r\n&gt;&gt;&gt; C1=Checkbutton(top,text=\"Pizza\",variable=CheckVar1,onvalue=1,offvalue=0,height=5,width=20)\r\n&gt;&gt;&gt; C2=Checkbutton(top,text=\"Fries\",variable=CheckVar2,onvalue=1,offvalue=0,height=5,width=20)\r\n&gt;&gt;&gt; C1.pack()\r\n&gt;&gt;&gt; C2.pack()<\/pre>\n<div id=\"attachment_15255\" style=\"width: 264px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/five.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15255\" class=\"wp-image-15255 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/five.png\" alt=\"Python GUI Tkinter\" width=\"254\" height=\"302\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/five.png 254w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/five-126x150.png 126w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/five-252x300.png 252w\" sizes=\"auto, (max-width: 254px) 100vw, 254px\" \/><\/a><p id=\"caption-attachment-15255\" class=\"wp-caption-text\">Python GUI Tkinter- Checkbutton<\/p><\/div>\n<h4><strong>4. Entry in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Next, this lets us add a single-line input tray for taking input from the user.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; L1=Label(top,text=\"Enrolment Number\")\r\n&gt;&gt;&gt; L1.pack(side=LEFT)\r\n&gt;&gt;&gt; E1=Entry(top,bd=3)\r\n&gt;&gt;&gt; E1.pack(side=RIGHT)<\/pre>\n<div id=\"attachment_15257\" style=\"width: 364px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/six-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15257\" class=\"wp-image-15257 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/six-1.png\" alt=\"Python GUI Tkinter- Entry\" width=\"354\" height=\"82\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/six-1.png 354w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/six-1-150x35.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/six-1-300x69.png 300w\" sizes=\"auto, (max-width: 354px) 100vw, 354px\" \/><\/a><p id=\"caption-attachment-15257\" class=\"wp-caption-text\">Python GUI Tkinter- Entry<\/p><\/div>\n<h4><strong>5. Frame in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Generally, a frame is a container widget to help hold other widgets.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; frame=Frame(top)\r\n&gt;&gt;&gt; frame.pack()\r\n&gt;&gt;&gt; frametwo=Frame(top)\r\n&gt;&gt;&gt; frametwo.pack(side=BOTTOM)\r\n&gt;&gt;&gt; redbutton=Button(frame,text=\"One\",fg=\"red\")\r\n&gt;&gt;&gt; redbutton.pack(side=LEFT)\r\n&gt;&gt;&gt; bluebutton=Button(frame,text=\"Two\",fg=\"blue\")\r\n&gt;&gt;&gt; bluebutton.pack(side=LEFT)\r\n&gt;&gt;&gt; greenbutton=Button(frametwo,text=\"Three\",fg=\"green\")\r\n&gt;&gt;&gt; greenbutton.pack(side=BOTTOM)<\/pre>\n<div id=\"attachment_15258\" style=\"width: 191px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seven.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15258\" class=\"wp-image-15258 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seven.png\" alt=\"Python GUI Tkinter- Frame\" width=\"181\" height=\"127\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seven.png 181w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seven-150x105.png 150w\" sizes=\"auto, (max-width: 181px) 100vw, 181px\" \/><\/a><p id=\"caption-attachment-15258\" class=\"wp-caption-text\">Python GUI Tkinter- Frame<\/p><\/div>\n<h4><strong>6. Label in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Basically, this lets us add a single-line caption for other widgets. We saw this in section 4d.<\/span><\/p>\n<h4><strong>7. Listbox in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This widget lets us add a list of options for the user to choose from.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; LB1=Listbox(top)\r\n&gt;&gt;&gt; LB1.insert(1,\"Hindi\")\r\n&gt;&gt;&gt; LB1.insert(2,\"Romanian\")\r\n&gt;&gt;&gt; LB1.insert(3,\"English\")\r\n&gt;&gt;&gt; LB1.insert(4,\"Gujarati\")\r\n&gt;&gt;&gt; LB1.pack()<\/pre>\n<div id=\"attachment_15259\" style=\"width: 198px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eight.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15259\" class=\"wp-image-15259 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eight.png\" alt=\"Python GUI Tkinter\" width=\"188\" height=\"293\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eight.png 188w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eight-96x150.png 96w\" sizes=\"auto, (max-width: 188px) 100vw, 188px\" \/><\/a><p id=\"caption-attachment-15259\" class=\"wp-caption-text\">Python GUI Tkinter- Listbox<\/p><\/div>\n<h4><strong>8. Menu button in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This lets us add a menu button anywhere in our application.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-number-types-conversion\/\">Python Number Types and Their Conversion Functions<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; mb=Menubutton(top,text=\"style\",relief=RAISED)\r\n&gt;&gt;&gt; mb.grid()\r\n&gt;&gt;&gt; mb.menu=Menu(mb,tearoff=0)\r\n&gt;&gt;&gt; mb[\"menu\"]=mb.menu\r\n&gt;&gt;&gt; balayageVar=IntVar()\r\n&gt;&gt;&gt; sombreVar=IntVar()\r\n&gt;&gt;&gt; mb.menu.add_checkbutton(label='Balayage',variable=balayageVar)\r\n&gt;&gt;&gt; mb.menu.add_checkbutton(label='Sombre',variable=sombreVar)\r\n&gt;&gt;&gt; mb.pack()<\/pre>\n<div id=\"attachment_15260\" style=\"width: 193px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nine.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15260\" class=\"wp-image-15260 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nine.png\" alt=\"Python GUI Tkinter- Add a Menu Button\" width=\"183\" height=\"86\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nine.png 183w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nine-150x70.png 150w\" sizes=\"auto, (max-width: 183px) 100vw, 183px\" \/><\/a><p id=\"caption-attachment-15260\" class=\"wp-caption-text\">Python GUI Tkinter- Add a Menu Button<\/p><\/div>\n<p><span style=\"font-weight: 400\">Clicking on this button does this:<\/span><\/p>\n<div id=\"attachment_15261\" style=\"width: 210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ten.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15261\" class=\"wp-image-15261 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ten.png\" alt=\"An output of Adding a Menu Button\" width=\"200\" height=\"151\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ten.png 200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ten-150x113.png 150w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><p id=\"caption-attachment-15261\" class=\"wp-caption-text\">An output of Adding a Menu Button<\/p><\/div>\n<h4><strong>9. Menu in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This lets us put all kinds of menus in our application.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; def donothing():\r\nfilewin=Toplevel(top)\r\nbutton=Button(filewin,text=\"This does nothing\")\r\nbutton.pack()\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; menubar=Menu(top)\r\n&gt;&gt;&gt; filemenu=Menu(menubar,tearoff=0)\r\n&gt;&gt;&gt; filemenu.add_command(label=\"New\",command=donothing)\r\n&gt;&gt;&gt; filemenu.add_command(label=\"Open\",command=donothing)\r\n&gt;&gt;&gt; filemenu.add_command(label=\"Save\",command=donothing)\r\n&gt;&gt;&gt; filemenu.add_command(label=\"Close\",command=donothing)\r\n&gt;&gt;&gt; filemenu.add_separator()\r\n&gt;&gt;&gt; filemenu.add_command(label=\"Exit\",command=top.quit)\r\n&gt;&gt;&gt; menubar.add_cascade(label=\"File\",menu=filemenu)\r\n&gt;&gt;&gt; editmenu=Menu(menubar,tearoff=0)\r\n&gt;&gt;&gt; editmenu.add_command(label=\"Undo\",command=donothing)\r\n&gt;&gt;&gt; editmenu.add_separator()\r\n&gt;&gt;&gt; editmenu.add_command(label=\"Cut\",command=donothing)\r\n&gt;&gt;&gt; editmenu.add_command(label=\"Copy\",command=donothing)\r\n&gt;&gt;&gt; editmenu.add_command(label=\"Paste\",command=donothing\r\n&gt;&gt;&gt; editmenu.add_command(label=\"Delete\",command=donothing)\r\n&gt;&gt;&gt; menubar.add_cascade(label=\"Edit\",menu=editmenu)\r\n&gt;&gt;&gt; top.config(menu=menubar)\r\n&gt;&gt;&gt; top.mainloop()<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eleven-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"301\" height=\"377\" class=\"wp-image-15293 size-full aligncenter\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eleven-1.png\" alt=\"&quot;&gt;&gt; from tkinter import * &gt;&gt;&gt; top=Tk() &gt;&gt;&gt; var=StringVar() &gt;&gt;&gt; label=Message(top,textvariable=var,relief=RAISED) &gt;&gt;&gt; var.set(\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eleven-1.png 301w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eleven-1-120x150.png 120w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eleven-1-240x300.png 240w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><\/a><\/p>\n<div id=\"attachment_15290\" style=\"width: 192px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fourteen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15290\" class=\"wp-image-15290 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fourteen-1.png\" alt=\"Python GUI Tkinter\" width=\"182\" height=\"126\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fourteen-1.png 182w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fourteen-1-150x104.png 150w\" sizes=\"auto, (max-width: 182px) 100vw, 182px\" \/><\/a><p id=\"caption-attachment-15290\" class=\"wp-caption-text\">Python GUI Tkinter- Message<\/p><\/div>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/loops-in-python\/\"><strong>Read\u00a0Loops in Python with Syntax and Examples<\/strong><\/a><\/p>\n<h4><strong>10. Radiobutton in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">When a user has a few choices of radio buttons, they may only choose one at once.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; def sel():\r\nselection=f\"Enjoy your {var.get()}\"\r\nlabel.config(text=selection)\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; var=StringVar()\r\n&gt;&gt;&gt; R1=Radiobutton(top,text=\"pizza slice\",variable=var,value='pizza',command=sel\r\n&gt;&gt;&gt; R1.pack(anchor=W)\r\n&gt;&gt;&gt; R2=Radiobutton(top,text=\"burger\",variable=var,value='burger',command=sel)\r\n&gt;&gt;&gt; R2.pack(anchor=W)\r\n&gt;&gt;&gt; R3=Radiobutton(top,text=\"fries\",variable=var,value='fries',command=sel)\r\n&gt;&gt;&gt; R3.pack(anchor=W)\r\n&gt;&gt;&gt; label=Label(top)\r\n&gt;&gt;&gt; label.pack()<\/pre>\n<div id=\"attachment_15289\" style=\"width: 192px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fifteen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15289\" class=\"wp-image-15289 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fifteen-1.png\" alt=\"Python GUI Tkinter\" width=\"182\" height=\"191\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fifteen-1.png 182w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/fifteen-1-143x150.png 143w\" sizes=\"auto, (max-width: 182px) 100vw, 182px\" \/><\/a><p id=\"caption-attachment-15289\" class=\"wp-caption-text\">Python GUI Programming with Tkinter- Radiobutton<\/p><\/div>\n<h4><strong>11. Scale in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">The scale widget provides a slider.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; def sel():\r\nselection=f\"Volume: {str(var.get())}\"\r\nlabel.config(text=selection)\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; var=DoubleVar()\r\n&gt;&gt;&gt; scale=Scale(top,variable=var)\r\n&gt;&gt;&gt; scale.pack(anchor=CENTER)\r\n&gt;&gt;&gt; button=Button(top,text=\"Get scale value\",command=sel)\r\n&gt;&gt;&gt; button.pack(anchor=CENTER)\r\n&gt;&gt;&gt; label=Label(top)\r\n&gt;&gt;&gt; label.pack()<\/pre>\n<div id=\"attachment_15286\" style=\"width: 192px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/sixteen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15286\" class=\"wp-image-15286 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/sixteen-1.png\" alt=\"Python GUI Tkinter\" width=\"182\" height=\"276\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/sixteen-1.png 182w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/sixteen-1-99x150.png 99w\" sizes=\"auto, (max-width: 182px) 100vw, 182px\" \/><\/a><p id=\"caption-attachment-15286\" class=\"wp-caption-text\">Python GUI Tkinter Programming- Scale<\/p><\/div>\n<h4><strong>12. Scrollbar in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This adds scrolling capability to other widgets like lists.<\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-decision-making-expressions\/\">Have a Look At Python Decision Making Statements with Syntax\u00a0<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; scrollbar=Scrollbar(top)\r\n&gt;&gt;&gt; scrollbar.pack(side=RIGHT,fill=X)\r\n&gt;&gt;&gt; scrollbar.pack(side=RIGHT,fill=Y)\r\n&gt;&gt;&gt; list=Listbox(top,yscrollcommand=scrollbar.set)\r\n&gt;&gt;&gt; for line in range(22):\r\nlist.insert(END,f\"Line {str(line)}\")\r\n&gt;&gt;&gt; list.pack(side=LEFT,fill=BOTH)\r\n&gt;&gt;&gt; scrollbar.config(command=list.yview)<\/pre>\n<div id=\"attachment_15284\" style=\"width: 225px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seventeen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15284\" class=\"wp-image-15284 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seventeen-1.png\" alt=\"Python GUI Tkinter\" width=\"215\" height=\"295\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seventeen-1.png 215w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/seventeen-1-109x150.png 109w\" sizes=\"auto, (max-width: 215px) 100vw, 215px\" \/><\/a><p id=\"caption-attachment-15284\" class=\"wp-caption-text\">Python 3 GUI Tkinter- Scrollbar<\/p><\/div>\n<h4><strong>13. Text in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This displays text in multiple lines.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; text=Text(top)\r\n&gt;&gt;&gt; text.insert(INSERT,\"One.\")\r\n&gt;&gt;&gt; text.insert(END,\"Two..Three...\")\r\n&gt;&gt;&gt; text.pack()\r\n&gt;&gt;&gt; text.tag_add(\"first\",\"1.0\",\"1.4\")\r\n&gt;&gt;&gt; text.tag_add(\"second\",\"1.10\",\"1.14\")\r\n&gt;&gt;&gt; text.tag_config(\"first\",background=\"cyan\",foreground=\"black\")\r\n&gt;&gt;&gt; text.tag_config(\"second\",background=\"black\",foreground=\"white\")<\/pre>\n<div id=\"attachment_15283\" style=\"width: 978px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15283\" class=\"wp-image-15283 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1.png\" alt=\"Python GUI Tkinter\" width=\"968\" height=\"627\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1.png 968w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1-150x97.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1-300x194.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eighteen-1-768x497.png 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><\/a><p id=\"caption-attachment-15283\" class=\"wp-caption-text\">Python GUI Tkinter- Text<\/p><\/div>\n<h4><strong>14. Toplevel in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This provides a separate window container.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; main=Tk()\r\n&gt;&gt;&gt; main.title(\"My Piano\")\r\n''\r\n&gt;&gt;&gt; new=Toplevel()\r\n&gt;&gt;&gt; new.title(\"New Song\")\r\n''<\/pre>\n<div id=\"attachment_15281\" style=\"width: 377px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nineteen-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15281\" class=\"wp-image-15281 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nineteen-1.png\" alt=\"Python GUI Tkinter\" width=\"367\" height=\"417\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nineteen-1.png 367w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nineteen-1-132x150.png 132w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/nineteen-1-264x300.png 264w\" sizes=\"auto, (max-width: 367px) 100vw, 367px\" \/><\/a><p id=\"caption-attachment-15281\" class=\"wp-caption-text\">Tkinter Tutorial Python 3- Toplevel<\/p><\/div>\n<h4><strong>15. Spinbox in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Basically, Spinbox is like an entry field, except it lets us select from a fixed number of values.<\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-variables-and-data-types\/\">Python Variables and Data Types with Syntax and Examples<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; s=Spinbox(top,from_=0,to=18)\r\n&gt;&gt;&gt; s.pack()<\/pre>\n<div id=\"attachment_15277\" style=\"width: 214px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-one.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15277\" class=\"wp-image-15277 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-one.png\" alt=\"Python GUI Tkinter\" width=\"204\" height=\"77\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-one.png 204w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-one-150x57.png 150w\" sizes=\"auto, (max-width: 204px) 100vw, 204px\" \/><\/a><p id=\"caption-attachment-15277\" class=\"wp-caption-text\">Spinbox<\/p><\/div>\n<div id=\"attachment_15279\" style=\"width: 216px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15279\" class=\"wp-image-15279 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-1.png\" alt=\"Python GUI Tkinter\" width=\"206\" height=\"77\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-1.png 206w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-1-150x56.png 150w\" sizes=\"auto, (max-width: 206px) 100vw, 206px\" \/><\/a><p id=\"caption-attachment-15279\" class=\"wp-caption-text\">Tkinter Widgets in Python GUI Programming<\/p><\/div>\n<h4><strong>16. PanedWindow in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This is a container widget that can hold any number of panes horizontally or vertically.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; w1=PanedWindow()\r\n&gt;&gt;&gt; w1.pack(fill=BOTH, expand=1)\r\n&gt;&gt;&gt; left=Entry(w1,bd=5)\r\n&gt;&gt;&gt; w1.add(left)\r\n&gt;&gt;&gt; w2=PanedWindow(w1,orient=VERTICAL)\r\n&gt;&gt;&gt; w1.add(w2)\r\n&gt;&gt;&gt; top=Scale(w2,orient=HORIZONTAL)\r\n&gt;&gt;&gt; w2.add(top)\r\n&gt;&gt;&gt; bottom=Button(w2,text=\"OK\")\r\n&gt;&gt;&gt; w2.add(bottom)<\/pre>\n<div id=\"attachment_15275\" style=\"width: 463px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-two.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15275\" class=\"wp-image-15275 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-two.png\" alt=\"Python GUI Tkinter- PanedWindow\" width=\"453\" height=\"164\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-two.png 453w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-two-150x54.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-two-300x109.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/a><p id=\"caption-attachment-15275\" class=\"wp-caption-text\">Python GUI Tkinter- PanedWindow<\/p><\/div>\n<h4><strong>17. LabelFrame in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">So, this is a container widget holding complex window layouts.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; labelframe=LabelFrame(top,text=\"Lyrics\")\r\n&gt;&gt;&gt; labelframe.pack(fill=\"both\",expand=\"yes\")\r\n&gt;&gt;&gt; left=Label(labelframe,text=\"No lyrics available\")\r\n&gt;&gt;&gt; left.pack()<\/pre>\n<div id=\"attachment_15274\" style=\"width: 287px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-three.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15274\" class=\"wp-image-15274 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-three.png\" alt=\"Python GUI Tkinter- LabelFrame\" width=\"277\" height=\"106\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-three.png 277w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-three-150x57.png 150w\" sizes=\"auto, (max-width: 277px) 100vw, 277px\" \/><\/a><p id=\"caption-attachment-15274\" class=\"wp-caption-text\">Python GUI Tkinter- LabelFrame<\/p><\/div>\n<h4><strong>18. tkMessageBox in Python Tkinter<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This widget displays a message box.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from tkinter import *\r\n&gt;&gt;&gt; from tkinter import messagebox\r\n&gt;&gt;&gt; top=Tk()\r\n&gt;&gt;&gt; def clickhere():\r\nmessagebox.showinfo(\"Click here\",\"You just got owned\")\r\n&gt;&gt;&gt; button=Button(top,text=\"Click here\",command=clickhere)\r\n&gt;&gt;&gt; button.place(x=50,y=77)<\/pre>\n<div id=\"attachment_15273\" style=\"width: 312px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-four.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15273\" class=\"wp-image-15273 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-four.png\" alt=\"Python GUI Tkinter\" width=\"302\" height=\"346\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-four.png 302w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-four-131x150.png 131w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-four-262x300.png 262w\" sizes=\"auto, (max-width: 302px) 100vw, 302px\" \/><\/a><p id=\"caption-attachment-15273\" class=\"wp-caption-text\">tkMessageBox in Tkinter<\/p><\/div>\n<div id=\"attachment_15272\" style=\"width: 392px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-five.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15272\" class=\"wp-image-15272 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-five.png\" alt=\"Python GUI Programming with Tkinter\" width=\"382\" height=\"467\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-five.png 382w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-five-123x150.png 123w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/twenty-five-245x300.png 245w\" sizes=\"auto, (max-width: 382px) 100vw, 382px\" \/><\/a><p id=\"caption-attachment-15272\" class=\"wp-caption-text\">Python GUI Programming with Tkinter<\/p><\/div>\n<p>So, this was all about Python GUI Programming. Hope you like our explanation of the Tkinter Tutorial in Python 3.<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/data-structures-in-python-lists-tuples-sets-dictionaries\/\">Data Structures in Python \u2013 Lists, Tuples, Sets, Dictionaries<\/a><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">Conclusion<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Hence, we completed the Python Tkinter tutorial. Now, it is time to get started with Python GUI programming. In addition, we saw Python GUI Programming and an alternative to Python GUI Programming. Moreover, we discussed Tkinter and widgets. At last, we learned about the different kinds of widgets that Tinker provides. Furthermore, for any query regarding Python GUI Programming with Tkinter, feel free to ask in the comment section.<\/span><br \/>\n<strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Tkinter\">For reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1943,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Tkinter&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;new&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this Python tutorial, we will discuss different interfaces that we can use to develop a Python GUI (graphical user interface). Also, we will see many options for Python GUI Programming; of these, we&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":16329,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[10178,10571,10572,10896,10897,10898,14747,14749,14750,14751,16031],"class_list":["post-15231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-programming-a-python-gui","tag-python-gui-library","tag-python-gui-programming","tag-python-tkinter-download","tag-python-tkinter-example","tag-python-tkinter-tutorial","tag-tkinter","tag-tkinter-tutorial-for-python","tag-tkinter-tutorial-for-python-3","tag-tkinter-tutorial-python","tag-what-is-tkinter"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is Python GUI Programming - Python Tkinter Tutorial - DataFlair<\/title>\n<meta name=\"description\" content=\"Python Tkinter Tutorial, Python GUI programming: wxPython, PyQt,Tkinter Widgets, types of widgets in Python Tkinter, Python GUI Tkinter with example\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-gui-programming\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Python GUI Programming - Python Tkinter Tutorial - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python Tkinter Tutorial, Python GUI programming: wxPython, PyQt,Tkinter Widgets, types of widgets in Python Tkinter, Python GUI Tkinter with example\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-gui-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-18T01:48:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T10:48:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Python GUI Programming - Python Tkinter Tutorial - DataFlair","description":"Python Tkinter Tutorial, Python GUI programming: wxPython, PyQt,Tkinter Widgets, types of widgets in Python Tkinter, Python GUI Tkinter with example","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/","og_locale":"en_US","og_type":"article","og_title":"What is Python GUI Programming - Python Tkinter Tutorial - DataFlair","og_description":"Python Tkinter Tutorial, Python GUI programming: wxPython, PyQt,Tkinter Widgets, types of widgets in Python Tkinter, Python GUI Tkinter with example","og_url":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-18T01:48:45+00:00","article_modified_time":"2026-04-24T10:48:36+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"What is Python GUI Programming &#8211; Python Tkinter Tutorial","datePublished":"2018-05-18T01:48:45+00:00","dateModified":"2026-04-24T10:48:36+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/"},"wordCount":1021,"commentCount":5,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg","keywords":["programming a Python GUI","Python GUI library","Python GUI programming","python tkinter download","Python Tkinter example","Python tkinter tutorial","Tkinter","Tkinter tutorial for Python","Tkinter tutorial for Python 3","tkinter tutorial python","What is Tkinter"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-gui-programming\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/","url":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/","name":"What is Python GUI Programming - Python Tkinter Tutorial - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg","datePublished":"2018-05-18T01:48:45+00:00","dateModified":"2026-04-24T10:48:36+00:00","description":"Python Tkinter Tutorial, Python GUI programming: wxPython, PyQt,Tkinter Widgets, types of widgets in Python Tkinter, Python GUI Tkinter with example","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-gui-programming\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-GUI-Programming-with-Tkinter-01.jpg","width":1200,"height":628,"caption":"Python GUI Programming with Tkinter"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-gui-programming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"What is Python GUI Programming &#8211; Python Tkinter Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=15231"}],"version-history":[{"count":8,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15231\/revisions"}],"predecessor-version":[{"id":147853,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15231\/revisions\/147853"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/16329"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=15231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=15231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=15231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}