简体   繁体   English

我怎么能设置Gtk Notebook页面选项卡可扩展?

[英]How am I supposed to set a Gtk Notebook page tab expandable?

When I add a page to a Gtk.Notebook programatically, I can't find a way to set the tab to expand. 当我以编程方式将页面添加到Gtk.Notebook时,我找不到将标签设置为展开的方法。 The property is available in Glade, so I know it can be done. 该物业在Glade有售,所以我知道它可以做到。 Here is a snippet using reorderable and detachable properties. 这是一个使用可reorderabledetachable属性的代码段。

#!/usr/bin/env python

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class GUI:
    def __init__(self):

        window = Gtk.Window()
        notebook = Gtk.Notebook()
        window.add(notebook)
        for i in range (4):
            label = Gtk.Label('label in page number ' + str(i))
            tab_label = Gtk.Label('page ' + str(i))
            notebook.append_page(label, tab_label)
            notebook.set_tab_detachable(label, True)
            notebook.set_tab_reorderable(label, True)
        window.show_all()
        window.connect('destroy', Gtk.main_quit)

app = GUI()
Gtk.main()

However, 然而,

notebook.set_tab_expandable(label, True)

fails with 失败了

AttributeError: 'Notebook' object has no attribute 'set_tab_expandable'

解决方案是:

notebook.child_set_property(label, 'tab-expand', True)

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

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