@@ -19,15 +19,15 @@ def __init__(self, master):
1919
2020 # define light grey color for borders
2121 light_grey = "#C0C0C0"
22-
22+
2323 # ====================
2424
2525 # personal information frame
2626 self .personal_frame = Frame (master , relief = "solid" , highlightbackground = light_grey , highlightthickness = 1 )
2727 self .personal_frame .grid (row = 0 , column = 0 , padx = 10 , pady = 10 , sticky = "nsew" )
2828
2929 # personal frame title
30- self .personal_title_label = Label (self .personal_frame , text = "Employee Information" , font = ("Arial" , 10 , "bold" ))
30+ self .personal_title_label = Label (self .personal_frame , text = "Employee Information" , font = ("Arial" , 10 ))
3131 self .personal_title_label .grid (row = 0 , column = 0 , columnspan = 2 , padx = 5 , pady = 5 , sticky = "w" )
3232
3333 # first Name
@@ -55,91 +55,133 @@ def __init__(self, master):
5555 self .gender_entry .grid (row = 4 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
5656
5757 # ====================
58-
58+
5959 # contact information frame
6060 self .contact_frame = Frame (master , relief = "solid" , highlightbackground = light_grey , highlightthickness = 1 )
6161 self .contact_frame .grid (row = 1 , column = 0 , padx = 10 , pady = 10 , sticky = "nsew" )
6262
6363 # contact frame title
64- self .contact_title_label = Label (self .contact_frame , text = "Contact Information" , font = ("Arial" , 10 , "bold" ))
64+ self .contact_title_label = Label (self .contact_frame , text = "Contact Information" , font = ("Arial" , 10 ))
6565 self .contact_title_label .grid (row = 0 , column = 0 , columnspan = 2 , padx = 5 , pady = 5 , sticky = "w" )
6666
6767 # email Address
6868 self .email_label = Label (self .contact_frame , text = "Email Address:" , font = ("Arial" , 10 ))
6969 self .email_label .grid (row = 1 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
7070 self .email_entry = Entry (self .contact_frame , font = ("Arial" , 10 ))
7171 self .email_entry .grid (row = 1 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
72-
72+
7373 # phone number
7474 self .phone_number_label = Label (self .contact_frame , text = "Phone Number:" , font = ("Arial" , 10 ))
7575 self .phone_number_label .grid (row = 2 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
7676 self .phone_number_entry = Entry (self .contact_frame , font = ("Arial" , 10 ))
77- self .phone_number_entry .grid (row = 2 , column = 1 , padx = 10 , pady = 5 , sticky = "ew " )
78-
77+ self .phone_number_entry .grid (row = 2 , column = 1 , padx = 10 , pady = 5 , sticky = "e " )
78+
7979 # home address
8080 self .address_label = Label (self .contact_frame , text = "Home Address:" , font = ("Arial" , 10 ))
8181 self .address_label .grid (row = 3 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
8282 self .address_entry = Entry (self .contact_frame , font = ("Arial" , 10 ))
8383 self .address_entry .grid (row = 3 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
84-
84+
8585 # zip code
8686 self .zip_code_label = Label (self .contact_frame , text = "Zip Code:" , font = ("Arial" , 10 ))
8787 self .zip_code_label .grid (row = 4 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
8888 self .zip_code_entry = Entry (self .contact_frame , font = ("Arial" , 10 ))
8989 self .zip_code_entry .grid (row = 4 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
90-
90+
9191 # ====================
92-
92+
9393 # job information frame
9494 self .job_frame = Frame (master , relief = "solid" , highlightbackground = light_grey , highlightthickness = 1 )
9595 self .job_frame .grid (row = 2 , column = 0 , padx = 10 , pady = 10 , sticky = "nsew" )
96-
96+
9797 # job information title
98- self .job_frame_title = Label (self .job_frame , text = "Job Information" , font = ("Arial" , 10 , "bold" ))
98+ self .job_frame_title = Label (self .job_frame , text = "Job Information" , font = ("Arial" , 10 ))
9999 self .job_frame_title .grid (row = 0 , column = 0 , columnspan = 2 , padx = 5 , pady = 5 , sticky = "w" )
100-
100+
101101 # job title
102102 self .job_title_label = Label (self .job_frame , text = "Job Title:" , font = ("Arial" , 10 ))
103103 self .job_title_label .grid (row = 1 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
104104 self .job_title_entry = Entry (self .job_frame , font = ("Arial" , 10 ))
105105 self .job_title_entry .grid (row = 1 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
106-
106+
107107 # department
108108 self .department_label = Label (self .job_frame , text = "Department:" , font = ("Arial" , 10 ))
109109 self .department_label .grid (row = 2 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
110110 self .department_entry = Entry (self .job_frame , font = ("Arial" , 10 ))
111111 self .department_entry .grid (row = 2 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
112-
112+
113113 # date of hire
114114 self .hire_date_label = Label (self .job_frame , text = "Hire Date:" , font = ("Arial" , 10 ))
115115 self .hire_date_label .grid (row = 3 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
116116 self .hire_date_entry = Entry (self .job_frame , font = ("Arial" , 10 ))
117117 self .hire_date_entry .grid (row = 3 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
118-
118+
119119 # salary
120120 self .salary_label = Label (self .job_frame , text = "Salary:" , font = ("Arial" , 10 ))
121121 self .salary_label .grid (row = 4 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
122- self .salary_entry = Entry (self .job_frame ,font = ("Arial" , 10 ))
123- self .salary_entry .grid (row = 4 , column = 1 , padx = 0 , pady = 5 , sticky = "e" )
124-
122+ self .salary_entry = Entry (self .job_frame , font = ("Arial" , 10 ))
123+ self .salary_entry .grid (row = 4 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
124+
125125 # ====================
126-
126+
127127 # emergency contact frame
128128 self .emergency_contact_frame = Frame (master , relief = "solid" , highlightbackground = light_grey , highlightthickness = 1 )
129129 self .emergency_contact_frame .grid (row = 3 , column = 0 , padx = 10 , pady = 10 , sticky = "nsew" )
130-
131- # ====================
132-
130+
131+ # emergency information title
132+ self .emergency_contact_title = Label (self .emergency_contact_frame , text = "Emergency Information" , font = ("Arial" , 10 ))
133+ self .emergency_contact_title .grid (row = 0 , column = 0 , columnspan = 2 , padx = 5 , pady = 5 , sticky = "w" )
134+
135+ # emergency contact first name
136+ self .e_fname_label = Label (self .emergency_contact_frame , text = "First Name:" , font = ("Arial" , 10 ))
137+ self .e_fname_label .grid (row = 1 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
138+ self .e_fname_entry = Entry (self .emergency_contact_frame , font = ("Arial" , 10 ))
139+ self .e_fname_entry .grid (row = 1 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
140+
141+ # emergency contact last name
142+ self .elname_label = Label (self .emergency_contact_frame , text = "Last Name:" , font = ("Arial" , 10 ))
143+ self .elname_label .grid (row = 2 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
144+ self .elname_entry = Entry (self .emergency_contact_frame , font = ("Arial" , 10 ))
145+ self .elname_entry .grid (row = 2 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
146+
147+ # emergency contact relationship
148+ self .e_relationship_label = Label (self .emergency_contact_frame , text = "Relationship:" , font = ("Arial" , 10 ))
149+ self .e_relationship_label .grid (row = 3 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
150+ self .e_relationship_entry = Entry (self .emergency_contact_frame , font = ("Arial" , 10 ))
151+ self .e_relationship_entry .grid (row = 3 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
152+
153+ # emergency contact number
154+ self .e_phone_number_label = Label (self .emergency_contact_frame , text = "Phone Number:" , font = ("Arial" , 10 ))
155+ self .e_phone_number_label .grid (row = 4 , column = 0 , padx = 5 , pady = 5 , sticky = "w" )
156+ self .e_phone_number_entry = Entry (self .emergency_contact_frame , font = ("Arial" , 10 ))
157+ self .e_phone_number_entry .grid (row = 4 , column = 1 , padx = 10 , pady = 5 , sticky = "e" )
158+
133159 # configure grid layout for the frames to expand properly
134160 self .personal_frame .columnconfigure (1 , weight = 1 )
135161 self .contact_frame .columnconfigure (1 , weight = 1 )
136162 self .job_frame .columnconfigure (1 , weight = 1 )
163+ self .emergency_contact_frame .columnconfigure (1 , weight = 1 )
137164
138- # emergency contact name
139- self .eContact_label = Label (self .emergency_contact_frame , text = "Emergency Name:" , font = ("Arial" , 10 ))
140- self .eContact_label .grid ()
141- # relationship
142- # phone number
165+ # ====================
166+
167+ # Adjust window size based on the content
168+ self .adjust_window_size ()
169+
170+ def adjust_window_size (self ):
171+ # Update the window layout to calculate the total height
172+ self .master .update_idletasks ()
173+
174+ # Calculate the total height needed for all frames
175+ total_height = (
176+ self .personal_frame .winfo_height () +
177+ self .contact_frame .winfo_height () +
178+ self .job_frame .winfo_height () +
179+ self .emergency_contact_frame .winfo_height () +
180+ 50 # additional padding between frames
181+ )
182+
183+ # Set the window height to fit all frames
184+ self .master .geometry (f"1400x{ total_height } " )
143185
144186def main ():
145187 """Initialize the Tkinter window application."""
@@ -150,7 +192,6 @@ def main():
150192 # start the Tkinter event loop
151193 window .mainloop ()
152194
153-
154195if __name__ == "__main__" :
155196 # run the main function if the script is executed directly
156197 main ()
0 commit comments