gtk - 如何在 Glade3 中将子级添加到 StatusBar?

标签 gtk python-3.x glade

在 GTK2 中,StatusBar 只是一个类似于 HBox 的简单容器。当我尝试将子小部件添加到状态栏时,Glade 3 (gtk3) 现在会显示此消息:

Widgets of type Status Bar need placeholders to add children.

什么是占位符?

我更喜欢完全在 Glade 中构建 UI,但是如果这不再起作用,那么在代码中构建它也可以。我通过 GObject 内省(introspection)使用 Python 3.2 和 Gtk。

最佳答案

在 Gnome 3 中,状态栏不再是容器;它们更像是一堆消息。要显示消息,请获取一个新的上下文 id 并将消息推送到与状态栏关联的消息堆栈中:

context_id = statusbar.get_context_id("progress_message")
statusbar.push(context_id, "Almost done...")

或者
statusbar.push(1, "Almost done...")

要再次删除该消息,请使用 statusbar.pop(1) .因此,在状态栏中不再有进度条或图像之类的东西。

另见:GtkStatusbar at the Gnome Dev Center

关于gtk - 如何在 Glade3 中将子级添加到 StatusBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8726466/

相关文章:

Python:将字典存储在多个 json 文件中

基于Linux的嵌入式实时显示系统QT或GTK

Python + pygtk 从数据库生成复选框表

python - `ip = ipaddress.ip_address(args.ip)` 的 TCP 端口测试不准确

python 3, window 7 :ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

python - 如何使用 Glade 和 Gtk 获取动态标签条目

linux - 如果Linux(Ubuntu)安装或卸载了任何其他程序,如何获取程序事件?

haskell - 如何将 Netpbm 图像转换为 Gtk pixbuf(在 Haskell 中)?

python - 从林间空地创建 Gtk.ApplicationWindow

statusbar - 在 Glade3 中添加 Gtkstatusbar