@@ -15,24 +15,23 @@ def create_sgpa_entries():
1515 sgpa_labels .append (sgpa_label )
1616 sgpa_entries .append (sgpa_entry )
1717
18- create_sgpa_entries_button .grid_remove ()
19- cgpa_calc_button .grid (row = num_semesters + 2 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
18+ create_sgpa_buttons .grid_remove ()
19+ cgpa_calc .grid (row = num_semesters + 2 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
2020
2121
22- def validate_sgpa_entries (event ):
22+ def validate_sgpa_entries ():
2323 filled_entries = [entry .get () for entry in sgpa_entries ]
2424 if all (filled_entries ):
25- cgpa_calc_button .configure (state = "normal" )
25+ cgpa_calc .configure (state = "normal" )
2626 else :
27- cgpa_calc_button .configure (state = "disabled" )
27+ cgpa_calc .configure (state = "disabled" )
2828
2929
3030def calculate_cgpa ():
3131 sgpa_values = [float (sgpa_entry .get ()) for sgpa_entry in sgpa_entries ]
3232
3333 total_sgpa = sum (sgpa_values )
3434 num_semesters = len (sgpa_values )
35- total_credit_hours = num_semesters * 18 # Assuming 18 credit hours per semester
3635 cgpa = total_sgpa / num_semesters
3736
3837 cgpa_label .configure (text = f"CGPA: { cgpa :.2f} " )
@@ -48,8 +47,8 @@ def reset_entries():
4847 sgpa_labels .clear ()
4948 sgpa_entries .clear ()
5049
51- create_sgpa_entries_button .grid (row = 1 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
52- cgpa_calc_button .configure (state = "disabled" )
50+ create_sgpa_buttons .grid (row = 1 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
51+ cgpa_calc .configure (state = "disabled" )
5352 cgpa_label .configure (text = "CGPA: " )
5453
5554 reset_button .configure (state = "disabled" )
@@ -70,10 +69,10 @@ def reset_entries():
7069sgpa_labels = []
7170sgpa_entries = []
7271
73- create_sgpa_entries_button = tk .Button (sgpa_frame , text = "Create SGPA Entries" , command = create_sgpa_entries )
74- create_sgpa_entries_button .grid (row = 1 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
72+ create_sgpa_buttons = tk .Button (sgpa_frame , text = "Create SGPA Entries" , command = create_sgpa_entries )
73+ create_sgpa_buttons .grid (row = 1 , column = 0 , columnspan = 2 , padx = 10 , pady = 5 )
7574
76- cgpa_calc_button = tk .Button (sgpa_frame , text = "Calculate CGPA" , command = calculate_cgpa , state = "disabled" )
75+ cgpa_calc = tk .Button (sgpa_frame , text = "Calculate CGPA" , command = calculate_cgpa , state = "disabled" )
7776
7877cgpa_label = tk .Label (root , text = "CGPA: " )
7978cgpa_label .pack ()
0 commit comments