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

Re: problems with table and labels



J.Blunck@tu-harburg.de wrote:
> 
> I want to add 2 labels and 2 entries to a table. The problem is that
> the labels are not left aligned. How can I do that ?
> 

Put the labels in an alignment widget and then attach the alignment to
the table. Here's an example:

GtkWidget *add_label_to_table( GtkWidget *table, gint left, gint top,
gchar *str )
{
  GtkWidget *label;
  GtkWidget *align;

  align = gtk_alignment_new( 1, 1, 0, 0 );
  label = gtk_label_new( str );
  gtk_widget_show( GTK_WIDGET(label) );
  gtk_misc_set_padding( GTK_MISC( label ), 5, 0);
  gtk_container_add( GTK_CONTAINER(align), label );
  gtk_widget_show( GTK_WIDGET(align) );
  gtk_table_attach_defaults( GTK_TABLE(table), align, left, left+1, top,
top+1 );

  return label;
}

This will right align the label. Change the arguments to
gtk_alignment_new() to get your desired affect.

Ted Roth


-- 
Email: <troth@netmagic.net>  Web site: <http://www.netmagic.net/~troth>
------------------------------------------------------------------------
"Of all the things I miss from veterinary practice, puppy breath
is one of the most fond memories!"
                                          --- Dr. Tom Cat



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