如何获取(无子项)“tabs”在 pygtk 应用程序中
我面临着需要在 pygtk 应用程序中使用选项卡的问题。与 gedit 非常相似,但没有任何针对每个子组件的小部件内容。 我遇到过 gtk.Notebook,但这需要我把每个选项卡都有一个小部件,这是我不想要的。
原因是,我有一个小部件,但只想根据选择的选项卡更新其内容。
关于如何做到这一点有任何提示吗? 到目前为止,我的想法是为每个选项卡添加一些不可见的小部件,然后连接到 select-page
信号。我可以使用哪个小部件作为隐形小部件,或者是否有更好/替代的方法来实现我的目标?
I am facing the problem to need tabs in a pygtk app. Pretty much just like gedit has, but without any per-child widget content.
I’ve come across gtk.Notebook, but that requires me to put a widget for each tab, which I don't want.
The reason is, that I have one widget, but would only like to updates its content based on which tab is selected.
Any hints on how to do that?
My idea so far would be to just add some invisible widget for each tab and then connect to the select-page
signal. Which widget could I use as invisible widget, or is there a better/alternative way of achieving my goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
隐形小部件的想法是有效的。但不是使用
gtk.Invisible
(这只会崩溃),而是使用gtk.HBox()
或任何其他看起来空的东西。现在,如果我实际上想在选项卡内显示内容,我可以使用 reparent 将小部件移动到当前选项卡,如下所示。
The invisble widget idea works. But not with
gtk.Invisible
(this just crashes), but withgtk.HBox()
or any other thing that seems empty.Now if I want to display stuff inside the tab actually, I can use reparent to move the widget to the current tab like this.
您可以根据需要拥有全局小部件,每个选项卡一个,以便在选择选项卡时轻松访问它们。
然后连接到“切换页面”信号
并:
现在您有了带有当前所选页面标签的“名称”。只需测试它(如果名称==“订单”...)即可进行交互。
希望这对您有所帮助!
You can have global widgets, one per tab as you want, in order to access them easily when the tab is selected.
Then connect to the "switch page" signal
and :
Now you have "name" with the label of the currently selected page. Just test it (if name == "Orders" ...) to interact.
Hope this was of some help !