首页 > 解决方案 > Mac OS 上的 Tkinter 文本框滚动问题

问题描述

我在使用 Tkinter 文本框时遇到问题。滚动时会出现一条白线。我写了一个简单的代码让你重现这个问题。

注意:我在使用 Python3.x 运行脚本时遇到此问题,使用 Python2.x 运行脚本时不会出现此问题。

截图示例



import tkinter
from tkinter import *

class StdoutRedirector(object):
    def __init__(self,text_widget):
        self.text_space = text_widget

    def write(self,string):
        self.text_space.insert('end', string)
        self.text_space.see('end')


root = Tk()
root.geometry("300x300")
root.resizable(False,False)
root.title("Fattura Facile v0.2_beta")
window = Frame(root)

horiz_frame=Frame(root,height=200,width=200)
horiz_frame.pack_propagate(0)
horiz_frame.pack(side=BOTTOM)

text_box = Text(horiz_frame, wrap='word',bg="#282828",fg="white",bd=0,height=100,width=100)
text_box.pack()

sys.stdout = StdoutRedirector(text_box)

root.mainloop()


编辑:我正在使用 Python 3.7.5 版本、Tk 8.5 版本、macOS Catalina 10.15.1 (19B88)

标签: pythonmacostkintertextboxtkinter-macos

解决方案


推荐阅读