Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm writing a Python app that is tab-based, and I don't want it to have any additional pop-up dialogs.

I'd like to use the Gtk.AboutDialog functionality, but I don't want it to appear as a separate window. Rather, I'd like it to be embedded in one of the tabs of my Gtk.Notebook (which I've created with Glade).

I could not find any obvious way to do this. Does anyone have any pointers?

share|improve this question
    
If this question is not specific to Ubuntu, then perhaps it should be migrated to StackOverflow. –  Eliah Kagan May 21 '12 at 16:59
3  
The question is related to creating applications for Ubuntu, as are all those in the application-development tag. We recommend and encourage the use of Askubuntu as a resource for support for and by app developers developer.ubuntu.com/community –  David Planella May 22 '12 at 5:41

1 Answer 1

up vote 6 down vote accepted

You can move content area (GtkVBox) from GtkDialog to another GtkContainer, and then append to GtkNotebook - using gtk.Widget.reparent() method.

about = Gtk.AboutDialog()
about.set_program_name ("Application")
about.set_copyright ("Author")

box = Gtk.VBox ()
about.vbox.reparent (box)
notebook.append_page (box, Gtk.Label("About"))
about.destroy ()

With interface created in Glade, You must do simple trick for this solution. Create "About" tab in notebook with appended GtkBox (with id for example "about_box"). Then you can do something like this:

box = builder.get_object ("about_box")
about.vbox.reparent (box)

In some reasons Glade's GtkAboutDialog content area contains also GtkButtonBox. If You don't need this buttons simply destroy them:

about.action_area.destroy()

If You want only 'Credits' button, without 'Close' button, do something like this:

close_button = about.get_widget_for_response(Gtk.ResponseType.CANCEL)
close_button.destroy()
share|improve this answer
    
Thanks! Somehow, this does not seem to work, as it's not adding the tab apparently. I'm not sure whether it's due to the fact that I've initially created the notebook with Glade and then I try to add the tab in code. I haven't yet figured it out. –  David Planella May 16 '12 at 18:14
1  
After testing it, I can confirm that the code above works for any Gtk.Notebook created in code, but if the notebook has been created with Glade, it won't get the new tab appended. –  David Planella May 16 '12 at 22:54
    
That's brilliant, thanks for following up! That works fine now. –  David Planella May 17 '12 at 16:54
    
One final question: I can get rid of the whole action_area widget, but is there a way to only get rid of the close_button? the box being now embedded in a tab makes the button unnecessary. –  David Planella May 17 '12 at 18:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.