简体   繁体   English

ttk.Entry:如果文本右对齐,则看不到尖号

[英]ttk.Entry: no caret visible if text is right justified

When ttk.Entry['justify']='right' is set the caret cannot be seen when the window shows up. 设置ttk.Entry ['justify'] ='right'时,在窗口出现时看不到插入符号。
Hence any user identifies the focused entry widget by seeing the caret, this is very weird. 因此,任何用户都可以通过查看插入符号来识别聚焦条目小部件,这很奇怪。
How can I make the caret visible? 如何使插入符号可见?
I tried with styles but it didn't work. 我尝试过样式,但是没有用。
This is my code so far: 到目前为止,这是我的代码:

from tkinter import *
from tkinter import ttk

root = root = Tk()
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)

style = ttk.Style()
style.configure('My.TEntry', padding=10)
entry = ttk.Entry(root, style='My.TEntry')
entry['justify'] = 'right'
entry.grid(column=0, row=0, sticky='nswe', padx=5, pady=5)

root.mainloop()

Can someone help? 有人可以帮忙吗?

EDIT: 编辑:
1.) I'm using Python 3.6.8 on Ubuntu 18.04 1.)我在Ubuntu 18.04上使用Python 3.6.8
2.) It's not a matter of focus. 2.)这不是焦点问题。 I can't see the caret even if the widget has focus. 即使窗口小部件具有焦点,我也看不到插入符号。

Maybe this could help you, simply do entry.focus(): 也许这可以为您提供帮助,只需执行entry.focus():

from tkinter import *
from tkinter import ttk

root = root = Tk()
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)

style = ttk.Style()
style.configure('My.TEntry', padding=10)
entry = ttk.Entry(root, style='My.TEntry')
entry['justify'] = 'right'
entry.grid(column=0, row=0, sticky='nswe', padx=5, pady=5)
entry.focus()

root.mainloop()

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

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