python - 用文本小部件编写的行间距
问题描述
如果有人非常了解 tkinter,他会得到我的确切要求。
我有一个代码,我试图查看该选项的影响,或者您可以说名为spacing2的文本小部件的关键字。我想知道为什么使用这个选项。
from tkinter import *
root = Tk()
txt = Text(root,spacing2 = 100)
txt.pack()
root.mainloop()
帮助我知道为什么这里使用了这个选项或名为spacing2 的关键字。
解决方案
根据文档(例如这里)
此选项指定当逻辑换行时在显示的文本行之间添加多少额外的垂直空间。默认值为 0。
这是一个非常明显的例子:
from tkinter import Tk, Text
root = Tk()
txt = Text(root, spacing2=10, wrap='word', width=10)
txt.insert('1.0', 'This is a very long line that is wrapped.')
txt.pack()
txt2 = Text(root, wrap='word', width=10)
txt2.insert('1.0', 'This is a very long line that is wrapped.')
txt2.pack()
root.mainloop()
推荐阅读
- c++ - 根据颜色范围创建蒙版
- python - 根据日期绘制数据集中的条目数
- authentication - 尝试登录 prestashop 管理面板时遇到两个错误
- reactjs - 从列表中获取数据
- xamarin.forms - Xamarin.Forms:带有 ContentView 的可重用错误视图,如何设置图像源?
- python - 为什么这个 Beautiful Soup 代码不能解析我的目标文本?
- .net-core - 在 ef core 中的表设置中添加另一个外键
- azure - 将子域重定向到 Azure 应用服务中的子目录
- sql - 在连接条件下从同一个表中检索 2 个条目
- lotus-notes - (Domino Notes)如何将文档从原始 NSF 移动到另一个 NSF?