我必须将文本小部件的选项卡大小设置为 4 个字符。当我做textwidget.config(tabs = ("4c","8c"))
我没有得到所需的结果。它的制表符很多,现在是 4 个字符。我在设置选项卡属性时做错了什么吗?另外,当我显示行号和列号时,我通过获取插入的索引来做到这一点,但是这里制表符被标记为一个字符,而不是我希望理想情况下的四个字符。有没有更好的方法来获取列号而不必处理选项卡的问题?
The 文档 http://www.tcl.tk/man/tcl8.5/TkCmd/text.htm#M-tabs对于 Tk 文本小部件-tabs选项提到 2c 的距离为 2 厘米。文档似乎没有说,但这使用了Tk_GetPixels http://www.tcl.tk/man/tcl8.5/TkLib/GetPixels.htm函数将选项值转换为距离,此处声明以下类型:
<none> : The number specifies a distance in pixels.
c : The number specifies a distance in centimeters on the screen.
i : The number specifies a distance in inches on the screen.
m : The number specifies a distance in millimeters on the screen.
p : The number specifies a distance in printer's points (1/72 inch) on the screen.
如果你想使用字符距离那么你应该使用字体测量 http://www.tcl.tk/man/tcl8.5/TkCmd/font.htm#M10使用为文本小部件定义的字体和合适的字符,例如m
or n
鉴于比例字体的字符具有不同的宽度。 Tk text widget -tabs 文档中给出了一个示例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)