From: Utkarsh Tiwari Date: Mon, 14 Oct 2024 04:22:13 +0000 (+0530) Subject: [TCT][Tool][Non-ACR] Fixed extra space issue on switching languages X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F319036%2F1;p=test%2Ftct%2Fnative%2Fapi.git [TCT][Tool][Non-ACR] Fixed extra space issue on switching languages Change-Id: I38bf55d637b6bc353c4b65401ac9476e173cc409 Signed-off-by: Utkarsh Tiwari --- diff --git a/tool/TC_Assistant_Tool/tct_assistance.py b/tool/TC_Assistant_Tool/tct_assistance.py index 652eb4f70..10ccabf4f 100644 --- a/tool/TC_Assistant_Tool/tct_assistance.py +++ b/tool/TC_Assistant_Tool/tct_assistance.py @@ -1112,26 +1112,62 @@ def on_closing(): base.destroy() def radiobutton_event(): + global toggle + print("radiobutton toggled, current value:", radio_var.get()) print("ChatLog.winfo_children()", ChatLog.winfo_children()) - for child in ChatLog.winfo_children(): - if child.widgetName == "frame": - child.destroy() - ChatLog.delete('0.0', END) - if radio_var.get() == 2: - Bot.destroy() - 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" - welcomeText = translate_to_ko(welcomeText) - Bot_ko = customtkinter.CTkLabel(ChatLog,text=welcomeText+"\n\n", justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10,font=("Malgun Gothic", 13),wraplength=500, cursor="hand2") - ChatLog.window_create('end', window=Bot_ko) - ChatLog.insert(END, '\n') - elif radio_var.get() == 1: - Bot.destroy() - 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" - Bot_ko = customtkinter.CTkLabel(ChatLog,text=welcomeText+"\n", justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10,font=("Malgun Gothic", 13),wraplength=500, cursor="hand2") - ChatLog.window_create('end', window=Bot_ko) - ChatLog.insert(END, '\n') - return radio_var.get() + + # get yes/no answers whether user want to change language or not + msg = CTkMessagebox(title="Exit?", message="Your current progress will be lost. Do you want to switch language?", + icon="question", option_1="No", option_2="Yes", option_3="",option_focus=2) + response = msg.get() + + if response=="Yes": + ChatLog.mark_set("end", "1.0") + if toggle != radio_var.get(): + for child in ChatLog.winfo_children(): + if child.widgetName == "frame": + child.destroy() + ChatLog.delete(0, END) + if radio_var.get() == 2: + Bot.destroy() + 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" + welcomeText = translate_to_ko(welcomeText) + 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") + 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") + ChatLog.insert('0.0', '\n') + ChatLog.window_create('0.0', window=WhiteSpace) + ChatLog.insert(END, '\n') + ChatLog.window_create('end', window=Bot_ko) + ChatLog.insert(END, '\n') + ChatLog.see("1.0") + ChatLog.tag_add("no_padding", "end-1c linestart", "end-1c lineend") + ChatLog.tag_configure("no_padding", lmargin1=0, lmargin2=0, rmargin=0) + ChatLog.insert(END, "") + + elif radio_var.get() == 1: + Bot.destroy() + 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" + 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") + 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") + ChatLog.insert('0.0', '\n') + ChatLog.window_create('0.0', window=WhiteSpace) + ChatLog.insert(END, '\n') + ChatLog.window_create('end', window=Bot_ko) + ChatLog.insert(END, '\n') + ChatLog.see("1.0") + ChatLog.tag_add("no_padding", "end-1c linestart", "end-1c lineend") + ChatLog.tag_configure("no_padding", lmargin1=0, lmargin2=0, rmargin=0) + ChatLog.insert(END, "") + toggle = radio_var.get() + return radio_var.get() + else: + if toggle != radio_var.get(): + if radio_var.get() == 2: + radiobutton_1.select() + elif radio_var.get() == 1: + radiobutton_2.select() + toggle = radio_var.get() CURRENT_PATH = get_current_dir_path() @@ -1152,6 +1188,7 @@ welcomeText = "Hey, Welcome to TC Assistance System. Tell me how would you like log_info_save(logger, "Assitant", welcomeText) radio_var = tkinter.IntVar(value=0) +toggle = 1 Bot = customtkinter.CTkLabel(ChatLog,text="Assistant: "+welcomeText, justify='left', fg_color='#C0C0C0',text_color='black',corner_radius=10,font=("Malgun Gothic", 13),wraplength=500, cursor="hand2") ChatLog.insert('end', '\n ') ChatLog.window_create('end', window=Bot)