Skip to content

Instantly share code, notes, and snippets.

@rohzzn
Created April 28, 2022 09:00
Show Gist options
  • Save rohzzn/282e1d9d60e5244df4fbbbd41869e3fb to your computer and use it in GitHub Desktop.
Save rohzzn/282e1d9d60e5244df4fbbbd41869e3fb to your computer and use it in GitHub Desktop.
Doctor Appointment tkinter
from doctest import master
from tkinter import *
import sqlite3
from tkinter import messagebox
conn = sqlite3.connect('database.db')
c = conn.cursor()
ids = []
class Application:
def __init__(self, master):
self.master = master
self.left = Frame(master, width=900, height=720, bg='#CEE5F2')
self.left.pack(side=LEFT)
self.right = Frame(master, width=500, height=720, bg='#CEE5F2')
self.right.pack(side=RIGHT)
self.heading = Label(self.left, text="Doctor Meet", font=('georgia 40 '), fg='#104C91', bg='#CEE5F2')
self.heading.place(x=0, y=0)
self.name = Label(self.left, text="Patient's Name", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.name.place(x=0, y=100)
self.age = Label(self.left, text="Age", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.age.place(x=0, y=140)
self.gender = Label(self.left, text="Gender", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.gender.place(x=0, y=180)
self.location = Label(self.left, text="Location", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.location.place(x=0, y=220)
self.time = Label(self.left, text="Appointment Time", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.time.place(x=0, y=260)
self.phone = Label(self.left, text="Phone Number", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.phone.place(x=0, y=300)
self.doctors = Label(self.left, text="Doctor", font=('arial 18 bold'), fg='#1F8AC0', bg='#CEE5F2')
self.doctors.place(x=0, y=340)
self.name_ent = Entry(self.left, width=30)
self.name_ent.place(x=250, y=110)
self.age_ent = Entry(self.left, width=30)
self.age_ent.place(x=250, y=150)
self.gender_ent = Entry(self.left, width=30)
self.gender_ent.place(x=250, y=190)
self.location_ent = Entry(self.left, width=30)
self.location_ent.place(x=250, y=230)
self.time_ent = Entry(self.left, width=30)
self.time_ent.place(x=250, y=270)
self.phone_ent = Entry(self.left, width=30)
self.phone_ent.place(x=250, y=310)
self.doctors_ent = Entry(self.left, width=30)
self.doctors_ent.place(x=250, y=350)
self.submit = Button(self.left, text="Add Appointment", width=20, height=2, fg='WHITE', bg='#104C91', command=self.add_appointment)
self.submit.place(x=330, y=400)
sql2 = "SELECT ID FROM appointments "
self.result = c.execute(sql2)
for self.row in self.result:
self.id = self.row[0]
ids.append(self.id)
self.new = sorted(ids)
self.final_id = self.new[len(ids)-1]
self.logs = Label(self.right, text="Logs", font=('georgia 28 '), fg='#104C91', bg='#CEE5F2')
self.logs.place(x=20, y=0)
self.box = Text(self.right, width=50, height=40)
self.box.place(x=20, y=60)
self.box.insert(END, "Total Appointments till now : " + str(self.final_id))
def add_appointment(self):
self.val1 = self.name_ent.get()
self.val2 = self.age_ent.get()
self.val3 = self.gender_ent.get()
self.val4 = self.location_ent.get()
self.val5 = self.time_ent.get()
self.val6 = self.phone_ent.get()
self.val7 = self.doctors_ent.get()
if self.val1 == '' or self.val2 == '' or self.val3 == '' or self.val4 == '' or self.val5 == '':
messagebox.showinfo("Warning", "Please Fill Up All Boxes")
else:
sql = "INSERT INTO 'appointments' (name, age, gender, location, scheduled_time, phone, doctor) VALUES(?, ?, ?, ?, ?, ?, ?)"
c.execute(sql, (self.val1, self.val2, self.val3, self.val4, self.val5, self.val6, self.val7))
conn.commit()
messagebox.showinfo("Success", "Appointment for " +str(self.val1) + " has been created" )
self.box.insert(END,'\n Appointment fixed for ' + str(self.val1) + ' at ' + str(self.val5))
root = Tk()
root.title("Doctor Meet")
b = Application(root)
root.geometry("1365x733+-7+0")
root.resizable(False, False)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment