As far as widgets resizing themselves, it is probably a matter of improper packing, and whether you have the homogeneous, spacing, expand, fill, padding settings correct for what behavior you want.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.