
-----------------------------------
apython1992
Sun Nov 28, 2010 5:43 pm

Problem with GTK+ Application
-----------------------------------
Hello, I am writing a GTK+ application as part of a final project at school.  To start, I wrote a toy application with simply a window that has one callback function, "on_window_destroy", just to work the kinks out before I add more widgets.  However, when I try to run the program, I get the following error message:


(test.exe:1236): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed

I am designing my application with Glade 3.6, which essentially builds an XML file that the C++ code parses, using GtkBuilder.

Here is the XML file created by Glade:

[code]


  
  
  
    GTK+ Text Editor
    
    
      
    
  

[/code]

And my C++ code:

[code]

#include 
#include 


void on_window_destroy(GtkObject *object, gpointer user_data)
{
    gtk_main_quit();
}

int main(int argc, char *argv[])
{
    GtkBuilder  *builder;
    GtkWidget   *window;

    gtk_init(&argc, &argv);

    builder = gtk_builder_new();
    gtk_builder_add_from_file(builder, "tutorial.xml", NULL);
    window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
    gtk_builder_connect_signals(builder, NULL);

    g_object_unref(G_OBJECT(builder));

    gtk_widget_show(window);
    gtk_main();

    return 0;
}
[/code]

I write my C++ code with codeblocks, and use the GNU GCC compiler, if that's relevant. Thank you in advance.

-----------------------------------
wtd
Mon Nov 29, 2010 2:19 am

RE:Problem with GTK+ Application
-----------------------------------
Any particular reason you hate yourself enough to use C++ for this?

Something like Vala would seem a better choice.

-----------------------------------
apython1992
Mon Nov 29, 2010 8:51 pm

Re: Problem with GTK+ Application
-----------------------------------
Trust me, I have used GTK with Python before, and I agree, using it with C++ is a bit of a pain by comparison.  However, as this is for a school project, I really have no choice but to use C++.

-----------------------------------
apython1992
Tue Nov 30, 2010 8:17 pm

Re: Problem with GTK+ Application
-----------------------------------
I found the problem, thanks.
