7

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?

2
  • If this question is not specific to Ubuntu, then perhaps it should be migrated to StackOverflow. May 21, 2012 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 May 22, 2012 at 5:41

1 Answer 1

6

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()
4
  • 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. May 16, 2012 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. May 16, 2012 at 22:54
  • That's brilliant, thanks for following up! That works fine now. May 17, 2012 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. May 17, 2012 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .