That's what I thought - improper packing.
I've burst a few brain cells trying to work out what the problem can be - I wonder if anyone can spot something obviously wrong?
The two scripts below are identical, except that the first writes some text to the window, and the second doesn't. The windows should be the same size, but the first is slightly wider.
#!/usr/bin/perl use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; # Create a window widget my $windowHandle = Gtk2::Window->new('toplevel'); $windowHandle->set_title('test1'); $windowHandle->signal_connect('delete_event' => sub { exit; }); $windowHandle->resize(600, 400); $windowHandle->set_position('center'); $windowHandle->set_border_width(10); # Create a VBox within the window my $vBox = Gtk2::VBox->new( FALSE, 6 ); $windowHandle->add($vBox); $vBox->set_border_width(0); # Create a textbuffer to contain the text my $buffer = Gtk2::TextBuffer->new(); # Create a textview using that textbuffer my $textView = Gtk2::TextView->new_with_buffer($buffer); $textView->set_editable(0); $textView->set_wrap_mode('GTK_WRAP_WORD'); # Create a scrolledwindow my $scrollWin = Gtk2::ScrolledWindow->new( undef, undef ); $scrollWin->set_policy ('never', 'automatic'); $scrollWin->set_border_width(0); # Add the textview to the scrolledwindow $scrollWin->add($textView); $vBox->pack_start($scrollWin, 1, 1, 0 ); # Put the window widget (and all its children) into the event queue $windowHandle->show_all; # Write text to the window; this causes it to expand. Comment out the +two lines below to see the window's normal size my $text = 'Hello mother! Hello father! It\'s a terribly beautiful day +; let\'s go outside and have some fun.'; $buffer->insert_with_tags_by_name($buffer->get_end_iter, $text); Gtk2->main; ##################################### sub delete_event { Gtk2->main_quit; return FALSE; }
#!/usr/bin/perl use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; # Create a window widget my $windowHandle = Gtk2::Window->new('toplevel'); $windowHandle->set_title('test1'); $windowHandle->signal_connect('delete_event' => sub { exit; }); $windowHandle->resize(600, 400); $windowHandle->set_position('center'); $windowHandle->set_border_width(10); # Create a VBox within the window my $vBox = Gtk2::VBox->new( FALSE, 6 ); $windowHandle->add($vBox); $vBox->set_border_width(0); # Create a textbuffer to contain the text my $buffer = Gtk2::TextBuffer->new(); # Create a textview using that textbuffer my $textView = Gtk2::TextView->new_with_buffer($buffer); $textView->set_editable(0); $textView->set_wrap_mode('GTK_WRAP_WORD'); # Create a scrolledwindow my $scrollWin = Gtk2::ScrolledWindow->new( undef, undef ); $scrollWin->set_policy ('never', 'automatic'); $scrollWin->set_border_width(0); # Add the textview to the scrolledwindow $scrollWin->add($textView); $vBox->pack_start($scrollWin, 1, 1, 0 ); # Put the window widget (and all its children) into the event queue $windowHandle->show_all; # Write text to the window; this causes it to expand. Comment out the +two lines below to see the window's normal size #my $text = 'Hello mother! Hello father! It\'s a terribly beautiful da +y; let\'s go outside and have some fun.'; #$buffer->insert_with_tags_by_name($buffer->get_end_iter, $text); Gtk2->main; ##################################### sub delete_event { Gtk2->main_quit; return FALSE; }
In reply to Re: gtk window sizes
by ronlewis
in thread gtk window sizes
by ronlewis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |