0% found this document useful (0 votes)
318 views

Application Development With Tkinter and Mongo DB: Code

This code creates a student record application using Tkinter for the GUI and MongoDB for the database. It defines functions to submit a student's details to the MongoDB database and to calculate and display the student's total and average marks. The Tkinter interface contains labels and entries for student name, roll number, section, and marks in 6 subjects. Buttons are included to submit the data or view the result.

Uploaded by

Shiny Prasanna T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
318 views

Application Development With Tkinter and Mongo DB: Code

This code creates a student record application using Tkinter for the GUI and MongoDB for the database. It defines functions to submit a student's details to the MongoDB database and to calculate and display the student's total and average marks. The Tkinter interface contains labels and entries for student name, roll number, section, and marks in 6 subjects. Buttons are included to submit the data or view the result.

Uploaded by

Shiny Prasanna T
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Application Development with TKinter and Mongo DB

CODE:

import pymongo
import tkinter as tk
from pymongo import MongoClient
from tkinter import * 
from tkinter import ttk
from tkcalendar import DateEntry
from tkinter.messagebox import showerror, showinfo

mongoClient = pymongo.MongoClient("mongodb://localhost:27017/")
db = mongoClient["Student_mark_database"]
col = db["student"]

def sub():
    name=nam.get()
    rol= roll.get()
    sec=dep.get()
    s1=sub1.get()
    s2=sub2.get()
    s3=sub3.get()
    s4=sub4.get()
    s5=sub5.get()
    s6=sub6.get()
    if not all((name,rol,sec,s1,s2,s3,s4,s5,s6)):
        showerror(title='Error!',message='Do not leave any of the fields empty!')
    data={'Name':name,'Roll_no':rol,'Section':sec,'GK':s1,
            'Tamil':s2,'English':s3,'Maths':s4,'Science':s5,'Social':s6}
    col.insert_one(data)
    showinfo("Success","Submitted Successfully")

def result():
    s1=sub1.get()
    s2=sub2.get()
    s3=sub3.get()
    s4=sub4.get()
    s5=sub5.get()
    s6=sub6.get()
    total=(int(s1)+int(s2)+int(s3)+int(s4)+int(s5)+int(s6))
    average=float(total/6)
    showinfo(title='Result',message=f'Total-{total} \n Average -{average}')
    showinfo("The total marks of student is :"+total+ "\n Average is "+average)

app= Tk()
app.geometry('500x500')
app.configure(bg='red')
app.title('Student form')

name_box=Label(app,text="Name :-").grid(row=0,sticky=W,pady=10)
nam=Entry(app)
nam.grid(row=0,column=1,sticky=W,pady=10)

roll_box=Label(app,text="Roll No :-").grid(row=1,sticky=W,pady=10)
roll=Entry(app)
roll.grid(row=1,column=1,sticky=W,pady=10)

dep_box=Label(app,text="Section :-").grid(row=2,sticky=W,pady=10)
dep=Entry(app)
dep.grid(row=2,column=1,sticky=W,pady=10)

Label(app, text="GK :-").grid(row = 3,sticky=W,pady=10)


sub1=Entry(app)
sub1.grid(row=3,column=1,sticky=W,pady=10)

Label(app, text="Tamil :-").grid(row = 4,sticky=W,pady=10)


sub2=Entry(app)
sub2.grid(row=4,column=1,sticky=W,pady=10)

Label(app, text="English :-").grid(row = 5,sticky=W,pady=10)


sub3=Entry(app)
sub3.grid(row=5,column=1,sticky=W,pady=10)

Label(app, text="Maths :-").grid(row = 6,sticky=W,pady=10)


sub4=Entry(app)
sub4.grid(row=6,column=1,sticky=W,pady=10)

Label(app, text="Science :-").grid(row = 7,sticky=W,pady=10)


sub5=Entry(app)
sub5.grid(row=7,column=1,sticky=W,pady=10)

Label(app, text="Social :-").grid(row = 8,sticky=W,pady=10)


sub6=Entry(app)
sub6.grid(row=8,column=1,sticky=W,pady=10)  

Register= Button(app, text="Submit", command=sub)


Register.grid(row=9, column=1,sticky=W,pady=10)

Result= Button(app, text="Result", command=result)


Result.grid(row=10, column=1,sticky=W,pady=10)
app.mainloop()
OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy