0

I have a question regarding window and button implementation. If I have a toolbar set up, and I have a button on it, is it possible to get it to open a window right within the program? I mean like open up a different section of the program much like the function, notepad1, would do? Or could I get it to imitate the behavior of what the system settings do, where it opens a window completely within the same window? If you can help, I appreciate it. I'm working with the default glade file if that helps anyone.

Compt
  • 468
  • 3
  • 10

1 Answers1

1

I'm doing this in my App also. I achieved it by doing something similar to the following:

In your main window get a reference to the widget you want to use as your parent. It must be a derivative of GtkContainer (such as GtkBox). In my instance I did something like the following in my class constructor:

self.itemAsMyContainer = self.builder.get_object("name_of_object_id")

I then used glade to create another, separate ui file with a GtkContainer derivative such (in my case GtkBox) as its top level object, and then modified its Class name in a similar way to how quickly does it. I then created a separate class for it in a similar way to _lib/Window.py in the quickly template. Once that was done I could simply instantiate this new class and attach it to my referenced Container with a piece of code like:

self.my_sub_ui = MySexyGtkContainerSubClass()
self.itemAsMyContainer.pack_start(self.my_sub_ui)

I believe this same approach is possible with another window but you might have to unparent it. See this question for more info on that here

  • Thanks man, it would have taken me quite a while to find that lol. Have you tried adding the Ambiance theme (on a toolbar/notepad) to your program? I used the code "self.viewport3 = self.builder.get_object("viewport3") but now the problem I am having is that the text is white/inverted (ie: the label "ubuntu" used to be black text, now it is an inverted white). context = self.viewport3.get_style_context() context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)" – Compt Jun 28 '12 at 13:15