index.py
Python_basic_school_managemnet system
This project demonstrates how to create a login system using CustomTkinter, a Python library for creating beautiful and customizable user interfaces. The system includes image processing to enhance the visual appeal of the login screen.
import customtkinter as tk
from PIL import Image
import json
from hashlib import sha256
import secrets
- CustomTkinter: This library provides a set of customizable widgets for creating user interfaces.
- PIL: Python Imaging Library is used for image processing tasks.
- json: This library is used to read and write JSON files.
- hashlib: This library provides functions for hashing data.
- secrets: This library provides functions for generating secure random numbers.
app = tk.CTk()
app.geometry('800x600')
- CTk(): This line creates the main application window.
- geometry(): This method sets the size of the application window to 800x600 pixels.
bg_img = Image.open('data\images\login\\32271.jpg')
bg = tk.CTkImage(bg_img, size=(600, 700))
lab = tk.CTkLabel(master=app, image=bg, text='')
lab.place(relx=0.2, rely=1, anchor='s')
- Image.open(): This line loads the background image from the specified path.
- CTkImage(): This line creates a CustomTkinter image object from the loaded image.
- CTkLabel(): This line creates a label widget to display the background image.
- place(): This method positions the label widget at the bottom-right corner of the application window.
Login_text = tk.CTkLabel(master=app, text='Login', font=Font, bg_color='transparent')
Login_text.place(relx=0.7, rely=0.2)
-
**CTkLabel
-
**home.py
This is a simple student management system with a graphical user interface (GUI) built using the customtkinter
library. It allows users to search for students and add new students to the system.
To run this code, you will need to have the following libraries installed:
customtkinter
PIL
(Python Imaging Library)
The code is structured as follows:
- The
home_2()
function is the main function that creates the GUI and handles the user interactions. - The
on_c1()
function is called when the "Search Students" button is clicked. It imports themain()
function from thedata.modules.search
module and calls it. - The
on_c2()
function is called when the "Add Students" button is clicked. It imports theformm()
function from thedata.modules.form
module and calls it. - The
info()
function is called when the "Info" button is clicked. It displays a message box with information about the software.
Here is a step-by-step explanation of the code:
- The
home_2()
function creates the main window of the application and sets its title, geometry, and resizable properties. - The
search_image
button is created and placed on the window. When this button is clicked, theon_c1()
function is called. - The
on_c1()
function imports themain()
function from thedata.modules.search
module and calls it. Themain()
function is responsible for searching for students. - The
search_image
button is created and placed on the window. When this button is clicked, theon_c2()
function is called. - The
on_c2()
function imports theformm()
function from thedata.modules.form
module and calls it. Theformm()
function is responsible for adding new students to the system. - The
info()
function is created and placed on the window. When this button is clicked, theinfo()
function is called. - The
info()
function displays a message box with information about the software.
To run the code, simply open a terminal window and navigate to the #form.py
This project is a simple student data management system built using Python and the customtkinter
library. It allows users to add new students to a database, and view and edit existing student records.
To run this project, you will need the following:
- Python 3.6 or later
customtkinter
library
To install the customtkinter
library, open a terminal window and run the following command:
pip install customtkinter
To use the student data management system, simply run the formm.py
file. This will open the main application window, which contains a form for adding new students.
To add a new student, simply enter the student's name, roll number, father's name, mother's name, phone number, date of birth, and birth certificate number into the corresponding fields. Then, click the "Submit" button to save the student's data to the database.
The student data management system uses a SQLite database to store student records. The database is created automatically when you run the application for the first time.
The code for the student data management system is relatively simple and straightforward. Here is a step-by-step explanation of the code:
- Import the necessary libraries.
import customtkinter as tk
from tkinter import messagebox
import sqlite3
- Define the main application window.
app = tk.CTk()
app.title("Add A Student")
app.geometry('600x600')
- Create a form for adding new students.
entry_frame = tk.CTkFrame(master=app,width=550,height=550)
entry_frame.place(relx=0.5,rely=0.5,anchor="center")
name_entry = tk.CTkEntry(master=entry_frame,text_color='white',placeholder_text='Enter Name',width=200,placeholder_text_color='white',corner_radius=34)
name_entry.place(relx=0.2,rely=0.1,anchor='s')
roll_entry = tk.CTkEntry(master=
#search.py
This is a student database search application built using SQLite and Tkinter. It allows users to search, edit, and delete student records from a local database.
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
import sqlite3
We start by importing the necessary modules for building the GUI and interacting with the SQLite database.
def create_table():
conn = sqlite3.connect('student_data.db')
cursor = conn.cursor()
# Create a table if it doesn't exist
cursor.execute('''
CREATE TABLE IF NOT EXISTS students (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
roll TEXT NOT NULL,
father TEXT,
mother TEXT,
phone TEXT,
birth_date TEXT,
birth_certificate TEXT
)
''')
conn.commit()
conn.close()
The create_table()
function establishes a connection to the SQLite database and creates a table named students
if it doesn't already exist. The table has several columns, including id
, name
, roll
, father
, mother
, phone
, birth_date
, and birth_certificate
.
def insert_data(name, roll, father, mother, phone, birth_date, birth_certificate):
conn = sqlite3.connect('student_data.db')
cursor = conn.cursor()
# Insert data into the table
cursor.execute('''
INSERT INTO students (name, roll, father, mother, phone, birth_date, birth_certificate)
VALUES (?, ?, ?, ?, ?, ?, ?)
''', (name, roll, father, mother, phone, birth_date, birth_certificate))
conn.commit()
conn.close()
The insert_data()
function takes various student details as arguments and inserts them into the students
table.
def search_data(search_text):
conn = sqlite3.connect('student_data.db')
cursor = conn.cursor()
# Search for data based on the search text
cursor.execute('''
SELECT * FROM students
WHERE name LIKE ? OR roll LIKE ? OR father LIKE ? OR mother LIKE ? OR phone LIKE ? OR birth_date LIKE ? OR birth_certificate LIKE ?
''', ('%' + search_text + '%', '%' + search_text + '%', '%' + search_text + '%', '%' + search_text + '%', '%' + search_text + '%', '%' + search_text + '%', '%' + search_text + '%'))
rows = cursor.fetchall()
conn.close()
return rows
project by aritra