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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify the window size 2

Status
Not open for further replies.

subasn

Programmer
May 7, 2003
11
0
0
US
Hi All,

I'm a beginner for Tcl/Tk. Please let me know how to specify the window size that is displaying in the screen.

Regards,
Subas N.
 
If your goal is to size the toplevel window of your application, see the wm geometry at:
You can size the toplevel with:
Code:
  set width 400 ;# in pixels
  set height 300 ;# in pixels
  wm geometry . $widthx$height

If you want to size a widget like a textbox, you should see the description of the widget (and mainly the -width & -height options).
Code:
  set width 30 ;# in chars
  set height 10 ;# inchars
  text .t -width $w idth -height $height

From the Tk manual:
wm geometry window ?newGeometry?
If newGeometry is specified, then the geometry of window is changed and an empty string is returned. Otherwise the current geometry for window is returned (this is the most recent geometry specified either by manual resizing or in a wm geometry command). NewGeometry has the form =widthxheight±x±y, where any of =, widthxheight, or ±x±y may be omitted. Width and height are positive integers specifying the desired dimensions of window. If window is gridded (see GRIDDED GEOMETRY MANAGEMENT below) then the dimensions are specified in grid units; otherwise they are specified in pixel units. X and y specify the desired location of window on the screen, in pixels. If x is preceded by +, it specifies the number of pixels between the left edge of the screen and the left edge of window's border; if preceded by - then x specifies the number of pixels between the right edge of the screen and the right edge of window's border. If y is preceded by + then it specifies the number of pixels between the top of the screen and the top of window's border; if y is preceded by - then it specifies the number of pixels between the bottom of window's border and the bottom of the screen. If newGeometry is specified as an empty string then any existing user-specified geometry for window is cancelled, and the window will revert to the size requested internally by its widgets.

HTH

ulis
 
Hi Ulis,

Thanks for your concern.

Somehow I specified the size using the following statements.
. configure -height 250
. configure -width 280

Also I tried with the
set width 400 ;# in pixels
set height 300 ;# in pixels
wm geometry . $widthx$height

Where I got the following error.
Error in startup script: can't read "widthx": no such variable
while executing
"wm geometry . $widthx$height"

Also could you please tell me how to create a radio button with two options.

Thanks and Warm Regards,
Subas N.

Feel free to cantact me @ subas_n@yahoo.com

 
You called the variable "width" in "set width 400 ;# in pixels". Then you refer to it as "$widthx" in "wm geometry . $widthx$height". Pick one.

I don't know what you mean by options for a radiobutton. In the radiobutton, you specify a variable that takes a value when the button is selected. So you might do the following:

set val 0
radiobutton <rb-name> -variable val -value 1

then when the radiobutton is selected, the value of &quot;val&quot; changes to 1.


Bob Rashkin
rrashkin@csc.com
 
Sorry, the exact syntax is:
Code:
  wm geometry . ${width}x$height
This is the way to mixt text and variables.

ulis
 
Hi Bong,

Thanks for your help.

When I have two radio button, either of the button should be active. Meaning if I have four button, at any point of time only one button must be active. I meant all the buttons are mutually exclusive and also atleast one button must be active.

My concern is here how to grounp these four buttons.

Your help is most appreciated.

Hi Ulis,

Again thanks for tyour help.

Regards,
Subas N.


 
For the radiobuttons:
Code:
  foreach i {1 2 3 4}   {
    radiobutton .rb$i -text &quot;button $i&quot; -variable ::myvar -value value$i
    pack .rb$i
  }
  pack [label .l -textvariable ::myvar -bg white]
  .rb1 select
The magic is on the textvariable and the values.

Info at:

HTH

ulis
 
Hi Ulis,

Thanks for extreme help. Keep doing and let others get benifited by U

Regards,
Suabs N.
 
Hi
i have developed a small application
i want to automate that...
it is a text mode application [not a GUI]
it runs from c:program exe is &quot;bob.exe&quot;
could you please writee a script for me to automatemy logon and move to next screen.



My logon screen is :[dos application/text mode]

----------------------------------------------------
USERNAME [ ]
PASSWORD [ ]
ctrl+X [Exit System]
----------------------------------------------------

Ok well my problem is to send USERname and Password simoultaneously.and then press enter to go to next screen
i used command: send &quot;$user\t$pass\r&quot; but what happens is it's just giving both id & password in some place.not in the designated columns:SO Logon is not happening

How to do that so that i can go to next screen:
----------------------------
HAI WELCOME
opt[]
-----------------------

Looking fwd for you valuable suggestion

code i developed:

set user SYS
set pass PASS /** password **/
cd $env(HOME) /**change to c:\ **/
spawn -noecho cmd
send &quot;bob\r&quot; /senidnng application command ie bob.exe **/
expect &quot;Please enter your USERNAME&quot; /*1st screen mesage**/
send &quot;SYSMAN\t&quot;
expect &quot;and PASSWORD&quot;
send &quot;PASSWORD\r&quot;
expect &quot;Exit System&quot; /*want to go to next screen*/


Please help me.
 
set user USERID
set pass PASSWD
set IP 1.1.1.1
spawn -noecho ftp $IP
while 1 {
expect {
&quot;*Name*&quot; { send &quot;$USERID\r&quot;; continue; }
&quot;Password&quot; { send &quot;$PASSWD\r&quot;; continue; }
&quot;ftp>&quot; { send &quot;ls\r&quot;; puts &quot;Login success&quot;; exit; }
}
}


This way you can wait for some pattern and pass the appropriate value.

When there is no GUI involved then how come moving to next screen possible.
Please be clear with ur question
 
you can frozen that window's size :).

like that:
wm resizable . 0 0; // here is the top window
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top