小编lau*_*ent的帖子

如何使用ScrolledText小部件多色文本?

from tkinter import *
from tkinter.scrolledtext import ScrolledText

window= Tk()
window.geometry('970x45')
box = ScrolledText(window, width=70, height=7).pack()
box.insert(END, "Ehila") #this insert "Ehila" into the box
box.congif(foreground='green') #this change the colour of "Ehila" into green colour
box.insert(END, "Now") #this insert "Now" into the box
box.congif(foreground='red') #this change the colour of "Now" into red colour but also "Ehila" become red and I don't want this!
Run Code Online (Sandbox Code Playgroud)

我想为每个用不同颜色着色的文字上色,但我最后没有得到这个结果.如何保持每次插入的颜色?

python tkinter python-3.x

1
推荐指数
1
解决办法
2159
查看次数

标签 统计

python ×1

python-3.x ×1

tkinter ×1