简体   繁体   中英

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

This a screenshot from a Tkinter Listbox in a program I'm writing:

问题的屏幕截图

Why does the \\t character show up as a black bar?

On a Mac it shows up normally (as a tab), but on Windows I get this. I think it might have something to do with character encoding because strings are unicode by default in OS X but not Windows?

I tried writing the tab as chr(9) instead of \\t , but it didn't help.

On Windows, the tab character is probably not interpreted by the Listbox rendering code but on Mac, it is. 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. Maybe this is part of the OS's font rendering code (which is more powerful on the 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 ...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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