@@ -135,8 +135,8 @@ def __init__(self, app:CTk.CTk) :
135
135
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 )
136
136
settings_button .place (x = 525 , y = 12 )
137
137
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 )
138
+ self . 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
+ self . ai_chat_button .place (x = 200 , y = 550 )
140
140
141
141
self .parse_unis ()
142
142
@@ -957,17 +957,14 @@ def generate_report(self,) :
957
957
958
958
def chat_with_ai (self ,) :
959
959
self .clearScreen ()
960
-
961
- self .ai_box = CTk .CTkScrollableFrame (self .app , 400 , 300 , 0 , 0 , self .app_text_box_color , self .app_text_box_color )
962
- self .ai_box .place (x = 100 , y = 150 )
963
- ## Deleting ai_box requires for basically everything else to be deleted
960
+ self .ai_chat_button .destroy ()
964
961
965
- self .ai_entry = CTk .CTkEntry (self .app , 340 , 50 , 0 , 0 , self .app_text_box_color , self .app_text_box_color , placeholder_text = "Hello, World!" , font = self .medium_font )
966
- self .ai_entry .place (x = 100 , y = 550 )
962
+ self .ai_entry = CTk .CTkEntry (self .app , 400 , 50 , 0 , 0 , self .app_text_box_color , self .app_text_box_color , placeholder_text = "Hello, World!" , font = self .medium_font )
963
+ self .ai_entry .place (x = 50 , y = 550 )
967
964
self .all_screen_obj .append (self .ai_entry )
968
965
969
966
send_button = CTk .CTkButton (self .app , 50 , 50 , 0 , 0 , command = self .sendMessage , bg_color = self .bg_color_light , fg_color = self .bg_color_light , text = "Send" , font = self .header_font )
970
- send_button .place (x = 350 , y = 550 )
967
+ send_button .place (x = 450 , y = 550 )
971
968
self .all_screen_obj .append (send_button )
972
969
973
970
self .current_y_ai = 15
@@ -1020,16 +1017,24 @@ def sendMessage(self) :
1020
1017
self .ai_entry .delete (0 , CTk .END )
1021
1018
print (user_input )
1022
1019
1023
- user_message = CTk .CTkLabel (self .ai_box , bg_color = self .bg_color_light , fg_color = self .bg_color_light , text = user_input , font = self .text_font )
1024
- user_message .place (x = 15 , y = self .current_y_ai )
1025
- self .all_screen_obj .append (user_message )
1026
- self .current_y_ai += int (len (user_input )/ 2 ) + 35
1027
-
1028
1020
ai_response = self .sendOPENAIMessage (user_input )
1021
+
1022
+ ## Programming crimes
1023
+ ai_response = list (ai_response )
1024
+
1025
+ space_count = 0
1026
+
1027
+ for i in range (len (ai_response )):
1028
+ if ai_response [i ] == " " :
1029
+ space_count += 1
1030
+ if space_count % 6 == 0 :
1031
+ ai_response [i ] = "\n " ## Very janky method of line seperation.
1032
+ i = i - 1 ## to deal with the fact that we technically added an additional character.
1033
+ ai_response = "" .join (ai_response )
1034
+
1029
1035
print (ai_response )
1030
- ai_message = CTk .CTkLabel (self .ai_box , bg_color = self .bg_color_light , fg_color = self .bg_color_light , text = ai_response , font = self .text_font )
1031
- ai_message .place (x = 15 , y = self .current_y_ai )
1032
- self .current_y_ai += int (len (ai_response )/ 2 ) + 35
1036
+ ai_message = CTk .CTkLabel (self .app , 500 , 400 , bg_color = self .bg_color , fg_color = self .bg_color , text = ai_response , font = self .text_font )
1037
+ ai_message .place (x = 25 , y = 100 )
1033
1038
1034
1039
def sendOPENAIMessage (self , user_input ) -> str :
1035
1040
try :
0 commit comments