Re: window resizing

On a usability note, wouldn't it be very anoying if the 'next' button
moves from place, because the window is auto resizing everytime?

This is not a solution ofcourse, but this was the first thing which
came to my mind. Maybe add a key shortcut as well?


On 10/6/07, Jaap Karssenberg <j g karssenberg student utwente nl> wrote:

Hmmm looks like "$window->set_policy()" should be available to set that
behavior [1]. However perl Gtk2::Window does not seem to have a binding
for this call. The C docs suggest to use set_resizable instead of
set_policy, but no mention there of any auto behavior. Anyone knows why
this call is missing ?




Laurent Klinger wrote:

  I have a simple application, whose toplevel window has the following
structure :

 |    [Image]                |
 ||            [Next] [Quit]||

When it starts, it displays an image. Upon clicking on the 'Next'
button, another image is read and displayed.

When the second image displayed is larger than the first, everything
resizes nicely to accomodate. However, when the second image is smaller
than the first, the window does not shrink: [Image] has some empty
space on both sides, while the HBox has some empty space below. I can
manually resize (downsize) the window, but it would be nicer if it
would fit tightly to its content by itself. How do you ask GTK to
adopt this kind of behaviour?

Thank you very much for your help,


#!/usr/bin/perl -w

use strict;
use Gtk2 -init;
use Glib qw/TRUE FALSE/;

my $image = undef;
my $fig = 1;

#===== create window
my $window = Gtk2::Window->new ('toplevel');
$window->set_resizable( TRUE );
$window->signal_connect( delete_event => \&Quit );

#===== add widgets
GetImage( $fig );

my $next_btn = Gtk2::Button->new( 'Next' );
$next_btn->signal_connect( 'clicked', sub{ GetImage( ++$fig ); } );
my $close_btn = Gtk2::Button->new_from_stock( 'gtk-close' );
$close_btn->signal_connect( 'clicked'  , sub{ Gtk2->main_quit; } ) ;

my $hbox = Gtk2::HBox->new( FALSE, 5 );
$hbox->pack_end( $close_btn, FALSE, TRUE, 5 );
$hbox->pack_end( $next_btn, FALSE, TRUE, 5 );

my $vbox = Gtk2::VBox->new(FALSE,0);
$vbox->pack_start( $image, FALSE, FALSE, 0 );
$vbox->pack_start( $hbox, FALSE, FALSE, 10 );

$window->set_position( 'center' );


sub GetImage
  my $id = shift;
  my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file( "fig${id}.png" );
  if ( defined $image ) {
    $image->set_from_pixbuf( $pixbuf );
  } else {
    $image = Gtk2::Image->new_from_pixbuf( $pixbuf );

gtk-perl-list mailing list
gtk-perl-list gnome org

gtk-perl-list mailing list
gtk-perl-list gnome org

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