[TCT][Tool][Non-ACR] Restructuring function for reuse 38/319038/1
authorUtkarsh Tiwari <utk.tiwari@samsung.com>
Mon, 14 Oct 2024 05:13:27 +0000 (10:43 +0530)
committerUtkarsh Tiwari <utk.tiwari@samsung.com>
Mon, 14 Oct 2024 05:13:27 +0000 (10:43 +0530)
Change-Id: I649e3ffdd2df31b424bd6b46049424ea87fb8fee
Signed-off-by: Utkarsh Tiwari <utk.tiwari@samsung.com>
tool/TC_Assistant_Tool/tct_assistance.py

index 10ccabf4ff59110dbf2244d40797fda5dd0564e5..35ec9443f5a9888c5a4a329028bd28a9c5941610 100644 (file)
@@ -1111,17 +1111,27 @@ def on_closing():
     if response=="Yes":\r
         base.destroy()\r
 \r
+def create_label(welcomeText):\r
+    Bot_ko = customtkinter.CTkLabel(ChatLog,text=welcomeText+"\n", justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
+    WhiteSpace = customtkinter.CTkLabel(ChatLog,text="This is a empty line label", justify='left',text_color='#d3d3d3',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
+    ChatLog.insert('0.0', '\n')\r
+    ChatLog.window_create('0.0', window=WhiteSpace)\r
+    ChatLog.insert(END, '\n')\r
+    ChatLog.window_create('end', window=Bot_ko)\r
+    ChatLog.insert(END, '\n')\r
+    ChatLog.see("1.0")\r
+    ChatLog.tag_add("no_padding", "end-1c linestart", "end-1c lineend")\r
+    ChatLog.tag_configure("no_padding", lmargin1=0, lmargin2=0, rmargin=0)\r
+    ChatLog.insert(END, "")\r
+\r
 def radiobutton_event():\r
     global toggle\r
 \r
-    print("radiobutton toggled, current value:", radio_var.get())\r
-    print("ChatLog.winfo_children()", ChatLog.winfo_children())\r
-\r
     # get yes/no answers whether user want to change language or not\r
     msg = CTkMessagebox(title="Exit?", message="Your current progress will be lost. Do you want to switch language?",\r
                         icon="question", option_1="No", option_2="Yes", option_3="",option_focus=2)\r
     response = msg.get()\r
-\r
+    welcomeText = "Assistant: Hey, Welcome to TC Assistance System. Tell me how would you like to proceed? \n > You can add a new UTC in existing module\n > You can add UTC in new module\n > Support Assistant\n > Remove Deprecated APIs\n"\r
     if response=="Yes":\r
         ChatLog.mark_set("end", "1.0")\r
         if toggle != radio_var.get():\r
@@ -1129,36 +1139,14 @@ def radiobutton_event():
                 if child.widgetName == "frame":\r
                     child.destroy()\r
             ChatLog.delete(0, END)\r
+            Bot.destroy()\r
             if radio_var.get() == 2:\r
-                Bot.destroy()\r
-                welcomeText = "Assistant: Hey, Welcome to TC Assistance System. Tell me how would you like to proceed? \n > You can add a new UTC in existing module\n > You can add UTC in new module\n > Support Assistant\n > Remove Deprecated APIs\n"\r
                 welcomeText = translate_to_ko(welcomeText)\r
-                Bot_ko = customtkinter.CTkLabel(ChatLog,text=welcomeText+"\n\n", justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
-                WhiteSpace = customtkinter.CTkLabel(ChatLog,text="This is a empty line label", justify='left',text_color='#d3d3d3',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
-                ChatLog.insert('0.0', '\n')\r
-                ChatLog.window_create('0.0', window=WhiteSpace)\r
-                ChatLog.insert(END, '\n')\r
-                ChatLog.window_create('end', window=Bot_ko)\r
-                ChatLog.insert(END, '\n')\r
-                ChatLog.see("1.0")\r
-                ChatLog.tag_add("no_padding", "end-1c linestart", "end-1c lineend")\r
-                ChatLog.tag_configure("no_padding", lmargin1=0, lmargin2=0, rmargin=0)\r
-                ChatLog.insert(END, "")\r
+                create_label(welcomeText)\r
 \r
             elif radio_var.get() == 1:\r
-                Bot.destroy()\r
-                welcomeText = "Assistant: Hey, Welcome to TC Assistance System. Tell me how would you like to proceed? \n > You can add a new UTC in existing module\n > You can add UTC in new module\n > Support Assistant\n > Remove Deprecated APIs\n"\r
-                Bot_ko = customtkinter.CTkLabel(ChatLog,text=welcomeText+"\n", justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
-                WhiteSpace = customtkinter.CTkLabel(ChatLog,text="This is a empty line label", justify='left',text_color='#d3d3d3',corner_radius=10, padx=10, pady=5, font=("Malgun Gothic", 13),wraplength=500, cursor="hand2")\r
-                ChatLog.insert('0.0', '\n')\r
-                ChatLog.window_create('0.0', window=WhiteSpace)\r
-                ChatLog.insert(END, '\n')\r
-                ChatLog.window_create('end', window=Bot_ko)\r
-                ChatLog.insert(END, '\n')\r
-                ChatLog.see("1.0")\r
-                ChatLog.tag_add("no_padding", "end-1c linestart", "end-1c lineend")\r
-                ChatLog.tag_configure("no_padding", lmargin1=0, lmargin2=0, rmargin=0)\r
-                ChatLog.insert(END, "")\r
+                create_label(welcomeText)\r
+\r
             toggle = radio_var.get()\r
         return radio_var.get()\r
     else:\r