![](/img/trans.png)
[英]get() method of Tkinter text widget - doesn't return the last character
[英]Tkinter Text widget scroll bar doesn't show the first character
我正在嘗試為 tkinter 中的文本小部件制作水平滾動條,它可以工作,但是當文本很長時,它開始不顯示第一個字符的某些部分,直到它完全消失。
那是我的代碼:
scrollbar = Scrollbar(window, orient='horizontal')
scrollbar.pack(side=BOTTOM, fill=X)
text = Text(window, font=("Calibri", 40), xscrollcommand=scrollbar.set)
text.tag_configure("center", justify='center')
text.insert("1.0", "222222222222222222222222222222")
text.tag_add("center", "1.0", "end")
text.config(width=100, height=1, background="#f2f2f2", borderwidth=0, state='disabled', wrap='none')
text.pack(pady=24)
scrollbar.config(command=text.xview)
我改變root.resizable(280, 20)
試試這個:
from tkinter import*
root = Tk()
root.resizable(280, 20)
root.title("Scrollbar Widget Example")
scrollbar = Scrollbar(root, orient='horizontal')
scrollbar.pack(side=BOTTOM, fill=X)
text = Text(root, font=("Calibri", 40), xscrollcommand=scrollbar.set)
text.tag_configure("center", justify='center')
text.insert("1.0", "222222222222222222222222222222")
text.tag_add("center", "1.0", "end")
text.config(width=30, height=1, background="#f2f2f2", borderwidth=0, state='disabled', wrap='none')
scrollbar.config(command=text.xview)
text.pack(pady=24)
root.mainloop()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.