You are on page 1of 3

import tkinter as tk

from tkinter import messagebox

class CareerSuggestion:
def __init__(self, root):
self.root = root
self.root.title("Career Suggestion Program")

# Initialize variables for user details


self.name = ""
self.class_level = ""
self.stream = ""

self.questions = [
"1. Do you enjoy working with numbers and solving mathematical
problems?",
"2. Are you interested in the field of medicine or healthcare?",
"3. Do you enjoy working with computers and technology?",
"4. Are you interested in creative arts like music, painting, or
writing?",
"5. Do you like working with machines or building things?",
"6. Are you interested in environmental issues and sustainability?",
"7. Do you enjoy working with people and helping them?",
"8. Are you interested in business, finance, or entrepreneurship?",
"9. Do you have a passion for teaching and educating others?",
"10. Are you interested in legal matters and justice?",
"11. Do you enjoy exploring and understanding different cultures?",
"12. Are you interested in research and scientific discoveries?",
"13. Do you enjoy working with data and analyzing information to make
informed decisions?",
"14. Are you comfortable with public speaking or presenting in front of
an audience?",
"15. Do you prefer a structured and organized work environment?",
"16. Are you open to working irregular hours or shifts, if required by
the job?",
"17. Do you have a desire to work in a hands-on, practical role?",
"18. Are you interested in politics and government affairs?",
"19. Do you have a strong inclination towards working in the field of
sports or athletics?",
"20. Are you willing to travel extensively for work-related purposes"
]

self.career_weights = {
'Engineer': [2, 0, 2, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 2, 0, 1,
0],
'Doctor': [0, 3, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
"Financial": [1, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,
1],
"Musician": [0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0],
"Educator": [1, 0, 0, 1, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
0],
"Researcher": [1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
2],
"Lawyer": [0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0],
"Business": [1, 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0,
2]
}
self.answers = []
self.current_question_index = 0

self.name_label = tk.Label(root, text="Name:")


self.name_label.pack()
self.name_entry = tk.Entry(root)
self.name_entry.pack()

self.class_label = tk.Label(root, text="Class:")


self.class_label.pack()
self.class_entry = tk.Entry(root)
self.class_entry.pack()

self.stream_label = tk.Label(root, text="Stream:")


self.stream_label.pack()
self.stream_entry = tk.Entry(root)
self.stream_entry.pack()

self.start_button = tk.Button(root, text="Start",


command=self.start_program)
self.start_button.pack()

self.result_label = None

def start_program(self):
self.name = self.name_entry.get()
self.class_level = self.class_entry.get()
self.stream = self.stream_entry.get()
self.name_label.destroy()
self.name_entry.destroy()
self.class_label.destroy()
self.class_entry.destroy()
self.stream_label.destroy()
self.stream_entry.destroy()
self.start_button.destroy()
self.show_question()

def show_question(self):
if self.current_question_index < len(self.questions):
question_text = self.questions[self.current_question_index]
question_label = tk.Label(root, text=question_text)
question_label.pack()

yes_button = tk.Button(root, text="Yes", command=self.handle_yes)


yes_button.pack()

no_button = tk.Button(root, text="No", command=self.handle_no)


no_button.pack()
else:
self.calculate_score()

def handle_yes(self):
self.answers.append("yes")
self.next_question()

def handle_no(self):
self.answers.append("no")
self.next_question()
def next_question(self):
self.current_question_index += 1
self.clear_question_ui()
self.show_question()

def clear_question_ui(self):
for widget in self.root.winfo_children():
widget.destroy()

def calculate_score(self):
career_scores = {career: 0 for career in self.career_weights.keys()}
for idx, answer in enumerate(self.answers):
if answer == 'yes':
for career, weights in self.career_weights.items():
career_scores[career] += weights[idx]
self.recommend_career(career_scores)

def recommend_career(self, career_scores):


suggested_career = max(career_scores, key=career_scores.get)
self.show_summary(suggested_career)

def show_summary(self, suggested_career):


summary_text = "Name: {}\nClass: {}\nStream: {}\nSuggested Career:
{}".format(self.name, self.class_level, self.stream, suggested_career)
self.result_label = tk.Label(root, text=summary_text)
self.result_label.pack()

if __name__ == "__main__":
root = tk.Tk()
app = CareerSuggestion(root)
root.mainloop()

You might also like