Close Menu
Techs Slash

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    How To Develop A Strategy That Works On Khelostar

    July 10, 2025

    Durable, Fast, and Accurate: Industrial-Grade Wrap Around Labeler

    July 10, 2025

    Unlocking the True Potential of Your Mitsubishi: A Guide to Performance Tuning

    July 9, 2025
    Facebook X (Twitter) Instagram
    Techs Slash
    • Home
    • News
      • Tech
      • Crypto News
      • Cryptocurrency
    • Entertainment
      • Actors
      • ANGEL NUMBER
      • Baby Names
      • Beauty
      • beauty-fashion
      • facebook Bio
      • Fitness
      • Dubai Tour
    • Business
      • Business Names
    • Review
      • Software
      • Smartphones & Apps
    • CONTRIBUTION
    Facebook X (Twitter) Instagram
    Techs Slash
    Home»python»Python 3 PyQt5 TODO List CRUD App Using SQLite Database GUI Desktop App
    python

    Python 3 PyQt5 TODO List CRUD App Using SQLite Database GUI Desktop App

    Ranveer KumarBy Ranveer KumarOctober 25, 2022No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email

    Warning: Trying to access array offset on value of type bool in /home/cadesimu/techsslash.com/wp-content/themes/smart-mag/partials/single/featured.php on line 78
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Python 3 PyQt5 Lineup for the day Muck Application Utilizing SQLite Data set GUI Work area Application I’m exceptionally intrigued to converse with you about this article. The explanation is that this article contains exceptionally fascinating data. How about we go to this article

    Python 3 PyQt5 TODO List CRUD App Using SQLite Database GUI Desktop App

    # -*- coding: utf-8 -*-
    
    # Form implementation generated from reading ui file 'todo.ui'
    #
    # Created by: PyQt5 UI code generator 5.15.4
    #
    # WARNING: Any manual changes made to this file will be lost when pyuic5 is
    # run again.  Do not edit this file unless you know what you are doing.
    
    
    from PyQt5 import QtCore, QtGui, QtWidgets
    import sqlite3
    
    
    
    class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
            MainWindow.setObjectName("MainWindow")
            MainWindow.resize(500, 600)
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap("to-do-list.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            MainWindow.setWindowIcon(icon)
            self.centralwidget = QtWidgets.QWidget(MainWindow)
            self.centralwidget.setObjectName("centralwidget")
            self.task_input = QtWidgets.QLineEdit(self.centralwidget)
            self.task_input.setGeometry(QtCore.QRect(30, 370, 431, 25))
            self.task_input.setObjectName("task_input")
            self.date_input = QtWidgets.QLineEdit(self.centralwidget)
            self.date_input.setGeometry(QtCore.QRect(30, 410, 201, 25))
            self.date_input.setObjectName("date_input")
            self.add_button = QtWidgets.QPushButton(self.centralwidget)
            self.add_button.setGeometry(QtCore.QRect(70, 490, 91, 71))
            self.add_button.setObjectName("add_button")
            self.remove_button = QtWidgets.QPushButton(self.centralwidget)
            self.remove_button.setGeometry(QtCore.QRect(330, 490, 91, 71))
            self.remove_button.setObjectName("remove_button")
            self.todo_list = QtWidgets.QTableWidget(self.centralwidget)
            self.todo_list.setGeometry(QtCore.QRect(30, 30, 431, 311))
            self.todo_list.setObjectName("todo_list")
            self.info_label = QtWidgets.QLabel(self.centralwidget)
            self.info_label.setGeometry(QtCore.QRect(150,570,200,20))
    
    
    
    
    
            self.todo_list.setColumnCount(3)
    
    
            MainWindow.setCentralWidget(self.centralwidget)
    
            self.retranslateUi(MainWindow)
            QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
            self.add_button.clicked.connect(self.add_task)
            self.remove_button.clicked.connect(self.remove_task)
            self.connect_database()
    
        def connect_database(self):
            global db, db_cursor, tasks, dates, x , rows
            db = sqlite3.connect("tasks.db")
            db_cursor = db.cursor()
            try:
                db_cursor.execute("CREATE TABLE to_do (id INTEGER PRIMARY KEY AUTOINCREMENT,task text,date text)")
            except:
                pass
    
            db_cursor.execute("SELECT * FROM to_do")
    
            self.todo_list.clearContents()
            self.todo_list.setRowCount(0)
    
            data = db_cursor.fetchall()
            #add tasks from database to the table
            for r1 in range(len(data)):
                item = data[r1]
                item = list(item)
                self.todo_list.insertRow(r1)
                self.todo_list.setItem(r1, 0, QtWidgets.QTableWidgetItem(str(item[0])))
                self.todo_list.setItem(r1, 1, QtWidgets.QTableWidgetItem(item[1]))
                self.todo_list.setItem(r1, 2, QtWidgets.QTableWidgetItem(item[2]))
    
    
            self.todo_list.resizeColumnsToContents()
            labels = ["Id","Tasks","Date"]
            self.todo_list.setHorizontalHeaderLabels(labels)
    
    
        def add_task(self):
            new_task = self.task_input.text()
            new_date = self.date_input.text()
            if len(new_task) == 0 or len(new_date) == 0:
                self.info_label.setText("Please type in a task and a date")
                self.info_label.adjustSize()
                return None
            self.info_label.setText("")
            db_cursor.execute("INSERT INTO to_do(task,date) VALUES (:task,:date)",{'task':new_task,'date':new_date})
            db.commit()
    
            self.connect_database()
    
    
        def remove_task(self):
            #db_cursor.execute("INSERT INTO sqlite_sequence(seq) VALUES (0)")
            selected = self.todo_list.selectedItems()
            for index in selected:
                idx = self.todo_list.item(index.row(),0)
                idx = idx.text()
                db_cursor.execute(f"DELETE FROM to_do WHERE id = {idx} ")
                db_cursor.execute("delete from sqlite_sequence where name='to_do';")
                db.commit()
                self.todo_list.removeRow(index.row())
    
    
    
        def retranslateUi(self, MainWindow):
            _translate = QtCore.QCoreApplication.translate
            MainWindow.setWindowTitle(_translate("MainWindow", "To-Do List"))
            self.task_input.setPlaceholderText(_translate("MainWindow", "Enter a task"))
            self.date_input.setPlaceholderText(_translate("MainWindow", "Enter a date (xx/xx/xxxx)"))
            self.add_button.setText(_translate("MainWindow", "Add"))
            self.remove_button.setText(_translate("MainWindow", "Remove"))
    
    
    if __name__ == "__main__":
        import sys
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = QtWidgets.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())

    Final Words

    We took in some fascinating data through the article Python 3 PyQt5 Schedule Muck Application Utilizing SQLite Data set GUI Work area Application. Likewise on the off chance that you feel somewhat wary about this article you can report your questions as a remark box. Much appreciated

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Ranveer Kumar
    • Website

    Related Posts

    JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    December 18, 2023

    Why does math.log result in ValueError: math domain error?

    December 17, 2023

    “inconsistent use of tabs and spaces in indentation” [duplicate]

    December 16, 2023
    Leave A Reply Cancel Reply

    Top Posts

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    ABOUT TECHSSLASH

    Welcome to Techsslash! We're dedicated to providing you with the best of technology, finance, gaming, entertainment, lifestyle, health, and fitness news, all delivered with dependability.

    Our passion for tech and daily news drives us to create a booming online website where you can stay informed and entertained.

    Enjoy our content as much as we enjoy offering it to you

    Most Popular

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024
    CONTACT DETAILS

    Phone: +92-302-743-9438
    Email: contact@serpinsight.com

    Our Recommendation

    Here are some helpfull links for our user. hopefully you liked it.

    Techs Slash
    Facebook X (Twitter) Instagram Pinterest
    • Home
    • About us
    • contact us
    • Affiliate Disclosure
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • Write for us
    • Daman Game
    © 2025 Techsslash. All Rights Reserved

    Type above and press Enter to search. Press Esc to cancel.