On Thu, Feb 18, 2010 at 10:54 AM, Alexander Kuleshov
<[email protected]> wrote:
>
> Hi to all. 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.
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
I would solve this using something like this:
Add a parameter to your close button connect:
closebtn.connect("clicked",self.close_tab, tab_child)
And add it to the close_tab function too:
def close_tab(self, sender, tab_child):
...
Now you can refer back to the tab in the close_tab function using tab_child.
To get the page number you could do something like:
self.notebook.page_num(tab_child)
Hope this helps you out
--
Simon Vermeersch
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/