{"id":56,"date":"2020-11-18T04:20:55","date_gmt":"2020-11-18T04:20:55","guid":{"rendered":"http:\/\/www.programminginpython.com\/2023\/03\/30\/how-to-create-a-temperature-converter-app-in-python-gui-using-tkinter\/"},"modified":"2023-05-14T14:28:23","modified_gmt":"2023-05-14T14:28:23","slug":"create-temperature-converter-app-python-gui-using-tkinter","status":"publish","type":"post","link":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/","title":{"rendered":"How to create a temperature converter app in python GUI using TKInter"},"content":{"rendered":"<p>Hello everyone! Welcome back to programminginpython.com. Here in this post, I will show you how to create a simple temperature converter app in Python GUI using TKInter. This app basically converts a <code>Celcius<\/code>\u00a0unit to <code>Fahrenheit<\/code>\u00a0and <code>Kelvin<\/code>units and\u00a0similarly\u00a0<code>Fahrenheit<\/code> to the other two units and similar with\u00a0<code>Kelvin<\/code>which returns the other two units.<\/p>\n<h4 class=\"post_h4\">Video Series of the app:<\/h4>\n<div class=\"yrc-shell-cover yrc-single\" data-yrc-uid=\"69e15bbde077d\" data-yrc-channel=\"{&quot;meta&quot;:{&quot;user&quot;:&quot;Programming In Python&quot;,&quot;channel&quot;:&quot;UCLBlXUMLYLxopRljNdLXOeQ&quot;,&quot;key&quot;:&quot;yrc_1683138754&quot;,&quot;apikey&quot;:&quot;AIzaSyC3vU6rFyzsO0shrRsAWmjuSiuWYTQhafc&quot;,&quot;cache&quot;:&quot;1440&quot;,&quot;channel_uploads&quot;:&quot;UULBlXUMLYLxopRljNdLXOeQ&quot;,&quot;onlyonce&quot;:&quot;&quot;,&quot;tag&quot;:&quot;&quot;,&quot;per_page&quot;:&quot;24&quot;,&quot;maxv&quot;:&quot;0&quot;,&quot;consent&quot;:{&quot;ask&quot;:&quot;&quot;,&quot;url&quot;:&quot;&quot;},&quot;ads&quot;:&quot;1&quot;,&quot;uid&quot;:&quot;69e15bbde077d&quot;,&quot;nocookie&quot;:&quot;&quot;,&quot;single&quot;:true},&quot;style&quot;:{&quot;colors&quot;:{&quot;item&quot;:{&quot;background&quot;:&quot;inherit&quot;},&quot;button&quot;:{&quot;background&quot;:&quot;#333&quot;,&quot;color&quot;:&quot;#fff&quot;},&quot;color&quot;:{&quot;text&quot;:&quot;#fff&quot;,&quot;link&quot;:&quot;inherit&quot;,&quot;menu&quot;:&quot;#000&quot;,&quot;meta&quot;:&quot;inherit&quot;}},&quot;theme&quot;:{&quot;videos&quot;:{&quot;style&quot;:&quot;__grid&quot;,&quot;thumb&quot;:[&quot;large&quot;,&quot;open&quot;],&quot;desc&quot;:&quot;&quot;,&quot;carousel&quot;:{&quot;thumbs&quot;:&quot;4&quot;,&quot;thumbs_to_slide&quot;:&quot;2&quot;,&quot;spacing&quot;:&quot;10&quot;},&quot;carousel_nav&quot;:{&quot;modifier&quot;:&quot;__sides&quot;,&quot;position&quot;:&quot;left-none&quot;,&quot;location&quot;:&quot;prepend&quot;,&quot;background&quot;:&quot;#fff&quot;,&quot;color&quot;:&quot;#000&quot;,&quot;font_size&quot;:&quot;2&quot;,&quot;border_radius&quot;:&quot;0&quot;}},&quot;a&quot;:&quot;1&quot;},&quot;fit&quot;:&quot;false&quot;,&quot;playlists&quot;:&quot;true&quot;,&quot;uploads&quot;:&quot;true&quot;,&quot;player_mode&quot;:&quot;1&quot;,&quot;truncate&quot;:&quot;&quot;,&quot;banner&quot;:&quot;true&quot;,&quot;thumb_margin&quot;:&quot;8&quot;,&quot;play_icon&quot;:&quot;hover&quot;,&quot;youtube_play_icon&quot;:&quot;&quot;,&quot;thumb_image_size&quot;:&quot;medium&quot;,&quot;default_tab&quot;:&quot;uploads&quot;,&quot;sticky&quot;:{&quot;enable&quot;:&quot;&quot;,&quot;width&quot;:&quot;400&quot;,&quot;position&quot;:&quot;bottom-right&quot;,&quot;only_above&quot;:&quot;768&quot;,&quot;margin&quot;:&quot;12&quot;},&quot;player&quot;:{&quot;show_desc&quot;:&quot;&quot;,&quot;show_meta&quot;:&quot;&quot;},&quot;menu&quot;:&quot;1&quot;,&quot;rating_style&quot;:&quot;NaN&quot;,&quot;rtl&quot;:false}}\" data-yrc-setup=\"\"><\/div>\r\n\t\t\t<script data-cfasync=\"false\" type=\"text\/javascript\">\r\n\t\t\t\tif( !window.YRC ) var YRC = {Data:{}};\r\n\t\t\t\tYRC.Data[\"69e15bbde077d\"] = {\"video\":\"\"};\r\n\t\t\t\t(function(){\r\n\t\t\t\t\tif(!YRC.loaded){\r\n\t\t\t\t\t    YRC.loaded = true;\r\n\t\t\t\t\t\tfunction YRC_Loader(){\r\n\t\t\t\t\t\t\t\/\/YRC.loaded = true;\r\n\t\t\t\t\t\t\tYRC.is_pro = false;\r\n\t\t\t\t\t\t\tYRC.is_pb = false;\r\n\t\t\t\t\t\t\tYRC.lang = {\"form\":{\"Videos\":\"Videos\",\"Playlists\":\"Playlists\",\"Search\":\"Search\",\"Loading\":\"Loading\",\"more\":\"more\",\"Nothing_found\":\"Nothing found\",\"Prev\":\"Previous\",\"Next\":\"Next\",\"consent_statement\":\"Allow cookies?\",\"consent_button\":\"Allow\",\"consent_privacy_policy\":\"Privacy policy\"},\"fui\":{\"sort_by\":\"Sort by\",\"relevant\":\"Relevant\",\"latest\":\"Latest\",\"liked\":\"Liked\",\"title\":\"Title\",\"views\":\"Views\",\"duration\":\"Duration\",\"any\":\"Any\",\"_short\":\"Short\",\"medium\":\"Medium\",\"_long\":\"Long\",\"uploaded\":\"Uploaded\",\"all_time\":\"All time\",\"live_now\":\"Live Now\",\"today\":\"Today\",\"ago\":\"ago\",\"last\":\"Last\",\"day\":\"day\",\"days\":\"days\",\"week\":\"week\",\"weeks\":\"weeks\",\"month\":\"month\",\"months\":\"months\",\"year\":\"year\",\"years\":\"years\",\"older\":\"Older\",\"show_more\":\"Show More\",\"show_less\":\"Show Less\",\"reply\":\"REPLY\",\"view_replies\":\"View replies\",\"write_comment\":\"Write comment...\",\"billion\":\"B\",\"million\":\"M\",\"thousand\":\"K\",\"max_plain_number\":1000,\"wplocale\":\"en_US\"}};\r\n\t\t\t\t\t\t\tYRC.is_admin = false;\r\n\t\t\t\t\t\t\tvar script = document.createElement(\"script\");\r\n\t\t\t\t\t\t\t\tscript.setAttribute(\"data-cfasync\", \"false\");\r\n\t\t\t\t\t\t\t\tscript.setAttribute(\"type\", \"text\/javascript\");\r\n\t\t\t\t\t\t\t\tscript.src = \"https:\/\/www.programminginpython.com\/wp-content\/plugins\/yourchannel\/js\/yrc.js?1.2.9\";\r\n\t\t\t\t\t\t\t\tscript.id = \"yrc-script\";\r\n\t\t\t\t\t\t\t\tdocument.querySelector(\"head\").appendChild(script);\r\n\t\t\t\t\t\t\tvar style = document.createElement(\"link\");\r\n\t\t\t\t\t\t\t\tstyle.rel = \"stylesheet\";\r\n\t\t\t\t\t\t\t\tstyle.href = \"https:\/\/www.programminginpython.com\/wp-content\/plugins\/yourchannel\/css\/style.css?1.2.9\";\r\n\t\t\t\t\t\t\t\tstyle.type = \"text\/css\";\r\n\t\t\t\t\t\t\t\tdocument.querySelector(\"head\").appendChild(style);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(window.jQuery){YRC_Loader();}else { var yrctimer2324 = window.setInterval(function(){\r\n\t\t\t\t\t\t\tif(window.jQuery){YRC_Loader(); window.clearInterval(yrctimer2324); }\r\n\t\t\t\t\t\t}, 250);}\r\n\t\t\t\t\t} else {if(YRC.EM)YRC.EM.trigger(\"yrc.newchannel\");}\r\n\t\t\t\t}());<\/script>\n<p style=\"text-align: center;\"><strong>You can also watch the video on YouTube <a href=\"https:\/\/www.youtube.com\/watch?v=66szFLXzUs4&amp;list=PLrKr3rQwMgsheweyIykLLrMD7ttZTAyFS\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/strong><\/p>\n<h4 class=\"post_h4\">TKInter GUI Design<\/h4>\n<p>Here I used some widgets like <code>Label<\/code>, <code>Button<\/code>, <code>EntryField<\/code> (Input field), and <code>OptionsMenu<\/code>(dropdown).<\/p>\n<p>These widgets are used as follows.<\/p>\n<ul>\n<li>An <code>EntryField<\/code> where one can enter any value and<\/li>\n<li>\u00a0 <code>OptionMenu<\/code> to select the unit of the entered value.<\/li>\n<li>A <code>Button<\/code> when pressed, calls the function to calculate the other two temperature units.<\/li>\n<li>Two <code>Labels<\/code> to show the result.<\/li>\n<\/ul>\n<figure id=\"attachment_497\" class=\"wp-caption aligncenter\" style=\"width: 568px;\" aria-describedby=\"caption-attachment-497\"><img decoding=\"async\" class=\"size-full wp-image-497 lazyload\" data-src=\"http:\/\/programminginpython.com\/wp-content\/uploads\/2017\/03\/temp_converter.png\" data-sizes=\"(max-width: 568px) 100vw, 568px\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2017\/03\/temp_converter.png 568w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2017\/03\/temp_converter-300x183.png 300w\" alt=\"Temperature converter app in python GUI - programminginpython.com\" width=\"568\" height=\"347\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 568px; --smush-placeholder-aspect-ratio: 568\/347;\" \/><figcaption id=\"caption-attachment-497\" class=\"wp-caption-text\">Temperature converter app in python GUI \u2013 programminginpython.com<\/figcaption><\/figure>\n<p>First I must import and initialize TKInter to use it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">import tkinter as tk \r\nroot = tk.Tk()<\/pre>\n<p>Then I will initialize a <code>Label<\/code> and an `EntryField` and also set their position using <code>grid<\/code> layout options.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">input_label = tk.Label(root, text=\"Enter temperature\")\r\ninput_entry = tk.Entry(root, textvariable=numberInput)\r\ninput_label.grid(row=0)\r\ninput_entry.grid(row=0, column=1)<\/pre>\n<p>Here I need to set \u2018numberInput\u2019 to a string.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">numberInput = tk.StringVar()<\/code><\/p>\n<p>Next, I will use an <code>OptionMenu<\/code> (a drop-down menu) to display Celsius, Fahrenheit, and Kelvin\u00a0temperatures and also set the dropdown default value to Celsius and set the position of the <code>OptionMenu<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">dropDownList = [\"Celsius\", \"Fahrenheit\", \"Kelvin\"]\r\ndropdown = tk.OptionMenu(root, var, *dropDownList, command=store_temp)\r\nvar.set(dropDownList[0])\r\ndropdown.grid(row=0, column=3)<\/pre>\n<p>I also need to set <code>var<\/code> in the above snippet to a string.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">var = tk.StringVar()<\/code><\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/temperature_converter_GUI.py\" target=\"_blank\" rel=\"noopener\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on Github<\/a><\/span><\/p>\n<h4 class=\"post_h4\">OptionMenu Selected Item<\/h4>\n<p>Here I need to convert the input temperature to two other temperature formats based on the input temperature format whether it is Celsius, Fahrenheit, or Kelvin unit, and store it somewhere so I can use it for conversion.<\/p>\n<p>If you notice in the above snippet I used a <code>command<\/code> parameter\u00a0for the <code>OptionMenu<\/code>, this <code>command<\/code> is nothing but it calls a function, here it calls <code>store_temp<\/code> when an <code>OptionMenu<\/code>(dropdown) value is changed.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def store_temp(sel_temp):\r\n    global tempVal\r\n    tempVal = sel_temp<\/pre>\n<p>So here I stored the value of the selected temperature in <code>tempVal<\/code>\u00a0variable which is declared globally. For declaring a variable globally, I just use a variable with some value\u00a0for it.<\/p>\n<pre class=\"lang:default decode:true \"><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">tempVal = \"Celsius\"<\/code><\/pre>\n<p>So now every time the drop-down is changed, its value is stored in <code>tempVal<\/code>\u00a0and can be accessed anywhere in our app.<\/p>\n<h4 class=\"post_h4\">The temperature Converter<\/h4>\n<p>So when the user inputs some value and selects the temperature from the drop-down, the next thing is to press a button that shows the desired results.<\/p>\n<p>I will initialize a button with a command to call the conversion function.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">result_button = tk.Button(root, text=\"Convert\", command=call_convert)\r\nresult_button.grid(row=0, columnspan=4)<\/pre>\n<p>I will pass 2 labels to show the result and the input value which is entered in the `Entry`. Here I use <code>partial<\/code>\u00a0from <code>functools<\/code>\u00a0to pass parameters to the function <code>call_convert<\/code><\/p>\n<p>So before I call <code>call_convert<\/code>\u00a0I will place the following line.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">call_convert = partial(call_convert, result_label1, result_label2, numberInput)<\/pre>\n<p>and of course, I need to import `partial`.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">from functools import partial<\/code><\/p>\n<p>So the logic resides in this <code>call_convert<\/code> method.<\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/temperature_converter_GUI.py\" target=\"_blank\" rel=\"noopener\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<h4 class=\"post_h4\">The Conversion<\/h4>\n<p>First I will get the entered value, then check the drop-down value and then perform the conversion and return the result to the labels.<\/p>\n<pre class=\"\"><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def call_convert(rlabel1, rlabe12, inputn):<\/code><\/pre>\n<p>The 3 parameters in the above line are the 2 labels to set the result and a value entered in the Entry field.<\/p>\n<p>So First I will get the input value.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">tem = inputn.get()<\/code><\/p>\n<p>Now I will check the dropdown value, as I previously store this value in a global variable <code>tempVal<\/code> So now will check whether it is Celsius, Fahrenheit, or Kelvin and perform the conversions based on this value.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#for Celsius\r\nif tempVal == 'Celsius':\r\n  ...\r\n  ...\r\n#for Fahrenheit\r\nif tempVal == 'Fahrenheit':\r\n  ...\r\n  ...\r\n#for Kelvin\r\nif tempVal == 'Kelvin':\r\n  ...\r\n  ...<\/pre>\n<p>So if the value is <code>Celsius<\/code><\/p>\n<p>I will use some calculations to convert and set those results to the appropriate labels.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">if tempVal == 'Celsius':\r\n    f = float((float(tem) * 9\/5) + 32)\r\n    k = float((float(tem) + 273.15))\r\n    rlabel1.config(text=\"%f Fahrenheit\" % f)\r\n    rlabe12.config(text=\"%f Kelvin\" % k)<\/pre>\n<p>Here the variables <code>f<\/code>and <code>k<\/code>\u00a0store the converted results based on some formulae to convert <code>Celsius<\/code>\u00a0to <code>Fahrenheit<\/code>\u00a0and <code>Kelvin<\/code><\/p>\n<p>Similarly for <code>Fahrenheit<\/code>\u00a0and <code>Kelvin<\/code>,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">if tempVal == 'Fahrenheit':\r\n    c = float((float(tem) - 32) * 5 \/ 9)\r\n    k = c + 273\r\n    rlabel1.config(text=\"%f Celsius\" % c)\r\n    rlabe12.config(text=\"%f Kelvin\" % k)\r\n\r\nif tempVal == 'Kelvin':\r\n    c = float((float(tem) - 273.15))\r\n    f = float((float(tem) - 273.15) * 1.8000 + 32.00)\r\n    rlabel1.config(text=\"%f Celsius\" % c)\r\n    rlabe12.config(text=\"%f Fahrenheit\" % f)<\/pre>\n<p>This converts the input temperature to the other two required temperatures.<\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/temperature_converter_GUI.py\" target=\"_blank\" rel=\"noopener\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<h4 class=\"post_h4\">Finishing Touch<\/h4>\n<p>Here I will show you How can we set the size of the window, set colors, \u00a0background, and foreground colors to widgets, and also to set the window to a fixed size and all.<\/p>\n<ul>\n<li>Set the size of the window\n<ul>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">root.geometry('400x150+100+200')<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set the title of the app\n<ul>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">root.title('Temperature Converter')<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set background and foreground colors\n<ul>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">root.configure(background='#e35237')<\/code><\/li>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">input_label = tk.Label(root, text=\"Enter temperature\", background='#e35237', foreground=\"#FFFFFF\")<\/code><\/li>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">dropdown.config(background='#e35237', foreground=\"#FFFFFF\")<\/code><\/li>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">dropdown[\"menu\"].config(background='#e35237', foreground=\"#FFFFFF\")<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Set the window to a fixed size\n<ul>\n<li><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">root.resizable(width=False, height=False)<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4 class=\"post_h4\">Program<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">__author__ = 'Avinash'\r\n\r\nimport tkinter as tk\r\nfrom functools import partial\r\n\r\n# global variable\r\ntempVal = \"Celsius\"\r\n\r\n\r\n# getting drop down value\r\ndef store_temp(sel_temp):\r\n    global tempVal\r\n    tempVal = sel_temp\r\n\r\n\r\n# the main conversion\r\ndef call_convert(rlabel1, rlabe12, inputn):\r\n    tem = inputn.get()\r\n    if tempVal == 'Celsius':\r\n        f = float((float(tem) * 9 \/ 5) + 32)\r\n        k = float((float(tem) + 273.15))\r\n        rlabel1.config(text=\"%f Fahrenheit\" % f)\r\n        rlabe12.config(text=\"%f Kelvin\" % k)\r\n    if tempVal == 'Fahrenheit':\r\n        c = float((float(tem) - 32) * 5 \/ 9)\r\n        k = c + 273\r\n        rlabel1.config(text=\"%f Celsius\" % c)\r\n        rlabe12.config(text=\"%f Kelvin\" % k)\r\n    if tempVal == 'Kelvin':\r\n        c = float((float(tem) - 273.15))\r\n        f = float((float(tem) - 273.15) * 1.8000 + 32.00)\r\n        rlabel1.config(text=\"%f Celsius\" % c)\r\n        rlabe12.config(text=\"%f Fahrenheit\" % f)\r\n    return\r\n\r\n\r\n# app window configuration and UI\r\nroot = tk.Tk()\r\nroot.geometry('400x150+100+200')\r\nroot.title('Temperature Converter')\r\nroot.configure(background='#09A3BA')\r\nroot.resizable(width=False, height=False)\r\nroot.grid_columnconfigure(1, weight=1)\r\nroot.grid_rowconfigure(0, weight=1)\r\n\r\nnumberInput = tk.StringVar()\r\nvar = tk.StringVar()\r\n\r\n# label and entry field\r\ninput_label = tk.Label(root, text=\"Enter temperature\", background='#09A3BA', foreground=\"#FFFFFF\")\r\ninput_entry = tk.Entry(root, textvariable=numberInput)\r\ninput_label.grid(row=1)\r\ninput_entry.grid(row=1, column=1)\r\n\r\n# result label's for showing the other two temperatures\r\nresult_label1 = tk.Label(root, background='#09A3BA', foreground=\"#FFFFFF\")\r\nresult_label1.grid(row=3, columnspan=4)\r\nresult_label2 = tk.Label(root, background='#09A3BA', foreground=\"#FFFFFF\")\r\nresult_label2.grid(row=4, columnspan=4)\r\n\r\n# drop down initalization and setup\r\ndropDownList = [\"Celsius\", \"Fahrenheit\", \"Kelvin\"]\r\ndropdown = tk.OptionMenu(root, var, *dropDownList, command=store_temp)\r\nvar.set(dropDownList[0])\r\ndropdown.grid(row=1, column=3)\r\ndropdown.config(background='#09A3BA', foreground=\"#FFFFFF\")\r\ndropdown[\"menu\"].config(background='#09A3BA', foreground=\"#FFFFFF\")\r\n\r\n# button click\r\ncall_convert = partial(call_convert, result_label1, result_label2, numberInput)\r\nresult_button = tk.Button(root, text=\"Convert\", command=call_convert, background='#09A3BA', foreground=\"#FFFFFF\")\r\nresult_button.grid(row=2, columnspan=4)\r\n\r\nroot.mainloop()<\/pre>\n<h4 class=\"post_h4\">Program Screenshots<\/h4>\n<figure id=\"attachment_519\" class=\"wp-caption aligncenter\" style=\"width: 498px;\" aria-describedby=\"caption-attachment-519\">\n<p><figure id=\"attachment_463\" aria-describedby=\"caption-attachment-463\" style=\"width: 498px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-463 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python1.png\" alt=\"How to create a temperature converter app in python GUI using TKInter\" width=\"498\" height=\"290\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 498px; --smush-placeholder-aspect-ratio: 498\/290;\" \/><figcaption id=\"caption-attachment-463\" class=\"wp-caption-text\">How to create a temperature converter app in Python GUI using TKInter<\/figcaption><\/figure><figcaption id=\"caption-attachment-519\" class=\"wp-caption-text\"><\/figcaption><\/figure>\n<figure id=\"attachment_520\" class=\"wp-caption aligncenter\" style=\"width: 483px;\" aria-describedby=\"caption-attachment-520\">\n<p><figure id=\"attachment_464\" aria-describedby=\"caption-attachment-464\" style=\"width: 483px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-464 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_11.png\" alt=\"How to create a temperature converter app in python GUI using TKInter\" width=\"483\" height=\"259\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 483px; --smush-placeholder-aspect-ratio: 483\/259;\" \/><figcaption id=\"caption-attachment-464\" class=\"wp-caption-text\">How to create a temperature converter app in Python GUI using TKInter<\/figcaption><\/figure><figcaption id=\"caption-attachment-520\" class=\"wp-caption-text\"><\/figcaption><\/figure>\n<figure id=\"attachment_521\" class=\"wp-caption aligncenter\" style=\"width: 484px;\" aria-describedby=\"caption-attachment-521\">\n<p><figure id=\"attachment_465\" aria-describedby=\"caption-attachment-465\" style=\"width: 484px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-465 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_21.png\" alt=\"How to create a temperature converter app in python GUI using TKInter\" width=\"484\" height=\"273\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 484px; --smush-placeholder-aspect-ratio: 484\/273;\" \/><figcaption id=\"caption-attachment-465\" class=\"wp-caption-text\">How to create a temperature converter app in Python GUI using TKInter<\/figcaption><\/figure><figcaption id=\"caption-attachment-521\" class=\"wp-caption-text\"><\/figcaption><\/figure>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/temperature_converter_GUI.py\" target=\"_blank\" rel=\"noopener\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<p>That is it for this post, also feel free to look at other <a href=\"http:\/\/programminginpython.com\/category\/gui-programs\/\" target=\"_blank\" rel=\"noopener\">GUI programs<\/a> or look at all of the posts <a href=\"http:\/\/programminginpython.com\/posts\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. Stay tuned for my next post, until then keep coding <i class=\"fa fa-desktop\"><\/i><\/p>\n<h4 class=\"post_h4\">Video Series of the app:<\/h4>\n<p style=\"text-align: center;\"> https:\/\/www.youtube.com\/embed?listType=playlist&amp;list=PLrKr3rQwMgsheweyIykLLrMD7ttZTAyFS&amp;layout=gallery&#8221;]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello everyone! Welcome back to programminginpython.com. Here in this post, I will show\u00a0you how to create a simple\u00a0temperature converter app in python GUI using TKInter. This app basically converts a Celcius\u00a0unit to Fahrenheit\u00a0and Kelvinunits and\u00a0similarly\u00a0Fahrenheit\u00a0to &hellip;<\/p>\n","protected":false},"author":1,"featured_media":466,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[157,159,52,158,51,156],"class_list":["post-56","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-gui","tag-celsius","tag-fahrenheit","tag-gui","tag-kelvin","tag-python-gui","tag-temperature-converter"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create a temperature converter app in python GUI using TKInter - Programming In Python<\/title>\n<meta name=\"description\" content=\"How to create a temperature converter app in python GUI using TKInter - Programming In Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a temperature converter app in python GUI using TKInter - Programming In Python\" \/>\n<meta property=\"og:description\" content=\"How to create a temperature converter app in python GUI using TKInter - Programming In Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/\" \/>\n<meta property=\"og:site_name\" content=\"Programming In Python\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/programminginpython\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-18T04:20:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-14T14:28:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"AVINASH NETHALA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@python_pip\" \/>\n<meta name=\"twitter:site\" content=\"@python_pip\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"AVINASH NETHALA\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","description":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","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:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/","og_locale":"en_US","og_type":"article","og_title":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","og_description":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","og_url":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/","og_site_name":"Programming In Python","article_publisher":"https:\/\/www.facebook.com\/programminginpython","article_published_time":"2020-11-18T04:20:55+00:00","article_modified_time":"2023-05-14T14:28:23+00:00","og_image":[{"width":1920,"height":420,"url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","type":"image\/png"}],"author":"AVINASH NETHALA","twitter_card":"summary_large_image","twitter_creator":"@python_pip","twitter_site":"@python_pip","twitter_misc":{"Written by":"AVINASH NETHALA","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#article","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/"},"author":{"name":"AVINASH NETHALA","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c"},"headline":"How to create a temperature converter app in python GUI using TKInter","datePublished":"2020-11-18T04:20:55+00:00","dateModified":"2023-05-14T14:28:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/"},"wordCount":770,"commentCount":0,"publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"image":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","keywords":["celsius","fahrenheit","GUI","kelvin","python GUI","temperature converter"],"articleSection":["Python GUI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/","url":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/","name":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#primaryimage"},"image":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","datePublished":"2020-11-18T04:20:55+00:00","dateModified":"2023-05-14T14:28:23+00:00","description":"How to create a temperature converter app in python GUI using TKInter - Programming In Python","breadcrumb":{"@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#primaryimage","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","width":1920,"height":420,"caption":"How to create a temperature converter app in python GUI using TKInter"},{"@type":"BreadcrumbList","@id":"https:\/\/www.programminginpython.com\/create-temperature-converter-app-python-gui-using-tkinter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.programminginpython.com\/"},{"@type":"ListItem","position":2,"name":"How to create a temperature converter app in python GUI using TKInter"}]},{"@type":"WebSite","@id":"https:\/\/www.programminginpython.com\/#website","url":"https:\/\/www.programminginpython.com\/","name":"Programming In Python","description":"All About Python","publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"alternateName":"pip","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.programminginpython.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.programminginpython.com\/#organization","name":"Programming In Python","alternateName":"PIP","url":"https:\/\/www.programminginpython.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","width":500,"height":500,"caption":"Programming In Python"},"image":{"@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/programminginpython","https:\/\/x.com\/python_pip","https:\/\/www.youtube.com\/programminginpython","https:\/\/github.com\/avinashn\/programminginpython.com"]},{"@type":"Person","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c","name":"AVINASH NETHALA","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","caption":"AVINASH NETHALA"},"sameAs":["https:\/\/www.programminginpython.com\/"],"url":"https:\/\/www.programminginpython.com\/author\/avinash\/"}]}},"jetpack_featured_media_url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/tempature_converter_python_WP1.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":3,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":467,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/56\/revisions\/467"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media\/466"}],"wp:attachment":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}