Hope you don't mind but, I spruced up your app a little.
I didn't do any of the database functions as I don't really know what you are wanting them to do.
On a side note you have a delete and reset button. If you delete a record from the database, it can't be reset.
Here is the code
I didn't do any of the database functions as I don't really know what you are wanting them to do.
On a side note you have a delete and reset button. If you delete a record from the database, it can't be reset.
Here is the code
import tkinter as tk import tkcalendar class Database: def __init__(self): pass class Window: def __init__(self, parent): # Set some parent window variables self.parent = parent self.parent.columnconfigure(0, weight=1) self.parent.rowconfigure(0, weight=1) # self.parent.geometry('1280x720+300+300') self.parent.title('Hospital Management System Version 0.01') # Create a main container frame widget. This will hold all other containers and widgets container = tk.Frame(self.parent) container.grid(column=0, row=0, sticky='news') container.grid_columnconfigure(0, weight=3) # Create a header for the app header = tk.Label(container, text='Hospital Management System', pady=8) header['font'] = None, 34, 'bold' header['bg'] = 'firebrick' header['fg'] = 'white' header.grid(column=0, row=0, sticky='news', padx=8, pady=4) # Create a container for widgets in row 1 row1 = tk.Frame(container) row1.grid(column=0, row=1, sticky='news', padx=4, pady=4) # Divied the column space evenly row1.grid_columnconfigure(0, weight=3, uniform='row1') row1.grid_columnconfigure(1, weight=3, uniform='row1') # Container to hold all the entry widgets for patient infoframe = tk.LabelFrame(row1, text='Patient Information', font=(None, 11, 'bold'), padx=4, pady=4) infoframe.grid(column=0, row=0, sticky='news', padx=4, pady=4) for i in range(4): infoframe.grid_columnconfigure(i, weight=3) # Container to hold prescription information/listbox prescriptionframe = tk.LabelFrame(row1, text='Prescription', font=(None, 11, 'bold')) prescriptionframe.grid(column=1, row=0, sticky='news', padx=4, pady=4) prescriptionframe.grid_columnconfigure(0, weight=3) # List of patient fields data = ['Reference No', 'Issue Date', 'Appointment Date', 'Patient ID', 'Patient Name', 'Date Of Birth', 'Patient Address', 'NHS Number', 'Use Medication', 'Doctor Name'] thelist = ['Issue Date','Appointment Date', 'Date Of Birth'] # Empty list to hold entry fields self.fields = [] col, row = 0, 0 for index, prefix in enumerate(data): label = tk.Label(infoframe, text=f'{prefix}:', anchor='w') # So entry prefix is in every other column if col % 2 == 0: col += 1 label.grid(column=col, row=row, sticky='new', padx=2, pady=4) if prefix in thelist: self.fields.append(tkcalendar.DateEntry(infoframe)) else: self.fields.append(tk.Entry(infoframe)) self.fields[index].grid(column=col+1, row=row, sticky='new', padx=8, pady=4) if col >= 3: row += 1 col = 0 else: col += 1 self.prescription = tk.Text(prescriptionframe, height=9) self.prescription.grid(column=0, row=0, sticky='news', padx=4, pady=4) # List for the buttons buttons = ['Prescription', 'Medication Details', 'Delete', 'Reset', 'Exit'] buttonlist = [] buttonframe = tk.LabelFrame(container, text='Actions', font=(None, 11, 'bold')) buttonframe.grid(column=0, row=2, sticky='news', padx=4, pady=4) for i in range(len(buttons)): buttonframe.grid_columnconfigure(i, weight=3, uniform='button') for index, button in enumerate(buttons): if button == 'Exit': color = 'orangered' activecolor = 'orange' elif button == 'Delete': color = 'tomato' activecolor = 'red' else: color = 'powderblue' activecolor = 'skyblue' buttonlist.append(tk.Button(buttonframe, text=button, bg=color, cursor='hand2')) buttonlist[index]['activebackground'] = activecolor buttonlist[index].grid(column=index, row=0, sticky='news', padx=4, pady=4) extra = tk.LabelFrame(container) extra['text'] = 'Type of medical condition / Does the patient use medications?' extra.grid(column=0, row=3, sticky='news', padx=4, pady=4) extra.grid_columnconfigure(0, weight=3) self.extra = tk.Text(extra) self.extra.grid(column=0, row=0, sticky='news' ,padx=4, pady=4) class Controller: def __init__(self, database, window): self.database = database self.window = window if __name__ == '__main__': root = tk.Tk() controller = Controller(Database(), Window(root)) root.mainloop()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags