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

spring out an entry

Status
Not open for further replies.

waistcoat

Programmer
Aug 2, 2003
15
CN
hi,all
Can you give me an example of how to spring out a frame
when I press a button.I need a entry in the frame.
Thanks!
 
Not sure of what you want.
Maybe that?
Code:
  pack [button .b -text Show! -command show -width 10] -pady 10
  proc show {}   {
    pack [frame .f -relief groove -bd 2]
    pack [entry .f.e -width 15] -padx 20 -pady 20
    .b config -text Hide! -command hide 
  }
  proc hide {}   {
    destroy .f 
    .b config -text Show! -command show 
  }
HTH

ulis
 
What I want is when I press a button it spring out a frame
with an entry in another window.And after I input the variable in the entry widget,I can dismiss it press a button
{for ezample ok).
 
Hi,

I think the link below has an example that should help you solve the problem:


Basically you need a toplevel window which will be the child of the main window and then put all the widgets that you want in the window.

Look at the code below: Where I am creating a Find window and placing two buttons Ok and Cancel in it.

global flagno
toplevel .find
wm title .find "Find"
wm transient .find .

set temp [winfo x .]
set temp2 [winfo y .]
set x2 [expr 100 + $temp]
set y2 [expr 100 + $temp2]
wm geometry .find 200x125+$x2+$y2

button .find.b1 -text "Ok" -background red -command {set flagno 0 ; destroy .find}

button .find.b2 -text "Cancel" -background red -command {set flagno 1 ; destroy .find}

pack .find.b2 .find.b1 -fill y -padx 1m -pady 1m

update idletask
grab .find
tkwait window .find
 
What I mean when you press the OK button in your program
it spring out another frame with an entry widget and a button( for example dismiss),when I press dismiss the frame
springed out will disappeared.
 
Thats exactly what the code above does. Simply put the above code in a proc and call that proc on the click of a command button on window 1. That will start a new window-- Window 2 and you can have the two buttons on it as you want-Ok and Cancel. Write two seperate procs or simply single proc that destroys the new window.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top