文本小部件中的选项卡键空间计数

2024-10-03 17:21:05 发布

您现在位置:Python中文网/ 问答频道 /正文

tkinter选项卡中将+8空间放入Text()小部件

如何更改空间数

我的tkinter代码:

from tkinter import *

win = Tk()

txt = Text()
txt.pack()

win.mainloop()


Tags: 代码textfromimporttxt部件tkinter空间
1条回答
网友
1楼 · 发布于 2024-10-03 17:21:05

我从对您的代码进行了此更改 Python/Tkinter: How to set text widget contents to the value of a variable?

from tkinter import *

win = Tk()

txt = Text()
txt.pack()

def tab(arg):
    print("tab pressed")
    txt.insert(INSERT, " " * 4) #this number is where you set the amount of spaces to add per tab
    return 'break'

txt.bind("<Tab>", tab)

win.mainloop()

相关问题 更多 >