Jump to content
Sign in to follow this  
Mike

Access to Parameters defined in a GUI

Recommended Posts

Hey guys,

 

I've got the following tcl code:

hwt::CreateWindow lala \
-windowtitle "title" \
-noGeometrySaving \
-cancelButton Cancel \
-acceptButton Okey \
-acceptFunc applyFunction \
-defaultButton Accept \
-minsize 470 100 \
-post;

set recess [::hwt::WindowRecess lala];
set section2 [label $recess.section2 \
-text "entry: " \
-justify left \
-anchor nw \
-font [hwt::AppFont]];

pack $section2 -side top -anchor nw -pady 5;
hwt::AddPadding $recess -side top -height [hwt::DluHeight 4];

set valueToPrint [ AddEntry $recess.frame2  label       "value:"  labelWidth  40   entryWidth  20  anchor   nw  validate    real  text 200  withoutPacking]; 
pack $valueToPrint -side top -anchor nw -pady 5;           
AddPadding $recess.frame2 width 22 -side left; 
EntryInsert $valueToPrint 7000;

proc applyFunction {args} {
 tk_messageBox -message "I don't know how to print the value :-(";
}

Now, I'd like to print the Value  "valueToPrint".

I tried

puts $valueToPrint, but it doesn't work. How can I get access to the parameter defined in the GUI?

 

Thanks for your help.

Mike

Share this post


Link to post
Share on other sites
5 hours ago, tinh said:

Hi,

look like you a refer to global variable, please try "puts $::valueToPrint"

 

Thanks tinh, but it doesn't work. Other ideas? Have you tried it? Does is work for you?

Cheers, Mike

Share this post


Link to post
Share on other sites

I copy your code and paste to command window, and then i type: puts $valueToPrint

it returns .lala.topFrame.recess.frame2

 

Do you want to return "7000" instead?

If so, give the entry a textvariable

 

set EntryWidget [ AddEntry $recess.frame2 textvariable valueToPrint   label       "value:"  labelWidth  40   entryWidth  20  anchor   nw  validate    real  text 200  withoutPacking]; 
pack $EntryWidget -side top -anchor nw -pady 5;           
AddPadding $recess.frame2 width 22 -side left; 
EntryInsert $EntryWidget 7000; #or set valueToPrint 7000

 

proc applyFunction args {tk_messageBox -message $::valueToPrint}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...