Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Gtk2::Dialog window size

by smittypaddler (Acolyte)
on Jun 30, 2016 at 15:49 UTC ( [id://1166938]=perlquestion: print w/replies, xml ) Need Help??

smittypaddler has asked for the wisdom of the Perl Monks concerning the following question:

How do I set the dialog window size so the entire title is displayed. set_size_request wants pixels, and I don't know how to get $title size in pixels. Here's my code:
$title=($answer eq $Answer) ? "Yes" : "No, s/b $Answer"; $dialog=Gtk2::Dialog->new($title,$parent, [qw/modal destroy-with-parent/], 'ok' => 'ok', ); $response=$dialog->run; $dialog->destroy;

Replies are listed 'Best First'.
Re: Gtk2::Dialog window size
by james28909 (Deacon) on Jun 30, 2016 at 19:14 UTC
    Try with this:
    $dialog->set_default_size ($width, $height); # or #$dialog->set_default_size (700, 400);
    I, personally, would also make the window non-resizable as well.
      set_default_size needs sizes in pixels. I had tried $dialog->set_size_request(500,-1), which worked, sort of. I know the size of my title in characters, but I don't know the width of the font used, so I can only guess at the required width in pixels, hence the 500. If my title is e.g. "No, whatever" I need something that will tell me how many pixels is equivalent to length("No, whatever").
Re: Gtk2::Dialog window size
by Anonymous Monk on Jun 30, 2016 at 22:15 UTC

    How do I set the dialog window size so the entire title is displayed.

    Titles are often clipped, so if that information is important, include it again inside the dialog

      I solved my problem with this, which granted is simple, but I still think there should be a strait forward one-statement way of determining text size in pixels:
      $title=($answer eq $Answer) ? "Yes" : "No, s/b $Answer"; $dialog=Gtk2::Dialog->new($title,$parent, [qw/modal destroy-with-parent/], $title => 'ok', );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1166938]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found