简体   繁体   English

Python:为什么制表符在Tkinter中显得奇怪?

[英]Python: Why does the tab character show up weird in Tkinter?

This a screenshot from a Tkinter Listbox in a program I'm writing: 这是我正在编写的程序中的Tkinter Listbox的屏幕截图:

问题的屏幕截图

Why does the \\t character show up as a black bar? 为什么\\t字符显示为黑条?

On a Mac it shows up normally (as a tab), but on Windows I get this. 在Mac上,它可以正常显示(作为选项卡),但是在Windows上,我可以看到它。 I think it might have something to do with character encoding because strings are unicode by default in OS X but not Windows? 我认为这可能与字符编码有关,因为默认情况下,字符串在OS X中是unicode而不是Windows?

I tried writing the tab as chr(9) instead of \\t , but it didn't help. 我尝试将选项卡写为chr(9)而不是\\t ,但这没有帮助。

On Windows, the tab character is probably not interpreted by the Listbox rendering code but on Mac, it is. 在Windows上,制表符可能不是由Listbox呈现代码解释的,而在Mac上则是。 Hence, the difference. 因此,差异。 But I'm unsure about this since, IIRC, Tkinter uses its own rendering code so it should render the same on all platforms. 但是我不确定,因为IIRC,Tkinter使用自己的渲染代码,因此应该在所有平台上渲染相同的代码。 Maybe this is part of the OS's font rendering code (which is more powerful on the Mac). 也许这是OS字体渲染代码的一部分(在Mac上更强大)。

It's not a problem of encoding since the tab character is the same on all encodings (well, with the exception of EBCDIC but you're not on a mainframe, so ...) 这不是编码的问题,因为制表符在所有编码上都是相同的(嗯,除了EBCDIC以外,但您不在大型机上,所以...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM