- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我向 ButtonBox 添加了一些子项,我希望它们不是同质的。所以我调用了 ButtonBox.set_ Uniformeous(False) 并且大部分都有效。但是,当我将窗口大小调整为最小尺寸并出现垂直滚动条时,我发现 ButtonBox 下方有很多空白空间。我能够通过单独将每个子项指定为非同质调用 ButtonBox.set_child_non_osmoeous(child, True) 来解决此问题,同时还保留之前对 ButtonBox.set_osmoeous(False) 的调用。
那么我的问题是,为什么会发生这种情况?我将 ButtonBox 的布局设置为 EXPAND,所有空间都应该被占用。
我编写了一些测试代码来说明我在说什么。您可以尝试使用或不使用注释行来查看我提到的两种情况。
import sys
from gi.repository import Gtk
class Application(Gtk.Application):
def __init__(self):
super().__init__(application_id='com.stackoverflow.xor')
self.connect('activate', self.on_activate)
self.connect('startup', self.on_startup)
def on_startup(self, app):
self.window = Gtk.ApplicationWindow(application=app)
self.window.set_default_size(200, 200)
self.window.add(MainView(self))
def on_activate(self, app):
self.window.show_all()
class MainView(Gtk.ScrolledWindow):
def __init__(self, app):
super().__init__()
button_list = Gtk.ButtonBox(orientation=Gtk.Orientation.VERTICAL)
button_list.set_layout(Gtk.ButtonBoxStyle.EXPAND)
button_list.set_homogeneous(False)
button_list.get_style_context().remove_class('linked')
for i in range(4):
button = Gtk.Button()
label = Gtk.Label('\n'.join(['test test'] * (i + 1)))
button.add(label)
button_list.pack_start(button, False, False, 0)
#button_list.set_child_non_homogeneous(button, True)
self.add(button_list)
if __name__ == '__main__':
main_app = Application()
exit_status = main_app.run(sys.argv)
sys.exit(exit_status)
最佳答案
您的问题是当您将按钮添加到设置“Expand”为 False 的框中时。
button_list.pack_start(button, False, False, 0)
具有 EXPAND 布局的按钮框与其子项自行扩展不同。
编辑:这已在 #gtk+ 上讨论过,但对于此布局,子级都应该将 Expand 和 Fill 设置为 True。
关于python - ButtonBox 中的同质子级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30564512/
我正在尝试在 proton::connection 对象的工作队列中添加 proton::work 函数(打开一个新的发送者)。我有一个指向工作队列的指针,但我的问题是如何正确绑定(bind) ope
引用资料: 身份方案 Format: id:::: http://docs.vespa.ai/documentation/content/buckets.html http://docs.vespa.
我正在使用 C++ 实现 Qpid 质子客户端。 Qpid 版本为 0.12.2。 我运行默认容器: proton::container(myHandler).run(); MyHandler 是这样
我在自己的服务器上部署了一个 Proton CEP 实例,它有 2 个 CPU 和 4GB RAM。 让它工作一整夜后,CPU 使用率大幅增加,每个核心都达到 100%。正在执行的命令是: java
我想从服务总线读取订阅消息。我正在为 python 使用 qpid-proton 库。我正在通过此链接接收消息 Proton-Python-Example-Simple-Receive .我正在传递此
我是一名优秀的程序员,十分优秀!