python - 文本小部件中的 TAB 键空间计数
问题描述
在tkinter
库Tab中将 +8 空间放入Text()
小部件。
如何更改空格数?
我的tkinter
代码:
from tkinter import *
win = Tk()
txt = Text()
txt.pack()
win.mainloop()
.
解决方案
我从 Python/Tkinter 对您的代码进行了此更改 :如何将文本小部件内容设置为变量的值?
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()
推荐阅读
- javascript - 如何使用 jQuery .css() 使用多个背景的堆叠顺序
- javascript - 使用 await 解析云代码 js 会引发语法错误
- c# - 将 CPU Parallel.For 转换为 GPU Gpu.For
- r - 如何修复 R 中损坏的日期?
- c# - WPF 中不规则形状项目的命中测试
- python - Keras 中的预处理功能不起作用
- excel - 如果单元格在同一列中具有相同的值
- javascript - 在锚点上触发 click() 命令时出现“递归过多”错误
- ms-access - MS访问查询从字符串中提取9位数字
- python-3.x - 如何生成从范围中的第一个值开始的列表?