Re: vertical size of buttons



While the solution presented below is a correct answer to the problem,
it is generally not recommended that you use set_usize to set the size
of the widget.  Doing so prevents GTK from adjusting the size if
necessary (for example, a user might have a GTK style set the font to
really big because of eyesight problems, and such a change might prevent
the full text from appearing).  I would recommend one of two other
solutions.

First, you could use the border_width method to set a border around the
button, which will give you a small gap surrounding the entire widget.

Second, and almost certainly the better way to do this, put a vertical
packing box inside the horizontal packing box, and then insert the
button in the vertical packing box.  This way, the appearance of the
button is very flexible and easily adjusted.

Of course, if you know your users *very* well (such as you being the
only one) then any solution is acceptable.  But if not, I recommend that
you use an additional packing box (with the appropriate constraints so
that it looks good) and let GTK manage sizes for you.


-- 
Stephen Wilhelm
    See my Gtk-Perl Tutorial:
    http://personal.riverusers.com/~swilhelm/gtkperl-tutorial/


On Fri, 2002-05-03 at 09:19, John McDermott wrote:

Hi,
The buttons fill the box because that is the default behavior (there has
to be one).  If you want to change their size, use set_usize like this:
$DataBaseButton->set_usize(100,50); # args are x,y

HTH
--john

Subject: vertical size of buttons
From: Peter Jay Salzman <p dirac org>

hello all,

for some reason, my buttons are deciding to fill up their containing
hbox in the vertical direction.

i use the following routine to make buttons next to text entry widgets:

  $MainHBox->pack_start($LeftMainVBox, $false, $false, 0);
  ...
  $tmpHBox = new Gtk::HBox($false, 0);
  my $DataBaseEntry = new Gtk::Entry();
  FramePacker($DataBaseEntry, "Database", $tmpHBox);
  my $DataBaseButton = MakeButton("Database", $tmpHBox, "DataBaseClick");
  $LeftMainVBox->pack_start($tmpHBox, $false, $false, 0);

  sub MakeButton {
     my ($label, $PackingBox, $callback) = @_;
     my $widget = new Gtk::Button($label);
     $widget->signal_connect("clicked", $callback);
     $PackingBox->pack_start($widget, $true, $false, 1);
     return $widget;
  }

  sub FramePacker {
     my $widget = shift;
     my $label = shift;
     my $packingbox = shift;
     my $frame = new Gtk::Frame($label);
     $frame->add($widget);
     $packingbox->pack_start($frame, $true, $true, 0);
  }

the buttons themselves fill the entire hbox that i pack them into.  so
an hbox that contains a text entry and a button looks like:

   ----------------------------------------------------------
        | -----------------------------------      -----------   |
        | |                                 |      |         |   |
        | |   Text Entry                    |      |Click Me |   |
        | |                                 |      |         |   |
        | -----------------------------------      -----------   |
   ----------------------------------------------------------

and (you have to take my word for it) it looks very unnatural.  what i
*want* to happen is:

   ----------------------------------------------------------
        | -----------------------------------                    |
        | |                                 |      -----------   |
        | |   Text Entry                    |      |Click Me |   |
        | |                                 |      -----------   |
        | -----------------------------------                    |
   ----------------------------------------------------------

can someone explain why the buttons are deciding to fill up the hbox in
the vertical direction?


-- 
John McDermott, Writer and Consultant
J-K International, Ltd.
V +1 505/377-6293  F +1 505/377-6313
jjm jkintl com
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list






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