For Programmers: Free Programming Magazines  


Home > Archive > Tcl > January 2008 > Button doesn't have to resize when the screen resolution is changed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Button doesn't have to resize when the screen resolution is changed
alexg

2008-01-25, 4:39 am

Hello
I don't know exactly if this is possible, so I have to ask this. I
have an application which holds 5 frames and each one of them holds
buttons. Each frame has its own width and height expressed in cm (like
-width 2.76c). I made some tests only with frames and they tend to
keep their width and height on a changed screen resolution. So, for
example, if I'm having a screen res of 1280x1024 and I'm starting the
application, frames are having the size as specified in code. I'm
closing the application, then I change the resolution to 640x480,
start the application and frames tend to keep their size. All good by
now.
But, if I add buttons in frames, problems start to appear. As I
understood from manual, the width and height of buttons express the
size of the text. But I want to set the size of these buttons in cm.
So I created images for each button, because I saw that when a button
holds an image, the width and height may receive input which are
accepted by Tk_GetPixels. So I set the width and height of buttons
like this:
-width 0.47c -height 0.30c
So, I did retest the changing of screen resolution and I observed the
following situation:
- the width and height of buttons tend to keep the size specified in
code (w=0.47 and h=0.30, at least near these values)
- but, the images from the buttons are not resizing.
Is there any possibility to code a button to holds its size when the
screen resolution is changed? I'm specifying that what I need is to
keep its size in the following scenario:
- resolution set on 1280x1024 (for example)
- application starts
- frames and buttons are having the size in cm (computed by tk)
specified in code
- application stops
- resolution set on 640x480 (again, for example)
- application starts
- i need that the frames and buttons try to keep the same size in cm
(at least, near the values specified in code)

I'm sorry for this sooo long post, but I tried to specify as accurate
as I could my situation
Thank you for your time and for the answers
Schelte Bron

2008-01-25, 7:26 pm

alexg wrote:
> But, if I add buttons in frames, problems start to appear. As I
> understood from manual, the width and height of buttons express
> the size of the text. But I want to set the size of these buttons
> in cm. So I created images for each button, because I saw that
> when a button holds an image, the width and height may receive
> input which are accepted by Tk_GetPixels.


If I understand correctly you have a problem, and a work-around for
the problem which also has a problem. It's kind of funny to me how
the whole thread sofar focuses on solving the problem with the
work-around instead of finding a solution for the initial problem.

What you can do is use the sizing properties of a frame to control
the size of the text button by placing the button in a frame:

# Create a helper frame with the desired size
frame .b_frame -width 4c -height 1c
# Create the button after the frame so it won't be obscured
button .b -text Quit -command exit
# Make the button the size of the helper frame
place .b -in .b_frame -relwidth 1 -relheight 1
# Put the button in the GUI (can also use grid)
pack .b_frame


Schelte.
--
set Reply-To [string map {nospam schelte} $header(From)]
Schelte Bron

2008-01-30, 7:46 pm

alexg wrote:
> The buttons are trying to keep their sizes now(through their
> helper frames) when the resolution is changed, but the font don't
> want to resize. I'll see what I can do about this, maybe a hack
> around fonts. Do you have any hint for this too? :)


I always understood that fonts will adapt to the display resolution
if they are specified in points (positive sizes) and not in pixels
(negative sizes). It even says so in the font manual page: "Sizes
should normally be specified in points so the application will
remain the same ruler size on the screen, even when changing screen
resolutions or moving scripts across platforms."


Schelte.
--
set Reply-To [string map {nospam schelte} $header(From)]
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com