python - 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)
解决方案
推荐阅读
- javascript - facebook ip 一天访问千次触发js错误(TypeError: Illegal invocation)
- python - 将两个图像与 PIL 和 numpy 组合后的质量损失
- php - 使用 woocommerce 更新变体订单价格
- assembly - 某个字符在字符串中出现的次数(汇编emu8086)
- css - 按类强制 Bootstrap 4 断点(用于预览)
- css - 边框半径和背景剪辑在伪元素上未按预期工作
- c++ - 在 GCC 中使用为类打包的属性
- mysql - 根据 id 列的值将一个 sql 列转换为两个
- java - 在 Internet 连接丢失/增益时恢复 Exoplayer 直播
- r - 如何从 R Shiny Session 中返回值