Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:14:28+00:00 2026-05-13T19:14:28+00:00

I have one notebook with some tabs in my form and in this tabs

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:14:28+00:00Added an answer on May 13, 2026 at 7:14 pm

    If your page widgets never change, you can just pass them to your close_tab callback as the user data:

    # In create_tab_label
        closebtn.connect("clicked", self.close_tab, tab_child)
    
    def close_tab(self, button, tab_child):
        # Do something with self.page_num(tab_child)
    

    Update: The “page_num first argument must be gtk.Widget, not instacemethod” error you mentioned is because of this:

    label = self.create_tab_label(label,self.editor_access)
    

    It seems that you are passing a method as tab_widget. Note that you previously you ran editor_access to create the tab child widget:

    self.scrolled_window.add_with_viewport(self.editor_access())
    

    You need to store this widget so you can pass it as tab_widget, i.e.:

    editor_access = self.editor_access()
    self.scrolled_window.add_with_viewport(editor_access)
    
    # ...
    
    label = self.create_tab_label(label, editor_access)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one form with several text fields and one button. When i enter
I have one page design with scrolling eased by jquery using this code: function
I have one view with a form and I want when a button will
i have one database, and it contains some columns. My requirement is that how
I have one dropdownlist in my c# code behind page like `DropDownList dl =
I have a GtkNotebook that will contain at the very least, one permanent tab,
I have one spreadsheet already saved with some data, then in a new spreadsheet
I have one main form, and i want to dynamically change it's content, via
I have one text input and one button (see below). How can I use
(I have tagged this question as Python as well since I understand Python code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.