The Tkinter Text control how to wrap text?

There python code:

window = tk.Tk()
t = tk.Text(window2, height=15, width=65)
button = tk.Button(window,text='获 取 IP', command=getIP,width=15, height=2)

def getIP():
	# randomIP()的作用是从数据库获取一个ip地址 
    IP = t.insert('end',randomIP())

After running like this:
Here Insert Picture Description

Obviously, ip address stick together if we are to read once every ip on a new line, it would only need to add the statement: t.insert(tk.INSERT, '\n')to

As follows:

window = tk.Tk()
t = tk.Text(window2, height=15, width=65)
button = tk.Button(window,text='获 取 IP', command=getIP,width=15, height=2)

def getIP():
	# randomIP()的作用是从数据库获取一个ip地址 
    IP = t.insert('end',randomIP())
    t.insert(tk.INSERT, '\n')

Modifying effect after:
Here Insert Picture Description

Published 208 original articles · won praise 841 · Views 1.21 million +

Guess you like

Origin blog.csdn.net/baishuiniyaonulia/article/details/101553910