{"id":85886,"date":"2022-02-07T09:00:03","date_gmt":"2022-02-07T03:30:03","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=85886"},"modified":"2026-06-03T16:30:11","modified_gmt":"2026-06-03T11:00:11","slug":"text-editor-notepad-project-python","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/","title":{"rendered":"Create a Simple Text Editor in Python"},"content":{"rendered":"<p>If one wants to learn a language the best way is to use it practically. Why not create interesting Python projects to learn Python? This time we are going to create a Text Editor Project using Python. This text editor will have a basic function to save a file.<\/p>\n<h3>About Text Editor<\/h3>\n<p>Text Editor is a simple application that helps a user to write texts and save it in a file. It is a basic beginners project but very interesting to make. So let\u2019s get started.<\/p>\n<h3>Project Details<\/h3>\n<p>This is a very interesting project using Python. Here we are going to create a text editor which will have several options like copy, paste, save, save as etc. We will try to include every possible option in it. While creating the project we will be using these modules and libraries &#8211;<\/p>\n<ul>\n<li>Tkinter Module<\/li>\n<li>Filedialog<\/li>\n<\/ul>\n<h3>Project Prerequisites<\/h3>\n<p>You need to install the Python Tkinter Module to create GUI. Use the following command to install it<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install tk<\/pre>\n<h3>Download Python Text Editor Project<\/h3>\n<p>Download source code of python text editor project: <a href=\"https:\/\/drive.google.com\/file\/d\/1dkIKoH98ZSHH7murXo5ZQQrZdhbeE1la\/view?usp=drive_link\"><strong>Python Text Editor Project Code<\/strong><\/a><\/p>\n<h3>Steps to Create Text Editor Using Python<\/h3>\n<h4>1. Importing libraries:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Import required modules and liberaries\r\nfrom tkinter import *\r\nimport tkinter as tk\r\nfrom tkinter.filedialog import asksaveasfilename<\/pre>\n<ul>\n<li>from tkinter import * for creating GUI in Python.<\/li>\n<li>Fileddialog &#8211; Inbuilt function for creating files in Python. We have imported asksaveasfilename to create a save file option in our text editor.<\/li>\n<\/ul>\n<h4>2. Create the main window:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">stimulator_window = Tk()\r\nstimulator_window.geometry('600x600')\r\nstimulator_window.title('TechVidvan')\r\n\r\nheading = Label(stimulator_window,text='Welcome to the Text Editor',font=('bold',20),bg='light grey') # This will create a label for the heading.\r\nheading.pack() # You have to pack this label so that it can be seen in the window<\/pre>\n<ul>\n<li>Creating the main window with scrollbar and save button.<\/li>\n<li>Stimulator_window = Tk() &#8211; to create the main window.<\/li>\n<li>title() &#8211; for giving the title to the window created.<\/li>\n<li>geometry()- for giving the dimensions to the window created.<\/li>\n<li>We want to give a heading to our window so we create a head variable and assign it with a Label. This label will display the desired text with attributes like font, colour, size etc. To place this head variable on the window we use the pack() function.Pack() function helps us display the label created.<\/li>\n<\/ul>\n<h4>3. Creating the Text Area, Scrollbar and Button:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">scrollbar = Scrollbar(stimulator_window).pack(side=RIGHT,fill=Y)\r\nEditor=Text(stimulator_window,width=400,height=450,yscrollcommand=scrollbar.set).pack(fill=BOTH)\r\nscrollbar.config(command=Editor.yview)<\/pre>\n<ul>\n<li>Text()- to create a text area in the window and pack it using pack(). This text area is the main area in which we will be writing our documents.<\/li>\n<li>We add a scrollbar to our text area using the Scrollbar() function which is an inbuilt function. While packing the scroll bar, we pack it on the RIGHT side so that it is vertical. It is compulsory to configure the scrollbar using the config() method. Yview specifies that the scrollbar is for the vertical section of the text area.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">button = Button(stimulator_window,text='Save',font=('normal',10),command=save, bg='yellow')\r\nbutton.place(x=270,y=520)<\/pre>\n<ul>\n<li>We want a save option in our text editor. To enable this save option, we create a save button using the Button() method which is an inbuilt method of the Tkinter Module. Command= save means that whenever the button is clicked, it will initiate the save() function(save function is given below in the article). To display the save button on the window, we use the place() method. While using the place() method, it is compulsory to specify the x and y coordinates respective to the window.<\/li>\n<\/ul>\n<h4>4. Save() Function:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def save():\r\n filepath = asksaveasfilename(defaultextension=\"txt\",filetypes=[(\"Text Files\", \"*.txt\"), (\"All Files\", \"*.*\")])\r\n if not filepath:\r\n  return\r\n  with open(filepath, \"w\") as output_file:\r\n   text = Editor.get(1.0, tk.END)\r\n   output_file.write(text)\r\n stimulator_window.title(f\"Entitled - {filepath}\")<\/pre>\n<ul>\n<li>We want to save our file that we make in the text editor for which we make a save button. Now let us make a function that will let the saving of a file happen.<\/li>\n<li>Asksaveasfilename() &#8211; this method is a part of filedialog library. This function helps us to set what the default type of file will be in the path. It basically lets us decide what the path and extension will be.<\/li>\n<li>If no filepath is given then return back. If the file path and name is given it opens the file using the open() method and we write all the text written in the text editor one by one using the write() method. After the file is saved, we display the filename and path on the window as the window title.<\/li>\n<\/ul>\n<h4>5. Main command:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># command to run\r\nwindow.mainloop()<\/pre>\n<p>Through mainloop() we command to display the window and display the output of the project.<\/p>\n<h3>Python Text Editor Project Output<\/h3>\n<p>The below picture shows the python text editor window:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/02\/python-text-editor-project-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-85902\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/02\/python-text-editor-project-output.webp\" alt=\"python text editor project output\" width=\"599\" height=\"626\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>We successfully created the Text Editor Project using Python. The modules and libraries we learned during the process of creation are<\/p>\n<ul>\n<li>Tkinter<\/li>\n<li>Filedialog<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If one wants to learn a language the best way is to use it practically. Why not create interesting Python projects to learn Python? This time we are going to create a Text Editor&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":85903,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[4625,4626,483,3249,4627,4628],"class_list":["post-85886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-notepad","tag-python-notepad-project","tag-python-project","tag-python-project-for-beginners","tag-python-text-editor","tag-python-text-editor-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create a Simple Text Editor in Python - TechVidvan<\/title>\n<meta name=\"description\" content=\"Text Editor helps a user to write texts and save it in a file. Create text editor project in python using Tkinter &amp; Filedialog modules.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Simple Text Editor in Python - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Text Editor helps a user to write texts and save it in a file. Create text editor project in python using Tkinter &amp; Filedialog modules.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-07T03:30:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T11:00:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.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=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan 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":"Create a Simple Text Editor in Python - TechVidvan","description":"Text Editor helps a user to write texts and save it in a file. Create text editor project in python using Tkinter & Filedialog modules.","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:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/","og_locale":"en_US","og_type":"article","og_title":"Create a Simple Text Editor in Python - TechVidvan","og_description":"Text Editor helps a user to write texts and save it in a file. Create text editor project in python using Tkinter & Filedialog modules.","og_url":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2022-02-07T03:30:03+00:00","article_modified_time":"2026-06-03T11:00:11+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Create a Simple Text Editor in Python","datePublished":"2022-02-07T03:30:03+00:00","dateModified":"2026-06-03T11:00:11+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/"},"wordCount":701,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.webp","keywords":["python notepad","python notepad project","Python project","python project for beginners","python text editor","python text editor project"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/","url":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/","name":"Create a Simple Text Editor in Python - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.webp","datePublished":"2022-02-07T03:30:03+00:00","dateModified":"2026-06-03T11:00:11+00:00","description":"Text Editor helps a user to write texts and save it in a file. Create text editor project in python using Tkinter & Filedialog modules.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2022\/02\/python-text-editor-notepad.webp","width":1200,"height":628,"caption":"python text editor notepad"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/text-editor-notepad-project-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Create a Simple Text Editor in Python"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":false,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=85886"}],"version-history":[{"count":1,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85886\/revisions"}],"predecessor-version":[{"id":448174,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85886\/revisions\/448174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/85903"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=85886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=85886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=85886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}