gpt4 book ai didi

Python Gtk3 条目设置占位符文本

转载 作者:太空宇宙 更新时间:2023-11-03 16:06:30 31 4
gpt4 key购买 nike

我尝试为 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.

尝试添加一个按钮并为其提供焦点,它应该可以工作。

关于Python Gtk3 条目设置占位符文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39729412/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com