Python Tkinter – NotePad Auto-savable using SQL

30 Likes 6 Comments

Hey Shouters!! Today we will build a NotePad in Python Using SQL and Tkinter. In this, we will build a notebook that will save the data typed automatically.

Python is a High-level Programming Language widely used all over the world. It can be very helpful in clearing many tasks.

So, In this busy world; many important tasks could be required to be noted anytime. And Application that we use should be easy and without opening any large programs and avoid extra time to “Do You want to save?” popups.

So, here brings a GUI application which can keep all the text every time.

Creating Base Application

Example : Now let’s create a simple window using tkinter.

Output:

notebook using python

The Text Widget is a Tkinter Widget used to Enter or display multi-line text.

Syntax:

Example : Let’ s add an expandable Text-box widget in our window now

notebook using python

After Tkinter window, Here comes last major task, that is, to use SQL for keeping our text. How can we use it?

SQL in Python-

For bringing SQL in Python I will use module SQLite3, as it’s a basic application and most of us are familiar with SQL along with python

Here’s how it works –

Basically, we have to just provide the query to the function start( ) and it will return whatever we gets after executing query, if any.

So the logic is to create a table where we insert everything from our Text widget on exit and insert everything saved in the table column’s row on rerun of the program.

Here’s how

Saving Text from GUI to SQL

Now, everything is set, so let’s put everything up.

But, here we have function on_exit() and we want it to work on exiting the window

This will help us executing the function on exiting the window.

Complete Code

Now, All set; Here is the compiled code.

Try it, Play with it, Keep Learning

I hope, now you will be able to successfully build the Notepad using Python-Tkinter. If you are preparing for placement than do follow us on Instagram handle at Shout Coders

Recommended Posts –

  1. Lists in Python: Declaration, Insertion, Traversal and All Functions
  2. Python Program to convert a decimal number to binary number
  3. Python Program to Check a Year is Leap Year or Not
  4. Python Program to Check a Palindrome Number
  5. Word Guessing Game in Python

You might like

Sarthak Goel

About the Author: Sarthak Goel

6 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami