简体   繁体   中英

Why frame border / line appear after click text widget (the frame is inside canvas) tkinter

i've the problem for make an GUI apps with python tkinter.

here is my sample code

import tkinter as tk

from tkinter import ttk

root = tk.Tk()

root.geometry('300x300')

root.title('CSV Editor')

notebook = ttk.Notebook(root)

notebook.pack(pady=10, expand=True)

tab_home = ttk.Frame(notebook, width=300, height=300)

notebook.add(tab_home, text='Home')

fr_home = tk.Frame(tab_home, background="white")

fr_home.grid(row=0, column=0)

fr_home_container_canvas = tk.Frame(fr_home, background="red")

fr_home_container_canvas.grid(row=0, column=0, sticky='nw')

fr_home_container_canvas.grid_rowconfigure(0, weight=1)

fr_home_container_canvas.grid_columnconfigure(0, weight=1)

fr_home_container_canvas.grid_propagate(False)

canvas_home = tk.Canvas(fr_home_container_canvas)

canvas_home.grid(row=0, column=0, sticky="news")

vsb = tk.Scrollbar(fr_home_container_canvas, orient="vertical", command=canvas_home.yview)

vsb.grid(row=0, column=1, sticky='ns')

canvas_home.configure(yscrollcommand=vsb.set)

fr_home_widget_canvas = tk.Frame(canvas_home, background="yellow")

canvas_home.create_window((0, 0), window=fr_home_widget_canvas, anchor='nw')

fr_home_widget_canvas.config(width=300, height=300, padx=10)

fr_home_container_canvas.config(width=300, height=300)

canvas_home.config(scrollregion=canvas_home.bbox("all"))


text_widget = tk.Text(fr_home_widget_canvas, width = 30, height = 10)

text_widget.grid(column=0, row=0)

root.mainloop()

if i run this code, this is the preview enter image description here

but when i click inside the text widget, in the frame appear line / border like this enter image description here

What is that line / border? how to remove it?

thank you so much:)

It is the highlight background which can be removed by setting highlightthickness=0 :

canvas_home = tk.Canvas(fr_home_container_canvas, highlightthickness=0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM