CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Perl Tk width and height of string.

 



PapaGeek
User

Mar 16, 2014, 1:47 PM

Post #1 of 3 (4709 views)
Perl Tk width and height of string. Can't Post

Perl Tk has methods:

Code
$height = $widget->reqheight; 
$width = $widget->reqwidth;


To get the width and height of a widget or label (string) “AFTER” the application has finished drawing everything.

Code
” When the widget is first created, width will return a 1 until  
the application has finished drawing everything. After that,
it will return the actual width of the widget.”


Is there a way to get the width and height of various strings before anything is drawn so the program can determine the geometry of the page “BEFORE” it is drawn?

If I’m creating multiple buttons with user defined text and I want all the buttons to be the same size, I need to know the size of each text string before I create the button widgets.


PapaGeek
User

Mar 17, 2014, 12:24 AM

Post #2 of 3 (4692 views)
Re: [PapaGeek] Perl Tk width and height of string. [In reply to] Can't Post

After more thought, what does everyone think of this idea?

Create a “fake” window that contains all of the widgets that I plan to use throughout the other windows, buttons, labels, date entries, etc.

Use this window to get the geometry of the widgets and then do a $window->withdraw(); and never display the window.

When I get to a real window and have a list of buttons that I want to be the same size I can just get the maximum width and height of the widgets in the list and use that as the geometry for all of them.

What does everyone think of creating a fake window for this reason?


(This post was edited by PapaGeek on Mar 17, 2014, 12:25 AM)


FishMonger
Veteran / Moderator

Mar 17, 2014, 8:45 AM

Post #3 of 3 (4685 views)
Re: [PapaGeek] Perl Tk width and height of string. [In reply to] Can't Post

Sounds like a very funky and weird design.

Additionally, IMO, using buttons for menu items is also an odd design choice. It seems to me that you might be stuck in the mindset of a web programmer where buttons are often used like this, but to me it's a weird design choice for a GUI.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives