[英]How ro change a Tkinter ScrolledText widget's Scrollbar color?
[英]how to fix the position of scrollbar of scrolledtext widget in tkinter?
我想修復 tkinter 的滾動文本小部件的滾動條位置。我正在創建一個聊天機器人,在每條新消息之后都需要向下拖動滾動條以查看具有不良影響的對話。 這是滾動文本的代碼
self.conversation = ScrolledText.ScrolledText(self,
state='disabled',borderwidth=5,
highlightthickness=1,
bg='#15202b',fg='#16202A',
font=('Arial Bold',8))
self.conversation.grid(column=0, row=1, columnspan=2, sticky='nesw', padx=3, pady=3)
from tkinter import *
from tkinter import scrolledtext
root = Tk()
scroll_x = Scrollbar(root, orient="horizontal")
text = scrolledtext.ScrolledText(root, wrap=NONE)
text.config(xscrollcommand=scroll_x.set)
scroll_x.configure(command=text.xview)
text.pack(fill=X)
scroll_x.pack(fill=X)
for i in range(10000):
text.insert(END, str(i)+"\n")
text.see("end")
root.update()
root.mainloop()
您要查找的命令是 see("end")
text.see("end")
root.update()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.