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

beginners guiding 1

Status
Not open for further replies.

kukelyk

Technical User
Mar 23, 2005
57
HU
hi
im new in tcl, im not a programmer, so i have many many problems...
my problem is finding the value of a numerical variable in a string.. how can i do this?
the string match command seems not to work..
thanks, kukelyk
 
It shouldn't. What platform are you on?

Anyway, just delete that option. The default text should be enough (especially if it's "disabled").

_________________
Bob Rashkin
rrashkin@csc.com
 
a big thanks Bong!
now my script looks (i realized that better to leave the entry normal, so later, when i generate the doc, i can change the text..) :
Code:
set w .dokumentáció
toplevel $w
pack [frame .ftop -borderwidth 4] -side top
label $w.l1 -text El?gyártmány: -font -*-Helvetica-Bold-R-Normal-*-*-140-*-*-*-*-*-*
grid $w.l1 -row 1 -column 1
entry $w.e1 -width 70 -textvariable Stock 
grid $w.e1 -row 1 -column 2

checkbutton $w.cb1 -command  {cbcmd $electrode} -text Elektróda -variable electrode
grid $w.cb1 -row 2 -column 1

label $w.l2 -text Nullpont: -font -*-Helvetica-Bold-R-Normal-*-*-140-*-*-*-*-*-*
grid $w.l2 -row 3 -column 1
entry $w.e2 -width 70 -textvariable MCSO
grid $w.e2 -row 3 -column 2
button $w.b1 -text ESC -command {exit}
button $w.b2 -text OK -padx 200 -command {set MCSorigin $MCSO; set stock $$w.e1::MCSorigin; #HERE IS STILL SOME PROBLEM
 destroy .$w
tk_messageBox -icon info -message "$stock \n $MCSorigin"}
grid $w.b1 -row 4 -column 1
grid $w.b2 -row 4 -column 2

proc cbcmd {electrode} {
global w
  if {$electrode == 1} {
     $w.e2 configure  -background gray
     set ::MCSO "Darab tetején, EROWA szerint középen"
  } else {
     $w.e2 configure -state normal
     set ::MCSO ""
  }
}
it almost works, could you correct the COMMENTED part?
(reading the other entry's content)

but i have the problem, to run this TK script from tlcsh :(
 
oh , i failed
$$w.e1::MCSorigin
it is correctly(???) $w.e1::Stock..
 
I think all you want is "$Stock". In .ftop.e1 you set [red]-textvariable Stock[/red]. That means that whatever is written in the entry is the value of the variable named "Stock".

_________________
Bob Rashkin
rrashkin@csc.com
 
great.
the thing what i dont know :
i want to execute this script in the middle of a longer tcl process, where is no graphics, but file operations.
when the script runs, it writes data to a file, after that it will display this window, where i can define variables.
when i destroy the window, will the main script continue?
(but it still depends on the tk commands... :-/ )
 
aaam, there are some other things:
-when i run my TCL script, what is associated with wish80, it displays to window: one with the name of the TCL file, and the other, what the script makes with the toplevel command
how can i avoid the 1st window?
-whem i click on the OK button, the command
Code:
destroy .$w
does not execute, whilst the other commands,
Code:
set variables
do.. :-?
 
aand, in the 3rd row, i forget to replace the .ftop to $w, but if i change it, the script does not work..
i thinkink about it causes the 1st window
 
do the variables of entries perish when i destroy a window?can i use them later in the script?
 
Just get rid of the toplevel. Wish launches a window (called "."). There's no getting around it. I use "toplevel" when I want a second window; if all I need is a single window, I use ..

If you destroy the "." window, the shell exits; so don't do that. You can, however, destroy the frames and widgets inside the window and build others to do different things.

_________________
Bob Rashkin
rrashkin@csc.com
 
:confused:
i really dont know, what should i do..
but thanx for your help & your time...
 
i get the answer for my question at
but there is still some questions...
what i need is:
package require Tk

but i dont know, where tclsh find the tk package.
as i told "its a part of an other program..", i dont know how the software execute my TCL scripts, b'cos i dont find even the interpreter...
so how can i include a tk package with absolute path?
package require c:\\TCL\\tk
 
I'm running Windows 2k. When I installed Tcl/Tk from ActiveState, the Tk package is in c:\tcl\lib\tk8.4. The PATH environment variable includes c:\tcl\bin. All I have to put in a script is "package require Tk".

Where is your Tcl installed?
What is your PATH?

_________________
Bob Rashkin
rrashkin@csc.com
 
my settings are the same, w2k, tk8.4 and 8.0 in the same dir., PATH env_var.. i dont know why the tclsh does not find it,
but this documentation i make will be used on computers without installed Tcl/Tk package (if not definitely needed),
but there is a tk8.0 package in the software's dir..but in a directory of an other application of this software..
 
Tcl needs to know how to find a package when it is called in a "package require" statement. The directory where the path is to be found must be in the global variable, "auto_path", or one of its immediate subdirectories. You can add the directory to auto_path with: lappend auto_path <directory name>. Then package require Tk should work.

_________________
Bob Rashkin
rrashkin@csc.com
 
heureka!
Code:
set cam_aux_dir  [MOM_ask_env_var UGII_CAM_AUXILIARY_DIR] 
set cam_shopdoc_dir  [MOM_ask_env_var UGII_CAM_SHOP_DOC_DIR] 
set ug_wish "ugwish.exe" 
set title ""
set msg ""
exec ${cam_aux_dir}$ug_wish ${cam_shopdoc_dir}datain.tcl $title $msg
and now it works, but there are some bugs, i have to correct..
MOM_ask_env_var is an alias...
 
hi
how can i clean the toplevel window? unpack or what?
 
ad 2
if i called wish from tcl, how can i switch back and in the same time keep variables in memory defined in wish
if i destroy wish window, it switches back, but the variables lost.
 
could anybody tell me which commands i need for this procedure:
open a file
read a single line to a pulldown list, the list elements are the pieces of the line
if the user dont find the text he need, he can write to the entry, and the new text will be appended to the line in the file
save&close the file
?
thanx in advance
 
To clean widgets (including frames) out of a window, use "destroy". As in destroy .f1.f2.e1.

If I understand you correctly you want to read a single line as a list of elements. Those elements become part of a pull-down.

There is no proper pull down in Tk but there is a Bwidgets ComboBox. Tk has a "spinbox" which behaves similarly. Both take an option [red]-values[/red], that points to a list variable. So the real process you're asking about, I think, is reading a line out of a file into a list; then adding to the list; then putting the list back out to the file:

set fid [open <file name> r]
set listvar [split [gets $fid]]
close $fid
#...assign [red]listvar[/red] to the [red]-values[/red] option
#...assign [red]tvar[/red] to an entry widget
#...have a button or binding to do:
lappend listvar $tvar
#...now the list (and box) has a new line
#...to write out:
set fid [open <file name> w]
puts $fid [join listvar " "]
close $fid


_________________
Bob Rashkin
rrashkin@csc.com
 
thanks Bong
as i undertand your script, it looks well, but i dont know, how can it figure which line it reads from/write to?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top