Re: [gtk-list] notebooks and hboxes



Dan Kimberg wrote:
> 
> Hi.  I've been having some odd problems laying out widgets in a notebook,
> and I was wondering if there was an obvious solution or workaround I'm
> missing.  What I'm trying to do is have a notebook in which some of the
> widgets are in rows together (e.g., a textentry and a button side-by-side),
> but in which everything is pushed to the top (not spaced out vertically).  I
> thought the obvious solution would be to do something analogous to what
> works for windows -- i.e., set up the boxes and widgets as nonhomogeneous,
> non-expanding, etc., and use an hbox for each row that contains more than
> one widget.  However, these hboxes seem to want to expand no matter what.
> So the notebook page with the least amount of vertical widgets ends up
> widely spaced.  They don't do the same if I put them in a window without a
> notebook.  I've tried a few dozen combinations of various settings without
> any luck, so I figured I'd see if anyone else has figured out how to do
> this.
> 
> I'm using gtk+ 1.0.5.  Thanks for any help.
> 

Try to use a table and gtk_table_atach. Play with the setting for
gtk_table_atach. Bellow is a fragment from my program that is doing what
you want (if I've understud corect you :)).

  // append two pages to the notebook
  // page 1
  frame = gtk_frame_new (NULL);
  gtk_container_border_width (GTK_CONTAINER (frame), SPACING);
  gtk_widget_show (frame);
    
  label = gtk_label_new ("Run Settings");
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
  
  // add some widgets to the notebook page
  // first a table for the widgets
  table = gtk_table_new ( 4 + BOXES,2, false );
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_container_border_width (GTK_CONTAINER (table), 4*SPACING);
  gtk_table_set_row_spacings(GTK_TABLE(table), 4*SPACING);
  gtk_table_set_col_spacings(GTK_TABLE(table), 4*SPACING);
  gtk_widget_show (table);

  int row = 0;

  label = gtk_label_new ("Max. Cycles");
  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
  gtk_table_attach(GTK_TABLE(table), label, 0,1,row,row+1,
GTK_FILL,GTK_FILL, 0,0 );
  gtk_widget_show (label);

  maxCyclesEntry = gtk_entry_new();
  gtk_table_attach(GTK_TABLE(table), maxCyclesEntry, 1,2,row,row+1,
GTK_FILL,GTK_FILL, 0,0 );
  gtk_widget_show (maxCyclesEntry);

  row++;

  // add a separator
  separator = gtk_hseparator_new ();
  gtk_table_attach(GTK_TABLE(table), separator, 0,2,row,row+1,
GTK_FILL,GTK_FILL, 0, 4*SPACING);
  gtk_widget_show (separator);

  row++;

  // display some informations:
  label = gtk_label_new ("Current Cycle");
  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
  gtk_table_attach(GTK_TABLE(table), label, 0,1,row,row+1,
GTK_FILL,GTK_FILL, 0,0 );
  gtk_widget_show (label);

  currentCycleEntry = gtk_entry_new();
  gtk_entry_set_text( GTK_ENTRY(currentCycleEntry), "0");
  gtk_table_attach(GTK_TABLE(table), currentCycleEntry, 1,2,row,row+1,
GTK_FILL,GTK_FILL, 0,0 );
  gtk_widget_set_sensitive ( currentCycleEntry, false );
  gtk_widget_show (currentCycleEntry);

  row++;

  // add a separator
  separator = gtk_hseparator_new ();
  gtk_table_attach(GTK_TABLE(table), separator, 0,2,row,row+1,
GTK_FILL,GTK_FILL, 0, 4*SPACING);
  gtk_widget_show (separator);

Ionutz



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