Find the answer to your Linux question:
Results 1 to 5 of 5
Hmm, the button btnQuit;Is not showing up on the main window.. Can somebody explain why?? Code below.. I don't want no functionality yet, just displaying it on the form.. Code: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    34

    GTK+ Button not showing.


    Hmm, the button btnQuit;Is not showing up on the main window.. Can somebody explain why?? Code below.. I don't want no functionality yet, just displaying it on the form..
    Code:
    #include <stdio.h>
    #include <gtk/gtk.h>
    
    static gboolean kill_window(GtkWidget *widget, GdkEvent *event, gpointer data)
    {
      gtk_main_quit();
      return FALSE;
    }
    
    
    int main(int argc, char * argv[])
    {
      
      gtk_init(&argc, &argv);
      
      GtkWidget *window;
      GtkWidget *quitBtn;
      
      
      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      
      gtk_window_set_title(GTK_WINDOW(window), "App 1");
      gtk_window_set_default_size(GTK_WINDOW(window), 800, 700);
      gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
      quitBtn = gtk_button_new_with_label("Quit");
      gtk_widget_set_size_request(GTK_WIDGET(quitBtn), 125, 25);
      gtk_widget_show_all(window);
      
      g_signal_connect(window, "delete_event", G_CALLBACK(kill_window), NULL);
    
      
      
      gtk_main();
     
      
      
      return 0;
      
    }

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,211
    I think you forgot to put the button in the window. At some point you need to call gtk_container_add().
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    34

    GTK+ Buttons.

    Quote Originally Posted by hazel View Post
    I think you forgot to put the button in the window. At some point you need to call gtk_container_add().
    Thankks a lot, =). gtk_container_add(GTK_CONTAINER(quitBtn)); I swear, there's something that goes after (quitBtn) but having a memory lapse.

  4. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,211
    Maybe this will refresh your memory.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  5. #5
    Just Joined!
    Join Date
    May 2008
    Posts
    34
    Quote Originally Posted by hazel View Post
    Maybe this will refresh your memory.
    Actually, I got it showing, but it appears to be taking up the entire window, I don't want that to happen.. I even tried to put it in a Layout, it fills up the entire Y Axis, but only a little bit of the X Axis.. Hmm, not sure what to do about this now.. I even went to gtk.org -> Documentation, went by that, still same thing.. I even tried the gtk_fixed_put and I was getting errors, and it still filled up the entire window.. Hmm.. What to do, what to do, LOL..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •