在 PyGTK/GTK 中动态添加/删除笔记本页面
如何即时刷新笔记本?
我有一个应用程序应该有不同数量的 根据底层模型中的数据进行页面。 为了 同步笔记本的外观 我想刷新它 每次从模型中添加/删除一行时。
我已经尝试过:
...
def get_pagebox(self, label)
...
return pagebox
def _reinit(self):
for child in self.notebook.get_children():
self.notebook.remove(child)
for label in self.get_labels():
self.notebook.append(self.get_pagebox(label), label)
self.notebook.queue_draw_area(0,0,-1,-1)
...
它删除旧页面,但无法附加新页面。 可能是什么 问题是什么?您认为如何才能做到这一点?
How to refresh a notebook on the fly?
I have an application which is supposed to have various number of
pages according to the data in the underlying model. In order to
synchronize the appearance of the Notebook I'd like to refresh it
every time a row is added/deleted from the model.
I've tried this:
...
def get_pagebox(self, label)
...
return pagebox
def _reinit(self):
for child in self.notebook.get_children():
self.notebook.remove(child)
for label in self.get_labels():
self.notebook.append(self.get_pagebox(label), label)
self.notebook.queue_draw_area(0,0,-1,-1)
...
It removes the old pages, but fails to append new ones. What could be
the problem and how do you think this could be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来不错。 您是否尝试执行显式
添加后在小部件上显示()
?That looks fine. Did you try doing an explicit
show()
on the widgets after adding them?添加新页面后,您应该在笔记本上调用
show_all()
。 GTK+ 创建的所有小部件最初都是隐藏的。queue_draw_area
调用应该不是必需的。You should just call
show_all()
on the notebook after adding the new pages. All widgets created by GTK+ are initially hidden. Thequeue_draw_area
call shouldn't be necessary.