Skip to content

Commit d8fe721

Browse files
committed
Change the behavior of "more info" and various GUI improvements.
1 parent 0b599e4 commit d8fe721

File tree

1 file changed

+60
-14
lines changed

1 file changed

+60
-14
lines changed

main.py

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ def __init__(self, app:CTk.CTk) :
120120
self.app_hieght = 800
121121

122122
app.resizable(False, False)
123-
123+
124+
self.chatHistory = [
125+
{"role" : "system", "content" : systemPrompt}
126+
]
127+
124128
## Spawns screen constants...
125129
header = CTk.CTkFrame(self.app, width=600, height=75, fg_color=self.bg_color_light, bg_color=self.bg_color, corner_radius=0)
126130
header.place(x=0, y=0)
@@ -131,9 +135,8 @@ def __init__(self, app:CTk.CTk) :
131135
settings_button = CTk.CTkButton(header, text="⚙️", font=self.header_font, fg_color=self.bg_color_light, hover_color=self.bg_color, border_width=0, command = lambda : self.director("SettingButton"), width=60, height=50)
132136
settings_button.place(x=525, y=12)
133137

134-
self.chatHistory = [
135-
{"role" : "system", "content" : systemPrompt}
136-
]
138+
ai_chat_button = CTk.CTkButton(self.app, 100, border_width=0, command=self.chat_with_ai, bg_color=self.bg_color_light, fg_color=self.bg_color_light, text="Chat with AI!", font=self.header_font)
139+
ai_chat_button.place(x=200, y=550)
137140

138141
self.parse_unis()
139142

@@ -164,7 +167,7 @@ def intro_1st_slide(self,) :
164167
self.all_screen_obj.append(intro_text_2)
165168

166169
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_2nd_slide, width=100, height=50)
167-
next_button.place(x=150, y=400)
170+
next_button.place(x=350, y=450)
168171
self.all_screen_obj.append(next_button)
169172

170173
def intro_2nd_slide(self,) :
@@ -179,11 +182,11 @@ def intro_2nd_slide(self,) :
179182
self.all_screen_obj.append(self.name_tb)
180183

181184
back_button = CTk.CTkButton(self.app, text="Back", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command = self.intro_1st_slide, width=100, height=50)
182-
back_button.place(x=150, y=400)
185+
back_button.place(x=150, y=450)
183186
self.all_screen_obj.append(back_button)
184187

185188
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command = self.intro_3rd_slide, width=100, height=50)
186-
next_button.place(x=350, y=400)
189+
next_button.place(x=350, y=450)
187190
self.all_screen_obj.append(next_button)
188191

189192
def intro_3rd_slide(self,) :
@@ -268,11 +271,11 @@ def intro_4th_slide_ap_selector(self) :
268271
self.all_screen_obj.append(self.ap_score)
269272

270273
back_button = CTk.CTkButton(self.app, text="Back", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_4th_slide, width=100, height=50)
271-
back_button.place(x=150, y=400)
274+
back_button.place(x=150, y=450)
272275
self.all_screen_obj.append(back_button)
273276

274277
next_button = CTk.CTkButton(self.app, text="Next", font=self.text_font, fg_color=self.bg_color_light, bg_color=self.bg_color, hover_color=self.bg_color, border_width=0, command=self.intro_4th_slide_ap_selector_validator, width=100, height=50)
275-
next_button.place(x=350, y=400)
278+
next_button.place(x=350, y=450)
276279
self.all_screen_obj.append(next_button)
277280

278281
def intro_4th_slide_ap_selector_validator(self,) :
@@ -941,16 +944,12 @@ def generate_report(self,) :
941944
uni_text.place(x=15, y=20)
942945
self.all_screen_obj.append(uni_text)
943946

944-
uni_button = CTk.CTkButton(layer, 75, border_width=0, command=lambda : webbrowser.open(f"https://google.com/search?q={uni.name}"), text="More info", font=self.small_font)
947+
uni_button = CTk.CTkButton(layer, 75, border_width=0, command=lambda university = uni.name: self.spawn_university_information_window(university), text="More info", font=self.small_font)
945948
uni_button.place(x=485, y=20)
946949

947950

948951
self.all_screen_obj.append(layer)
949952

950-
ai_chat_button = CTk.CTkButton(self.app, 100, border_width=0, command=self.chat_with_ai, bg_color=self.bg_color_light, fg_color=self.bg_color_light, text="Chat with AI!", font=self.header_font)
951-
ai_chat_button.place(x=250, y=550)
952-
self.all_screen_obj.append(ai_chat_button)
953-
954953
except :
955954
messagebox.showerror("Invalid Career Path", "Invalid Career Path!")
956955
self.intro_11th_slide()
@@ -1045,5 +1044,52 @@ def sendOPENAIMessage(self, user_input) -> str :
10451044
return response.choices[0].message.content
10461045
except Exception as e :
10471046
return f"An error occurred: {str(e)}"
1047+
1048+
def spawn_university_information_window(self, university_name) :
1049+
temp_chat = [{"role" : "system", "content" : systemPrompt + ". Please do not use lists and keep the reponse in a paragraph."}] ## Janky but works
1050+
temp_chat.append({"role" : "user", "content" : "Generate a short description of " + university_name + ". But be sure to include some tips for how to get in."})
1051+
1052+
try :
1053+
response = openai.chat.completions.create(
1054+
model="gpt-4o",
1055+
messages=temp_chat,
1056+
max_tokens=300,
1057+
n=1,
1058+
stop=None,
1059+
temperature=0.7
1060+
)
1061+
1062+
uni_description = response.choices[0].message.content
1063+
print(uni_description)
1064+
except Exception as e :
1065+
messagebox.showerror("Error!", f"An error occurred: {str(e)}")
1066+
1067+
## Programming crimes
1068+
uni_description = list(uni_description)
1069+
1070+
space_count = 0
1071+
1072+
for i in range(len(uni_description)):
1073+
if uni_description[i] == " ":
1074+
space_count += 1
1075+
if space_count % 6 == 0:
1076+
uni_description[i] = "\n" ## Very janky method of line seperation.
1077+
i = i-1 ## to deal with the fact that we technically added an additional character.
1078+
uni_description = "".join(uni_description)
1079+
1080+
uni_description_window = CTk.CTkToplevel(self.app,)
1081+
uni_description_window.config(bg=self.bg_color)
1082+
uni_description_window.geometry("600x600")
1083+
uni_description_window.title("About " + university_name)
1084+
1085+
header = CTk.CTkFrame(uni_description_window, 600, 75, 0, 0, self.bg_color_light, self.bg_color_light, )
1086+
header.place(x=0, y=0)
1087+
1088+
uni_name_header = CTk.CTkLabel(header, text=university_name, width=360, height=50, font=self.medium_font, text_color=self.app_text_color, bg_color=self.bg_color_light, fg_color=self.bg_color_light, )
1089+
uni_name_header.place(x=20, y=15)
1090+
1091+
uni_text = CTk.CTkLabel(uni_description_window, 600, 80, bg_color=self.bg_color, fg_color=self.bg_color, text=uni_description, font=self.button_font)
1092+
uni_text.place(x=0, y = 100)
1093+
10481094

10491095
var = app(CTk.CTk())

0 commit comments

Comments
 (0)