gpt4 book ai didi

rust - 如何将 "header"添加到笔记本的选项卡和页面部分?

转载 作者:行者123 更新时间:2023-12-03 11:36:00 25 4
gpt4 key购买 nike

我正在使用 gtk-rs创建一个 GUI。我想要如下图所示的东西:

A header above the tabs and page part of a notebook

但是,我找不到相对于笔记本的选项卡或页面部分定位标题的方法。即使在调查了原始 gtk 文档之后,我也找不到相对于笔记本的选项卡/页面部分的位置来定位小部件的方法。

我认识到我可以在笔记本上方放一个盒子并将我的小部件放在那里,但我不能以这种方式相对于笔记本放置小部件。如果有一种方法可以相对于笔记本本身的部件定位小部件,那就太好了。

最佳答案

听起来您正在使用 GtkNotebook , 这本质上比 GtkStack 更固执己见。 .我设法使用 GtkStack 制作了类似于您的原型(prototype)的东西和 GtkStackSidebar .它还需要添加一些 GtkSeparators。

prototype implemented in GTK+ 3

编码

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow">
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<placeholder/>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 1</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 2</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">page 3</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkTextBuffer" id="buffer1">
<property name="text" translatable="yes">placeholder text</property>
</object>
<object class="GtkTextBuffer" id="buffer2">
<property name="text" translatable="yes">placeholder text</property>
</object>
<object class="GtkTextBuffer" id="buffer3">
<property name="text" translatable="yes">placeholder text</property>
</object>
<object class="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="window_position">mouse</property>
<property name="default_width">440</property>
<property name="default_height">250</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">3</property>
<property name="margin_right">3</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
<property name="label" translatable="yes">TABS_HEADER</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStackSidebar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stack">stack1</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">3</property>
<property name="margin_right">3</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
<property name="label" translatable="yes">PAGE_HEADER</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStack" id="stack1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">buffer3</property>
</object>
<packing>
<property name="name">tab1</property>
<property name="title" translatable="yes">tab1</property>
</packing>
</child>
<child>
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">buffer1</property>
</object>
<packing>
<property name="name">tab2</property>
<property name="title" translatable="yes">tab2</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">buffer2</property>
</object>
<packing>
<property name="name">tab3</property>
<property name="title" translatable="yes">tab3</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

关于rust - 如何将 "header"添加到笔记本的选项卡和页面部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59481838/

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