我有一个tkinter'Text'和'Scrollbar'正常工作.在我的文本窗口程序中,自动行将继续添加.因此,当插入新的文本行并且数据超出限制时,我希望文本和滚动条自动滚动到底部,以便始终显示最新的文本行.这该怎么做?
另外如何链接文本窗口和滚动条的滚动,因为当我滚动文本窗口时滚动不会发生.我观察到的唯一方法是拖动滚动条.
scrollbar = Tkinter.Scrollbar(group4.interior())
scrollbar.pack(side = 'right',fill='y')
Details1 = Output()
outputwindow = Tkinter.Text(group4.interior(), yscrollcommand = scrollbar.set,wrap = "word",width = 200,font = "{Times new Roman} 9")
outputwindow.pack( side = 'left',fill='y')
scrollbar.config( command = outputwindow.yview )
outputwindow.yview('end')
outputwindow.config(yscrollcommand=scrollbar.set)
outputwindow.insert('end',Details1)
Run Code Online (Sandbox Code Playgroud)
在程序中,函数output()将连续发送应滚动的数据
提前致谢,
如何在tkinter Entry
小部件中插入临时文本?
例如,我有一个Label User
,旁边有一个Entry小部件,它应该"Enter your username..."
在应用程序的开头有一些文本,并且在将游标放在Entry小部件上时,它应该删除"Enter your username..."
并允许用户输入数据.
这是我目前的代码:
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="User:")
label.pack()
entry = tk.Entry(root, bd=1, show="Enter your user name...")
entry.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我没有找到任何选项或方法来删除将游标放在Entry小部件上的数据.