获取笔记本的页数
我有一个笔记本,表单中有一些选项卡,在这个选项卡中,我有用于关闭选项卡的标签按钮。我有这样的代码:
def new_tab(self,label): self.scrolled_window = gtk.ScrolledWindow()
self.add(self.scrolled_window)
self.scrolled_window.add_with_viewport(self.editor_access())
self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
label = self.create_tab_label(label,self.editor_access)
self.set_tab_label_packing(self.scrolled_window,False,False,2)
self.set_tab_label(self.scrolled_window,label)
self.saving = False
self.already_save.insert(0,self.get_n_pages() - 1)
label.show_all()
self.show_all()
return self.editor
def create_tab_label(self, title, tab_child): 框 = gtk.HBox() 标签 = gtk.Label(标题) closebtn = gtk.Button()
image = gtk.Image()
image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
closebtn.set_image(image)
closebtn.set_relief(gtk.RELIEF_NONE)
box.pack_start(label, True, True)
box.pack_end(closebtn, False, False)
self.show_all()
closebtn.connect("clicked",self.close_tab)
return box
如何获取用此按钮关闭的选项卡的 page_num ?
谢谢。
I have one notebook with some tabs in my form and in this tabs i have label-button for closing tab. I have code for this:
def new_tab(self,label):
self.scrolled_window = gtk.ScrolledWindow()
self.add(self.scrolled_window)
self.scrolled_window.add_with_viewport(self.editor_access())
self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
label = self.create_tab_label(label,self.editor_access)
self.set_tab_label_packing(self.scrolled_window,False,False,2)
self.set_tab_label(self.scrolled_window,label)
self.saving = False
self.already_save.insert(0,self.get_n_pages() - 1)
label.show_all()
self.show_all()
return self.editor
def create_tab_label(self, title, tab_child):
box = gtk.HBox()
label = gtk.Label(title)
closebtn = gtk.Button()
image = gtk.Image()
image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
closebtn.set_image(image)
closebtn.set_relief(gtk.RELIEF_NONE)
box.pack_start(label, True, True)
box.pack_end(closebtn, False, False)
self.show_all()
closebtn.connect("clicked",self.close_tab)
return box
How can i get page_num of tab which I closed with this button?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的页面小部件永远不会更改,您可以将它们作为用户数据传递给
close_tab
回调:更新: “page_num 第一个参数必须是 gtk.Widget,而不是 instacemethod “您提到的错误是因为这个:
您似乎正在将一个方法作为
tab_widget
传递。请注意,您之前运行了editor_access
来创建选项卡子小部件:您需要存储此小部件,以便可以将其作为
tab_widget
传递,即:If your page widgets never change, you can just pass them to your
close_tab
callback as the user data:Update: The "page_num first argument must be gtk.Widget, not instacemethod" error you mentioned is because of this:
It seems that you are passing a method as
tab_widget
. Note that you previously you raneditor_access
to create the tab child widget:You need to store this widget so you can pass it as
tab_widget
, i.e.:但 page_num 第一个参数必须是 gtk.Widget,而不是 instacemethod
But page_num first argument must be gtk.Widget, not instacemethod