Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sizing TK widgets

Status
Not open for further replies.

tcldude

Technical User
Feb 14, 2007
3
0
0
IL
Hi.
I'm writing TCL/TK GUI but I've encoutered 2 problems:

1. I have a series of buttons - each one in a different row and each one has its own text.
Since the text is different per button, the size of the buttons are different - how can I force that the size of all the buttons will be the same?
Illustration:

-------------
button one
-------------

---------------------
button two is longer
---------------------

2. Another problem is that sometimes even though I specify widgets (not necessarly buttons) one after the other in the same column (e.g row 4 column 1 & row 5 column 1), they are misaligned (there is an offset in the X axis between them).
Illustration:
--------
button 1
--------

-----------
button 2
-----------

How can I solve it?
Help would be much appreciated,
Adi.
 
Your first question:
Widget options -width and -height
Database Class: Width
Specifies a desired width for the button. If an image or bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in characters. If this option isn't specified, the button's desired width is computed from the size of the image or bitmap or text being displayed in it.
Database Class: Height
Specifies a desired height for the button. If an image or bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in lines of text. If this option isn't specified, the button's desired height is computed from the size of the image or bitmap or text being displayed in it.

Your second question:
It sounds like you're using the grid geometry. I find I have more control with pack. Anyway, post some of your code and let's have a look.


_________________
Bob Rashkin
 
Hi.
Thanks for your answer.
I indeed use the grid command.
A sample code:
grid .netlist -in . -row 1 -column 1
grid .netlist.label -in .netlist -row 1 -column 1
grid .netlist.path_label -in .netlist -row 1 -column 2
grid .netlist.path_name -in .netlist -row 1 -column 3
grid .netlist.file_label -in .netlist -row 1 -column 4
grid .netlist.file_name -in .netlist -row 1 -column 5
grid .netlist.save -in .netlist -row 1 -column 6
grid .top -in . -row 2 -column 1
grid .top.label -in .top -row 1 -column 1
grid .top.module_name -in .top -row 1 -column 2
grid .top.save -in .top -row 1 -column 3

The GUI looks like:

--------------------
first netlist widget
--------------------

----------------
first top widget
----------------

Thank you in advance,
Adi.
 
I assume you've already defined the frames, "netlist" and "top".
No matter what geometry manager you use, the widget definition statements are where you would use the -width and -height modifiers.

From the code you posted, it looks like the labels should align. I can only conclude that you have specified something in the frame (or widget) definitions that is causing the offset. Can you post those?



_________________
Bob Rashkin
 
Here's another thought: row and column numbers start with 0.


_________________
Bob Rashkin
 
In your grid statement try using -sticky

grid .netlist -in . -row 1 -column 1 -sticky news

I use this and every button in that column has the same width regardless of the text length of the buttons. The 'news' stretches it out to fill the space allotted for the column (at least that's what I think it does).

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top