简体   繁体   English

为什么单击文本小部件后出现框架边框/线条(框架在画布内)tkinter

[英]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.我在使用 python tkinter 制作 GUI 应用程序时遇到了问题。

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 :它是高亮背景,可以通过设置highlightthickness=0来移除:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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