Python Gtk3 条目集占位符文本
Python Gtk3 Entry set placeholder text
我尝试为 Gtk.Entry 设置灰色斜体占位符文本,但该条目为空。使用 Linux Mint 17.3 / Gtk 版本 3.10.8
这有什么问题:
#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
window = Gtk.Window()
box = Gtk.Box()
window.add(box)
entry = Gtk.Entry()
box.add(entry)
entry.set_placeholder_text("Filter")
window.show_all()
Gtk.main()
来自文档:
Note that since the placeholder text gets removed when the entry received focus, using this feature is a bit problematic if the entry is given the initial focus in a window. Sometimes this can be worked around by delaying the initial focus setting until the first key event arrives.
尝试添加一个按钮并给它焦点,应该可以。
我尝试为 Gtk.Entry 设置灰色斜体占位符文本,但该条目为空。使用 Linux Mint 17.3 / Gtk 版本 3.10.8
这有什么问题:
#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
window = Gtk.Window()
box = Gtk.Box()
window.add(box)
entry = Gtk.Entry()
box.add(entry)
entry.set_placeholder_text("Filter")
window.show_all()
Gtk.main()
来自文档:
Note that since the placeholder text gets removed when the entry received focus, using this feature is a bit problematic if the entry is given the initial focus in a window. Sometimes this can be worked around by delaying the initial focus setting until the first key event arrives.
尝试添加一个按钮并给它焦点,应该可以。