

{"id":107430,"date":"2022-02-26T09:00:37","date_gmt":"2022-02-26T03:30:37","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=107430"},"modified":"2026-06-01T12:18:36","modified_gmt":"2026-06-01T06:48:36","slug":"python-qr-code-generator-project","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/","title":{"rendered":"Python QR Code Generator Project with Source Code"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2524,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1F1x9_Erm6y42nWULV8jI5n4L7qs4KpTw\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601064654\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1F1x9_Erm6y42nWULV8jI5n4L7qs4KpTw\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 11:50:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 05:03:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-08 08:59:59&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-08 08:59:59&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Nowadays we all use QR code for multiple purposes like making payments, sharing WiFi, etc. Have you ever wished to generate such QR code on your own? We are here with a project for QR code generator using Python. So, follow us to build this Python project.<\/p>\n<h3>About QR Code Generator Project<\/h3>\n<p>QR Code is a machine-readable matrix barcode that uniquely represents information. With the increase in optical capabilities of smartphones, the use of QR codes started increasing.<\/p>\n<p>In this project, we will build a QR Code generator using Python Modules.<\/p>\n<h3>Generate QR Code in Python<\/h3>\n<p>We will be using Tkinter and Qrcode modules in Python to build this project. We use the Tkinter module to build the GUI to take the following inputs:<\/p>\n<ol>\n<li>text\/URL to convert to QR Code<\/li>\n<li>location to save the QR code with name<\/li>\n<li>size of the QR code.<\/li>\n<\/ol>\n<p>Then we generate the QR code from the above inputs and save in the given location using the qrcode module.<\/p>\n<h3>Download the Source Code for QR Code Generator in Python<\/h3>\n<p>Please download the source code for the QR code generator in Python using the link: <a href=\"https:\/\/drive.google.com\/file\/d\/1F1x9_Erm6y42nWULV8jI5n4L7qs4KpTw\/view?usp=drive_link\"><strong>Python QR Code Generator Project<\/strong><\/a><\/p>\n<h3>Project Prerequisites<\/h3>\n<p>It is suggested that the developer has prior knowledge on Python and the Tkinter module. Also, use the below commands to install the qrcode and tkinter modules.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install tkinter<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install qrcode<\/pre>\n<h3>Steps to build the QR Code Generator in Python<\/h3>\n<p>To build the QR code generator project using Python we need to follow the below steps:<br \/>\n1. Importing the modules<br \/>\n2. Creating the main window<br \/>\n3. Taking the input of the text\/URL, location to store the QR code, name of the QR code and the size of the QR code<br \/>\n4. Writing the function to generate and save the QR Code<\/p>\n<h4>1. Importing the modules<\/h4>\n<p>The first step is to import the qrcode and the tkinter module. We use the messagebox in the tkinter module to show the pop up messages.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import qrcode\r\nfrom tkinter import *\r\nfrom tkinter import messagebox<\/pre>\n<h4>2. Creating the main window<\/h4>\n<p>Next, we create the main window with title, size and color.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Creating the window\r\nwn = Tk()\r\nwn.title('DataFlair QR Code Generator')\r\nwn.geometry('700x700')\r\nwn.config(bg='SteelBlue3')<\/pre>\n<h4>3. Taking the inputs<\/h4>\n<p>Now, we take the inputs from the user to create the QR Code. We take the following inputs:<\/p>\n<p>1. Text\/URL as Entry() named as \u2018text\u2019<\/p>\n<p>2. Location to save the QR Code as Entry() named as \u2018loc\u2019<\/p>\n<p>3. Name of the QR Code image when saved in the device as Entry() named as \u2018name\u2019<\/p>\n<p>4. Size of the QR Code to be generated as Entry() named \u2018size\u2019. In this the user has to give the size in the range 1-40. 1 being the smallest size of 21&#215;21.<\/p>\n<p>Then we create a button when clicked generates the QR Code and saves it by executing the generateCode() function.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Label for the window\r\nheadingFrame = Frame(wn,bg=\"azure\",bd=5)\r\nheadingFrame.place(relx=0.15,rely=0.05,relwidth=0.7,relheight=0.1)\r\nheadingLabel = Label(headingFrame, text=\"Generate QR Code with DataFlair\", bg='azure', font=('Times',20,'bold'))\r\nheadingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)\r\n\r\n#Taking the input of the text or URL to get QR code\r\nFrame1 = Frame(wn,bg=\"SteelBlue3\")\r\nFrame1.place(relx=0.1,rely=0.15,relwidth=0.7,relheight=0.3)\r\n\r\nlabel1 = Label(Frame1,text=\"Enter the text\/URL: \",bg=\"SteelBlue3\",fg='azure',font=('Courier',13,'bold'))\r\nlabel1.place(relx=0.05,rely=0.2, relheight=0.08)\r\n\r\ntext = Entry(Frame1,font=('Century 12'))\r\ntext.place(relx=0.05,rely=0.4, relwidth=1, relheight=0.2)\r\n\r\n#Getting input of the location to save QR Code\r\nFrame2 = Frame(wn,bg=\"SteelBlue3\")\r\nFrame2.place(relx=0.1,rely=0.35,relwidth=0.7,relheight=0.3)\r\n\r\nlabel2 = Label(Frame2,text=\"Enter the location to save the QR Code: \",bg=\"SteelBlue3\",fg='azure',font=('Courier',13,'bold'))\r\nlabel2.place(relx=0.05,rely=0.2, relheight=0.08)\r\n\r\nloc = Entry(Frame2,font=('Century 12'))\r\nloc.place(relx=0.05,rely=0.4, relwidth=1, relheight=0.2)\r\n\r\n#Getting input of the QR Code image name\r\nFrame3 = Frame(wn,bg=\"SteelBlue3\")\r\nFrame3.place(relx=0.1,rely=0.55,relwidth=0.7,relheight=0.3)\r\n\r\nlabel3 = Label(Frame3,text=\"Enter the name of the QR Code: \",bg=\"SteelBlue3\",fg='azure',font=('Courier',13,'bold'))\r\nlabel3.place(relx=0.05,rely=0.2, relheight=0.08)\r\n\r\nname = Entry(Frame3,font=('Century 12'))\r\nname.place(relx=0.05,rely=0.4, relwidth=1, relheight=0.2)\r\n\r\n#Getting the input of the size of the QR Code\r\nFrame4 = Frame(wn,bg=\"SteelBlue3\")\r\nFrame4.place(relx=0.1,rely=0.75,relwidth=0.7,relheight=0.2)\r\n\r\nlabel4 = Label(Frame4,text=\"Enter the size from 1 to 40 with 1 being 21x21: \",bg=\"SteelBlue3\",fg='azure',font=('Courier',13,'bold'))\r\nlabel4.place(relx=0.05,rely=0.2, relheight=0.08)\r\n\r\nsize = Entry(Frame4,font=('Century 12'))\r\nsize.place(relx=0.05,rely=0.4, relwidth=0.5, relheight=0.2)\r\n\r\n#Button to generate and save the QR Code\r\nbutton = Button(wn, text='Generate Code',font=('Courier',15,'normal'),command=generateCode)\r\nbutton.place(relx=0.35,rely=0.9, relwidth=0.25, relheight=0.05)\r\n\r\n#Runs the window till it is closed manually\r\nwn.mainloop()<\/pre>\n<h4>4. Creating the function to generate QR code and save it<\/h4>\n<p>Finally, we create the function to generate the code that runs on clicking the button. In this,<\/p>\n<p>1. First we create the QRCode object with the version\/size that user gave as input in the size() entry<\/p>\n<p>2. Then we add the text that we need to encode by getting from the entry \u2018text\u2019<\/p>\n<p>3. Then we get the QR code and save it in the directory that user gave as input<\/p>\n<p>4. After this, we show the pop up message to confirm the user that the image is saved<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Function to generate the QR code and save it\r\ndef generateCode():\r\n  #Creating a QRCode object of the size specified by the user\r\n  qr = qrcode.QRCode(version = size.get(),\r\n            box_size = 10,\r\n            border = 5)\r\n  qr.add_data(text.get()) #Adding the data to be encoded to the QRCode object\r\n  qr.make(fit = True) #Making the entire QR Code space utilized\r\n  img = qr.make_image() #Generating the QR Code\r\n  fileDirec=loc.get()+'\\\\'+name.get() #Getting the directory where the file has to be save\r\n  img.save(f'{fileDirec}.png') #Saving the QR Code\r\n  #Showing the pop up message on saving the file\r\n  messagebox.showinfo(\"DataFlair QR Code Generator\",\"QR Code is saved successfully!\")<\/pre>\n<h3>Output of the QR Code Generator in Python<\/h3>\n<p>Image of the GUI to take inputs from the user for generating QR Code<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-qr-code-generator-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108002\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-qr-code-generator-output.webp\" alt=\"python qr code generator output\" width=\"872\" height=\"913\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Hurray! We have successfully built the QR Code generator in Python. In this, we learned the basic widgets of the tkinter module and to generate the QR Code using the qrcode module. Hope you enjoyed building this project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nowadays we all use QR code for multiple purposes like making payments, sharing WiFi, etc. Have you ever wished to generate such QR code on your own? We are here with a project for&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":108003,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[26520,21082,26519,26521,26518],"class_list":["post-107430","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-generate-qr-code-using-python","tag-python-project","tag-python-qr-code-generation-project","tag-python-qr-code-generator","tag-qr-code-generation-using-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python QR Code Generator Project with Source Code - DataFlair<\/title>\n<meta name=\"description\" content=\"Develop the QR Code generator project in Python using tkinter module for GUI and qrcode module to generate the QR Code.\" \/>\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-qr-code-generator-project\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python QR Code Generator Project with Source Code - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Develop the QR Code generator project in Python using tkinter module for GUI and qrcode module to generate the QR Code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/\" \/>\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=\"2022-02-26T03:30:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T06:48:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp\" \/>\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\/webp\" \/>\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=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python QR Code Generator Project with Source Code - DataFlair","description":"Develop the QR Code generator project in Python using tkinter module for GUI and qrcode module to generate the QR Code.","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-qr-code-generator-project\/","og_locale":"en_US","og_type":"article","og_title":"Python QR Code Generator Project with Source Code - DataFlair","og_description":"Develop the QR Code generator project in Python using tkinter module for GUI and qrcode module to generate the QR Code.","og_url":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-02-26T03:30:37+00:00","article_modified_time":"2026-06-01T06:48:36+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python QR Code Generator Project with Source Code","datePublished":"2022-02-26T03:30:37+00:00","dateModified":"2026-06-01T06:48:36+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/"},"wordCount":604,"commentCount":15,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp","keywords":["Generate QR Code using Python","Python project","Python QR Code Generation project","Python QR Code Generator","QR Code Generation using Python"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/","url":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/","name":"Python QR Code Generator Project with Source Code - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp","datePublished":"2022-02-26T03:30:37+00:00","dateModified":"2026-06-01T06:48:36+00:00","description":"Develop the QR Code generator project in Python using tkinter module for GUI and qrcode module to generate the QR Code.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/02\/python-generate-qr-code-project.webp","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-qr-code-generator-project\/#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":"Python QR Code Generator Project with Source Code"}]},{"@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\/107430","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=107430"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/107430\/revisions"}],"predecessor-version":[{"id":148596,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/107430\/revisions\/148596"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108003"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=107430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=107430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=107430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}