Re: Gtk-WARNING** Atempting to add a widget with type..



On Fri, Apr 11, 2008 at 12:14 PM, Algirdas Jarockis
<algirdas jarockis gmail com> wrote:
> Hi all,
> im just starting with gktmm-2.4 and i have problem that i can not add
> drawing area object to window where menu is already added. The warning
> message at runtime:
> "Gtk-WARNING** Atempting to add a widget with type gtkmm__GtkDrawingArea to
> a gtkmm__GtkWindow, but as a GtkBin subclass a gtkmm__GtkWindow can only
> contain (...) it already contains a widget of type gtkmm__GtkVBox"
>
> Source of adding menus is from tutorial:
>
> http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-menus-examples.html
>
> .. and now i want to add a drawing area below the menu, and the source of
> drawing area is taken from tutorial too:
>
> http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-cairo-drawing-lines.html
>
> Now my main.cc file looks like this:
> int main(..)
> {
>   Gtk::main kit(..);
>   ExampleWindow win;
>   MyDrawingArea area;
>   window.add(area);
>   window.show();
>   Gtk::Main::run(win);
>   return 0;
>  }
>
> So main question is: how to add drawing area and menu that they will be
> shown together?
>
> Thanks for any suggestion.

A Gtk::Window can only hold a single child widget.  The example window
you reference above packs a VBox into the Window as it's only direct
child.  The VBox can hold multiple widgets, so you have to pack extra
widgets into the VBox (see in the ExampleWindow constructor where it
uses the m_Box.pack_start() method)

Hope that helps

-- 
jonner


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]