See also: [Ask, and it shall be given.]
'''In order to leave room for unanswered questions, please move your question to the appropriate page on Wikit once it has been answered. If you cannot find a page, please create a new one.'''
----
[LES] on May 02 2005:
$ set foo {Quoting "one" or "two words" is {tough}.}
$ set foo
Quoting "one" or "two words" is {tough}.
Great. However...
$ proc p> {args} {puts "
$args
"}
$ p> Quoting "one" or "two words" is {tough}
Quoting one or {two words} is tough
$ p> Quoting "one" or "two words" is {tough}.
extra characters after close-brace
Ouch! Using the proc, '''one''' is not quoted, '''tough''' is not braced and the quotes became braces in '''two words'''. And if the phrase ends in a period, it generates an error. Why does it only happen when attempted with a proc and how can I clean '''ALL''' that mess?
[RS]: Arguments to a command are early parsed as a list. That will remove grouping markup, i.e. quotes and braces around grouped words. The quotesw around "one" disappear as they're redundant in Tcl syntax. "two words" are grouped, but at Tcl's discretion with braces, not quotes.
And in this syntax, the period after the close-brace is considered an error. If you don't want the parsing to occur, add another layer of braces around strings you don't want to be parsed further:
% p> {Quoting "one" or "two words" is {tough}.}
{Quoting "one" or "two words" is {tough}.}
[LES] But that does not produce the desired effect. Those braces should not be there. I suppose you left that as an exercise for me? OK, this proc seems to work:
proc p> {args} {puts [lindex $args 0]
}
Thanks! Any suggestion of a wikit page where this topic should be moved to?
----
Stephen Tjemkes: 2005-04-29 Hi can somebody help me with background processes? I want to spawn off a limited number (say 30) of parallel background processes within the expect modules but do not understand how this can work. I've seen a brief description in the expect book using [fork] but this allowed me to fork off only one process. At least i didnot see that there were more than one. Is there somebody who can share his experience on this
Thanks
Stephen
----
[MK] I have made a Iwidgets::combobox. In order to test it , I am creating it through a *.do file in my application.On creating it the mouse is grabbed to this combobox. I want to select different entry from the list of combobox. How can I perform this behaviour of mouse from a *.do file ??
----
[Derek Peschel] 2005-04-23 I'm new to Tcl and Tk and the [console for UNIX] script is still not clear to me.
I have Mac OS X.
I've tested the console under X a little with [A minimal editor], but I want to use the console as a part of TkOutline [http://tkoutline.sourceforge.net/wiki/] under Aqua.
Note my terms "loader script" (what's on [console for UNIX]) and "library script".
Also see my comments on the [console] page.
If someone can answer these questions about the loader, I'll be ready to send in some changes from TkOutline:
1. Are the two blocks that call '''tk::unsupported::ExposePrivateCommand''' in the most logical place? Obviously they have to come after '''$consoleInterp''' is created. But a binding that uses '''tkConsoleExit''' comes before the code that makes '''tkConsoleExit''' available.
2. Should the "work around bug in first draft..." block logically go closer to the reading of the library file?
Incidentally, I would promote the "work around bug..." comment to the outer level (whole line with frame around it).
Other harder questions:
After loading console.tcl, the window opens but no prompt appears.
I don't know if the library script has to be fixed or if the loader script can contain the fix.
I tried putting in a call to '''ConsolePrompt''' but got errors because of the redefined '''puts'''.
[Brian Theado] - ''I see in tkoutline on windows that the console comes up without the prompt. If you hit enter, then a prompt is displayed. It's possible this is a tkoutline problem''
TkOutline has a '''Help''' menu.
Creating a second '''Help''' menu (in the library script) doesn't make the newly-added commands appear, but it does make the original ones disappear -- the menu appears as a blank box.
This is undoubtedly Macintosh-specific.
The Mac interface puts the menu bar outside of all windows.
The OS also may treat any menu called '''Help''' specially.
''Posting a snippet of your code would be useful in helping figure this out''
And can someone explain the relationship between the interpreters, the relationship between the two main windows, etc.?
I want to be able to affect TkOutline's widgets from the console but I also want to be able to affect the console window from itself.
But '''.''' in the console window still refers to the TkOutline window.
Later I may want to affect the console (window and interpreter) from TkOutline.
''Will add a description of my understanding to [console]''
----
[MK] 1. When I am using the command "regexp" and supppose my pattern is "*". This gives a Tcl error . I am not able to catch this error using the catch command. How can I do this ?
2. Where can I find the new features added for tcl commands (for example in case of list commands many new options have been added) for new versions ??
[LV] 1. Here's what I see:
$ tclsh
% catch { regexp {*} abc a b c}
1
Seems like I can catch it. Can you show us specifically what you believe is a failure to catch?
P.S. See [regexp] for an explanation of why your pattern is wrong.
P.P.S. be certain to actually '''check''' the results of the catch, because ignoring the error is just begging for trouble.
[MK] Its working .. Thanks.
2. New features to Tcl commands are supposedly only added after proposal, discussion, and approval of an appropriate [TIP]. If you check out [Changes in Tcl/Tk], there are attempts to summarize the changes there. There are also short notes in the ChangeLog files that are a part of the source distribution.
----
[MK] I am using a button which when invoked adds image inside itself with text . The size of the button increases. How can I fix this size ??
[Peter Newman] 17 April 2005: [Paved Widgets] allows you to tile an image behind the text of an otherwise standard Tk button (so the button size is fixed by the text size). Maybe [Tile] has something similar. Otherwise, make your own button with eg a ''canvas'' or ''label'' - and add '''', '''' and '''' etc, bindings, to give it the button-like behaviour you want. And possibly enclosed in a ''frame'', to provide the 3D border (and avoid the ''canvas'' feature/bug that it's border intrudes on the content).
----
[LV] In debugging, I often need to figure out from where a proc was called.
Certainly I could go through all the procs in a program and add code that
output something. But that is time consuming and adds a lot of output
that I'd rather not have to dig through. When there's an error, I see
sort of a ''stack trace''; is this info something that I can programatically
invoke?
[Lars H]: Yes, at least partially. Using [info level] you can determine what procedure calls were made. You probably cannot get the "... at line XX of ..." parts though, as that information is added to the stack trace when returning with an error.
Another option could be to use a trace that, rather than just dumping everything in a list or to a file, pushes and pops data onto and off its own emulation of the call stack. Then you could inspect that in the places you find interesting.
[RS]: See also "stack trace" in the [Bag of algorithms].
----
[Robert Abitbol] It's always a pleasure -- even a thrill -- to come here on wikit and to be a part of a group of '''busy bees''' always on the go, always active. This has to be the most active place on internet that I know of... The busiest wiki for sure. '''Keep it up, gang!'''
I am a huge fan of the TCL Kit and I use it all the time to start a TCL program (using copy/paste). Excuse my complete ignorance on this one. I'd like to upgrade to TCL 8.5. Is there a TCL Kit for it? Thanks!
----
Buzz Buzz Buzz ... Check out http://www.equi4.com/pub/tk/downloads.html ... that's the primary matrix
showing versions available for various platforms.
-----
[LV] on comp.lang.tcl , Ethan Blanton and William Poser, in the thread
titled "combining diacritics fail to combine in Tk", report that
attempts to display text containing Unicode non-spacing diacritics
and text are failing. Instead of being displayed as a single
character, they are displaying as multiples. Anyone know how to deal with that?
----
[SH] I am using Iwidgets::combobox. I have inserted items in the list using the "insert" command. Now my combobox entries present in list changes. Now I will have to remove entries and then insert new entries. Is there any way such that I can associate entries with a variable. When the variable gets updated , values in the combobox list also gets updated ??? In case of listbox widget there is a option -listvariable, but for Iwidgets::combobox there is no such option.. Is there any better way of doing this which can enable me not to interact with the widget but with the variable ???
[MG] I'm not familiar with the Iwidgets::combobox, but if there is no "native" way to do it, you could set up a [trace] on your variable, and fire a proc to update the combobox whenever the var changes.
----
[MK] How can I capture Key events or mouse events for testing my application. Suppose I have a entry widget , and on pressing Return a procedure is invoked. How can I perform this operation without manually pressing return ???
Similarly for mouse events , how can I move mouse , press mouse buttons etc (not doing anything manually) ??
[Peter Newman] 14 April 2005: There's the ''event generate'' command. Also it's ''-warp'' option allows you to move the mouse. If you're on Windows (95+), there's ''c:/Windows/recorder.exe'', which ''"...is an application that you can use to create macros. Macros are useful if you perform a series of keystrokes or mouse actions frequently. By using Recorder, you can record your keystrokes and mouse actions, and then play them back later by just pressing a key."''. And there are may similar propgrams on the Net. See also [Techniques for 'driving' Windows applications].
----
[MK] How can I make a Tk widget button very small size less than 1 ??
button .a -width 1
Now I cannot reduce the size of this button. - [RS]: See the [Bag of Tk algorithms], scroll down to "Minimal buttons". The idea is to create a tiny [photo] of 1 pixel size, and put that as content of the button.
[Peter Newman] Another approach is to just use a ''frame'' - and ''bind <1>'' to the button handler. That's essentially all a button is anyway - with a few extras like switching the relief to sunken when the mouse button is pressed, etc.
----
[MG] April 7th 2005 - This isn't a problem, just something I'm curious about. If I fire up a wish console (Tcl/Tk 8.4.9 on Win XP), and type in
info body parray
it gives me the error ''"parray" isn't a procedure''. If I then do a ''parray'' then (just with no args works fine), and then repeat the ''info body parray'', it shows up fine. Is it that "parray" is loading through "unknown", or something like that? [RS]: [info body] seems not to try to autoload procedures - only [unknown] does that. The error message comes for anything not known:
% info body notaproc
"notaproc" isn't a procedure
[Vince]: you can use [[auto_load parray]] if you want to force the procedure to exist. (This command will return 1 if it succeeded in finding the given proc).
----
[MH] 06 April 2005 Hi, I have been usin jacl for a while now and I've got a new requirement and I cant for the life of me, no matter how many web sites I've checked, figure out how to run a ksh shell script from within a jacl script and be able to see the output and enter input to/from the shell script.
For example:
content of mel.jacl could be:
exec /tmp/mel.sh a b c
content of /tmp/mel.sh could be:
/usr/bin/ksh
echo "$1 $2 $3"
echo "Enter Name: \c"
read user_name
The exec works but there is not output to the screen.
What do I need to do?
[RS]: The stdout of the [exec]ed command is its return value. Try just
puts [exec /tmp/mel.sh a b c]
[MH] yes that works but the shell script needs to be interactive, it displays some stuff to the screen, asks for input and then does some processing.
[RS]: Hm, then try (untested):
exec /tmp/mel.sh a b c <@stdin >@stdout
[MH] Nope, no output to screen, doesnt complete script, assume its hanging.
[LV] Okay, what platform are you on? Because on windows, there are peculiar requirements for setting up to get to stdin, stdout, and stderr .
Can you try something like
exec ksh -i /tmp/mel.sh a b c
[MH]platform=sun solaris - no still hangs
[LV] I am not certain what might be going on then. Have you tried
writing the Jacl mailing list?
[RJ] If you have [Expect], spawn the command, then [interact]:
#!/usr/local/bin/expect --
spawn -noecho /tmp/mel.sh a b c
interact
----
[MK] Is there any good tool which can help to determine code coverage and memory consumption in Tcl application. ??
[LV] I don't know about ''tool'', but in [tcllib] there is a module called [profiler], and there's some kind of memory debugging compile time option in tcl.
[TclX] has [profile] and [profrep].
[memory leak finding with memory trace]
[memory introspection]
[measuring memory usage]
Anyone else have some Wiki or other URL references on this topic?
----
[MK] We can save canvas information to a file in Postscript Format. Is there any way to read this file and show the information in the canvas ??? [RS]: In a way yes, but it requires the [Img] extension and Ghostscript installed. Then you can render Postscript into a [photo] image, which can of course be put on a canvas. See [Postscript] for details.
----
[ABU] 2005/03/31
? Listbox: Is there an event raised when a listbox has no selected items ?
Here is a simple scenario:
I have a listbox and a button
The button should be enabled when a selected element exists, and it should be disabled when no element is selected.
In order to enable the button, I can intercept the <> event,
but, I cannot find a similar event for the other case (when the listbox has no element selected).
Can anybody suggest me a tecnique for catching this 'event', so that I can properly enable/disable the button ?
[Peter Newman] 31 March 2005: As I read the ''listbox'' manpage, <> is generated when the selection '''changes'''. So all you have to do is bind to <> - and then check if something is selected now or not. Also, the ''treectrl'' and ''tablelist'' (and the BWidget ListBox too, I think,) handle selection changes differently than the standard ''listbox'' (and every one different from the other). And I'm pretty certain, that with the ''treectrl'' at least (especially the latest (Feb 2005, I think,) version), you can do what you want.
[ABU] Sorry, but it doesn not work !
<> is generated when a new element is selected, but when the listbox looses its selection (or maybe its last element is deleted), no event is generated.
Below you can find a simple scenario I used for testing .... I cannot find a way to *disable* the button ...
proc mylistbox {w} {
listbox $w.lb1
pack $w.lb1
$w.lb1 insert 0 aa bb cc dd
button $w.b1 -text "apply on selected element" -state disabled
pack $w.b1
bind $w.lb1 <> [list $w.b1 configure -state normal]
}
toplevel .wa
toplevel .wb
mylistbox .wa
mylistbox .wb
To be honest I am interested with the Tablelist widget, but I think that listbox could be a simpler starting point.
[Peter Newman] 31 March 2005: Strange about the ''listbox''; the manpage clearly states ''when the selection changes''. My main app. is focused around one main single column listbox. But to get it to work right, I've had to experiment with the standard ''listbox'', the BWidget ''Listbox'', ''tablelist'' and ''treectrl''. They're all implemented, and you can menu select between them. But the ''treectrl'' is far and away the most powerful. Check out it's '''' event:-
Generated whenever the selection changes. This event gives information about how the selection changed.
%c Same as the selection count widget command
%D List of newly-deselected item ids
%S List of newly-selected item id
Clearly, that will do what you want. (I use the event in my own code. And it fires for both selections and de-selections.) It basically blows the others away in every other respect too. I agree that the standard Tk ''listbox'' should be the simplest to use. But the fact is it's so gutless, that this is only true for very simple applications. ''treectrl'' is a nightmare to learn though. So if that selection thing is all you're concerned about, I'd check out the BWidget ''ListBox'' and ''tablelist'' first.
Just checked it out in my app. And ''treectrl'' is to be the only one that fires on both selection and de-selection. But in my test, I can't get the ''listbox'' to fire even on selection. Something's not right. Monitoring selection and de-selection is important to my app. - and I'm sure they all do it. I think we're both missing something.
[ABU] As far as I read from your notes, Treectrl seems to deal the de-selection perfectly; unfortunatelly, treectrl is not a pure-tcl widget, so I cannot investigate further ...
About your listbox bindings experiment, check if you wrote <> or <> (wrong).
As I said before, I'm interested with Tablelist, and since it is built upon listbox widget, I though it was simpler to investigate.
[Peter Newman] I re-wrote your test code to try and figure this out...
pack [listbox .myListbox]
button .b1 -text addElement -command addElement
button .b2 -text deleteElement -command deleteElement
button .b3 -text selectFirst -command selectFirst
button .b4 -text selectAll -command selectAll
button .b5 -text selectNone -command selectNone
pack .b1 .b2 .b3 .b4 .b5 -side left
set elementNumber 1
proc addElement { } {
global elementNumber
.myListbox insert end Element#${elementNumber}
incr elementNumber
}
proc deleteElement { } {
.myListbox delete 0
}
proc selectFirst { } {
.myListbox selection set 0
}
proc selectAll { } {
.myListbox selection set 0 end
}
proc selectNone { } {
.myListbox selection clear 0 end
}
pack [button .myButton \
-text "apply on selected element" \
-state disabled \
-command bell \
]
bind .myListbox <> ListboxSelectHandler
proc ListboxSelectHandler { } {
set listOfCurrentlySelectedElements [.myListbox curselection]
set elementCount [llength $listOfCurrentlySelectedElements]
puts "${elementCount} Currently Selected Elements: ${listOfCurrentlySelectedElements}"
if { $elementCount == 0 } {
puts {Disabling the button...}
.myButton configure -state disabled
} else {
puts {Enabling the button...}
.myButton configure -state normal
}
}
Running the above shows that - contrary to what the manpage says - <> DOESN'T fire in response to selection changes at all (neither selections nor de-selections trigger it). But it does fire in response to a LEFT MOUSE CLICK??? This makes no sense to me at all. Has the listbox always behaved this way? Or is it a bug introduced with recent versions of Tcl? Might pay to check the listbox bindings. Possibly, by fiddling with them, you can get it to behave the way it should.
[ABU] Peter, I've repeated your experiment on my PC (WinXP, Tcl 8.4.3) and I can confirm that the <> behavior is not what we expected.
I don't know if it is a new bug; I'm not aware of a "good" app providing the behavior I wanted ...
Now I'm investigating with Tablelist internal code; it seems to me that it handles correctly the case when the widget loose the selection (I've found a proc named tablelist::lostSelection), but I'm not sure of all the required preconditions and side-effects ...
NOTE: I must correct my myself: Tablelist does not use listbox internally; it uses a text-widget.
It seems to me that Tablelist is using some sophisticated (?) tecniques with the 'selection' command. Unfortunatelly this is quite obscure to me now .
I'll keep you informed on future results.
Any help is appreciated.
[Peter Newman] Aha, it becomes clearer! It seems that <> ISN'T generated in response to selection changes made by the PROGRAM - only in response to selection changes made by the USER. Then it fires for both selections and de-selections, as you want it to.
The user can select and de-select things:-
* In ''-selectmode multiple'' - by clicking the left mouse button, and;
* In ''-selectmode extended'' - by holding down Ctrl whilst clicking the left mouse button.
The following updated code demonstrates this...
global selectMode ; set selectMode browse
pack [listbox .myListbox -selectmode $selectMode]
pack [frame .row1]
radiobutton .row1.sm1 -text browse -variable selectMode -value browse \
-command {.myListbox configure -selectmode $selectMode}
radiobutton .row1.sm2 -text multiple -variable selectMode -value multiple \
-command {.myListbox configure -selectmode $selectMode}
radiobutton .row1.sm3 -text extended -variable selectMode -value extended \
-command {.myListbox configure -selectmode $selectMode}
pack .row1.sm1 .row1.sm2 .row1.sm3 -side left
pack [frame .row2]
button .row2.b1 -text addElement -command addElement
button .row2.b2 -text deleteElement -command deleteElement
button .row2.b3 -text selectFirst -command selectFirst
button .row2.b4 -text selectAll -command selectAll
button .row2.b5 -text selectNone -command selectNone
pack .row2.b1 .row2.b2 .row2.b3 .row2.b4 .row2.b5 -side left
set elementNumber 1
proc addElement { } {
global elementNumber
.myListbox insert end Element#${elementNumber}
incr elementNumber
}
proc deleteElement { } { .myListbox delete 0 }
proc selectFirst { } { .myListbox selection set 0 }
proc selectAll { } { .myListbox selection set 0 end }
proc selectNone { } { .myListbox selection clear 0 end }
pack [button .myButton \
-text "apply on selected element" \
-state disabled \
-command bell \
]
bind .myListbox <> ListboxSelectHandler
proc ListboxSelectHandler { } {
set listOfCurrentlySelectedElements [.myListbox curselection]
set elementCount [llength $listOfCurrentlySelectedElements]
puts "${elementCount} Currently Selected Elements: ${listOfCurrentlySelectedElements}"
if { $elementCount == 0 } {
puts {Disabling the button...}
.myButton configure -state disabled
} else {
puts {Enabling the button...}
.myButton configure -state normal
}
}
So all you have to do is update the button's state manually, when selecting, de-selecting, inserting and deleting listbox items from the program. And provide a <> handler to deal with changes made by the user.
[ABU] 4-apr-2005
Sorry, but catching <> is not enough ...
Here is a simple way to test ...
* Add an entry-widget to the last example:
entry .e ; pack .e
* add some rows to the listbox, then select a row ..
* click within the entry-widget ..
* write some text and SELECT IT
* now you can see that the selected row within the listbox has disappeared, but no <> has been generated !
I developed a more general solution (hint: the "selection own" command) ; currently it is under testing. I hope to be able to publish it before tomorrow.
[ABU] 5-apr-2005
You can find my solution at: [How to totally handle listbox selection].
Feel free to add suggestions.
----
[NickM] 2005/03/28
I need to call a simple TCL (8.4.9) script from within a Windows XP DLL environment (no tclsh or console init). The script will make use of some custom TCL command extentions. Tip#66 starts to talk about the all the system initialization that occurs before you can make the first call to something like Tcl_FindExecutable("bla"); Is there a single simple initialization call I can make like to tclWinInit.c, that takes care of this initialization, except outside of a console environment? Interestingly, I have been able to make some progress creating an interp using a dynamic TCL build with USE_TLC_STUBS not set. With a static build, you can't call Tcl_bla out of the chute because the stubs table needs to be inited. There's got to be some secret sauce. Thanks.
----
[MK] I want to show progress bar of a process. Which widget to use and how to use such that the bar automatically updates itself according to the time taken by a process. (Time taken by a process may differ at different time). The progress bar should also be destroyed at the time a process ends.
[Peter Newman] 29 March 2005: 1) Just search for ''progress'' on this Wiki, and you'll get a whole heap of progress bars. 2) I assume that you mean that you want to launch an external process with (say) ''exec'' - and have the launching process display a progress bar that indicates (say) the ''percent completed'' of whatever it is that the launched process is doing. The general problem with this is; ''How does the launching process know how much the launched process has done?''. If this is correct, the solution will depend on what the launching and launched processes are - and what possibilities the launching process has for monitoring the launched process? It would help if you tell us what the launching and launched processes are. - [RS] Hint: a quick search URL is http://mini.net/tcl/2?progress - just add your search term after the "2?" part.
----
[Erik Purins] 2005/03/23
I need to just install part of tcllib, but tcllib's installer.tcl wants to install and make docs for them all.
Can this be changed to treat the args to installer.tcl (after the options) as a list of packages to install?
Is there already a mechanism for this that I missed?
So instead of 'tclsh installer.tcl -dry-run' and an install of all the scripts and docs, I can 'tclsh installer.tcl -dry-run cmdline'
and just install 1 or more of them.
----
tk newbie 2005/03/19
When i run a tcl-tk script xterm window opens along with my widget. How to avoid this....
[Peter Newman] 21 March 2005: If you run the script with ''tclsh'', that won't happen. But if you run the script with ''wish'', it will - because ''wish'' automatically opens an (empty) ''toplevel'' window called '''.''' when it starts.
Normally, a Tk script will fill the toplevel with widgets, so this is no problem. But you can get rid of the toplevel with either:-
wm iconify . # Hides the window, though it still appears on the taskbar.
--OR--
wm withdraw . # Hides it totally.
Use ''wm deiconify .'' to restore the window. The above behaviour is what is seen on Windows; it might be a little different on Linux. Hope that helps.
----
[Meir] March 18, 2005
As a newbie to Apache and Tcl I'd appreciate if this simple question can be answered for me.
I run a local WIN2K box. Got tcl 8.4 loaded and working. Loaded Apache 2.0. It runs on startup. (I nixed IIS)
My browser is Firefox. I note that it has the tcl plugin.
Question: How do I get Apache to run a script? Just putting the URL to point to the script seems NOT to work; It seems Tcl isn't interpreting the script commands.
Thank you - I hope I asked my question correctly.
It seems to be an imposing way to ask a question, editing and all.
[LV] Sorry, I can't imagine a much easier way to ask a question than to type it in a window.
However, check the [Apache] and [Rivet] pages here on this site for more help. Also, check
out [tkchat] for information about [IRC] chatrooms (or the chatroom on this site) where
you can ask people questions in real-time.
[ECS] 2005-03-18 -- I am not sure if I understood correctly, but I think you want to download a TCL script to be executed by TCL plugin in Firefox. Two things: you need to configure apache to return tcl scripts as 'application/x-tcl'. And have Firefox configured to associate this MIME type with the plug-in.
Another interpretation is that you want a CGI written in TCL.
Sorry if I misunderstood your question.
[Meir] March 20, 2005
I want to develop web programs using Tcl on my local WIN2K box; By repeatedly testing them with my local browser.
I know my Firefox browser has a plugin enabling the Tcl extension.
Now Apache seems to be my main obstacle for progress. Seems I need to know a whole lot about how to configure it.
May I make this request of you just so I can get going? Can you just spell out for me how I can run a file residing in D:\myServer ; How do I actually tell Apache that this is my "virtual directory"? That is, in what section of httpd.conf do I say what. Do I need to say,
AddType application/x-tcl .TCL
or do I need an Action/Application statement too?
If I can just get the browser to run a simple (albeit sloppy) Tcl file, such as
puts "Content-Type: text/html"
puts "Current Time"
puts "The time is [clock format [clock seconds]]"
I'd be grateful to hear from you. Thanks so much.
[Peter Newman] 21 March 2005: I could well be wrong, but AFAIK there is NO ''Tcl plugin'' for ''Firefox'' under ''Windows''. Under Linux, and as far as I can tell from the Web, it seems to be possible. But under Windows??? (This doesn't mean to say you couldn't compile it, and get it to run under Windows. But I can't find any such package on the Web.)
Are you absolutely sure you have a working version of that package. And if so, where did you get if from? (I ask that question because I've been unable to find a precompiled copy of the ''Tcl plugin'', that works in the LATEST browsers, under ''Windows''.)
[Meir] I wish you'd've responded to my heartfelt request, Peter.
In answer to your question; The 1st Google search for "tcl plugin windows"
yields result #1: http://www.demailly.com/tcl/plugin/download.html
It's called nptcl30.dll and resides in
C:\Documents and Settings\Administrator\Application Data\Mozilla\Plugins
Could someone please refer to my previous request and help me out.
[Peter Newman] 22 March 2005: I know nothing of Apache, so I can't help you there. But you don't need Apache to test the plugin. There are pages on the Web that use the plugin, eg; [http://hegel.ittc.ku.edu/topics/tcltk/index.html] - so going there will let you know whether or not the plug-in's installed properly (or whether it's Apache that's the problem).
I've installed the version you pointed me too, but FROM MEMORY: 1) It's for VERY old browsers, eg; Netscape BEFORE Mozilla and IE 3/4/5 (not sure which one(s)). (In other words, it's for browsers that you'd be lucky if even 1% of Web users still have - so running a site that uses it is virtually pointless). And: 2) I found it either (very) flaky - or it just wouldn't install and run on the latest browsers. A few months ago I tried installing it on Win98SE and/or XP - under Firefox and/or IE6. But oh dear!!!
In other words, it's a great idea, but it's dead; ''Tcl PlugIn, RIP''.
But check out the site above, and any others you can find. That at least will tell whether or not and how well the plug-in works.
If you find that the plugin works OK, but you're still having problems with Apache, then you might want to consider switching to [TclHttpd] as your Web Server - at least until you get the plugin running properly. I'm sure you'll find a LOT more Tcl'ers with experience of that who can help you, than with Apache.
TclHttpd is also MUCH easier to use than Apache. It works practically straight out of the box - though you do need the external documentation to help you get started. I've tried installing Apache twice. It installs OK. But getting it to do stuff is just too complicated. If you're running a Web Server maybe. But on a desktop, it's just not worth the time & effort. I've got a copy of TclHttpd installed on this desktop, so maybe can help you with TclHttpd, if you're still having problems.
[Meir] Thanks Peter. I'll give TclHttpd a try.
----
[KB] 14-03-05. TCLCurl seems to be written for POST docs, I need to simply listen to a given TCP port and respond with a HTTP 200 OK when documents received. Docs will be pushed at me instead of pulling them.
Is TCLCurl a good lib for this?
Is there something else that would provide better performance for this?
[Peter Newman] 15 March 2005: [http] is the standard Tcl package for HTTP. It's simpler than TclCurl - though it doesn't support all the bells and whistles that TclCurl does. I'd try [http] first.
----
[MK] Consider an example :
bind $topLevel {puts "toplevel window"}
bind $toplevel.button {puts "button inside a toplevel window"}
if focus is on the button, then both the scripts get executed. I want that only the script associated with the button should be executed. How will this be done ???
[aricb]:
bind $toplevel.button {puts "button inside a toplevel window"; break}
[MK] Thanks
----
[rdt] asks how would you implement a text widget with some "fixed uneditable" parts and
some parts that are editable? Like a Form to be filled out?
[rdt] How about creating a text widget, placing entry boxes for each editable part, then
seting the text widget read-only?
[Peter Newman] 13 March 2005: Your suggested solution sounds OK to me. But check out [Wcb]; it has solutions for this too.
[DKF]: Works very well. Remember to add bindings for , and too.
[rdt] Yeah, but with my idea, how do you get a multiline entry widget? Looks like a combination of read-only and normal text widgets!
[aricb]: Is [gridplus] an option for you, or is that totally not what you're looking for?
[Peter Newman] 13 March 2005: For multi-line entry widgets, see [LabelText -A Multi Line Entry Widget] and [Multiline expanding entry widget]. I also wrote one which I think is probably better than both of those, because it also fixes the Tab and Shift+Tab keys so that they work exactly like they do for the `entry' and other widgets (move you from field to field in a data entry form). The text widget uses Tab and Shift+Tab for 8-space text editor/word processor tabbing. Though if you check out the bindings on the text widget manpage, you'll see that it's not too difficult to restore the `entry' widget like behaviour. Though I found I also needed [Wcb], to do the job properly. See [Multi-Line Text Entry Widget - With Entry Widget Like Field To Field Tabbing].
[MG] You could also overload the text widget's standard bindings for all the keys which edit to check to see if the text you're editing is locked (like add a ''disabled'' tag around it). Then, for insertion, check to see if the characters either side of the insertion cursor have the tag, and for deletion/modification, check to see if any of the characters in the selection range (or the single character next to the insertion cursor, for deletion) has the tag. That might be more difficult than the suggestions above, though - especially since the bindings change over different versions of Tk...
----
Is it possible to recursively walk a keyed list. If so, any algorithm?
[Peter Newman] 9 March 2005: Yes it's possible. Can you give an example of the keyed list you want to walk - and explain what you mean by walking it.
----
[MRS] 2005-03-03
It is safe to do a
source [file join .. somefile.tcl]
or is better always to do
source [file join [file dirname [info script]] .. somefile.tcl]
???
[MG] It depends on where you're doing it. ".." is relative to the current directory - so, if you use [cd], it'll work differently. Running a Tcl script in [wish] from ActiveTcl 8.4.9.0, I find that (after the app has started), [[info script]] returns nothing, but [[[pwd]]] (without changing directory manually first) is the dir my script is in, as is [[file dirname $argv0]].
So, basically, it depends on when and where you're using it, and whether somefile.tcl is relative to your current working directory, or to the directory your original script was in at the time it was run.
----
[MRS] 2005-03-03
What are the effects of a
package require
???
My question is because, as I understand, The difference between a '''package require''' and a '''source''' is that with '''source''' one needs to inform the path where to find the script and with '''package require''' Tcl will look in the library dirs.
If there is only this difference, why I see in many scripts both lines like this:
source somepackage.tcl
package require somepackage
???
[MG] The main difference is that [[package require $package]] is intended for loading libraries of code - commonly used functions which are shared among a lot of applications. The code for these, whether it's pure-Tcl or compiled extensions, is stored in a place which is not relevant to any particular program (but is relevant to Tcl itself), so that any program using Tcl can access it, without knowing where it's stored (or can check if it's available, even), with a simple [[package require $packageName]].
[source], on the other hand, is more useful (when used inside a program) for loading code used only by / packaged with that particular program. Then you can, for instance,
source [file join . lib moduleX.tcl]
to load a particular piece of code that your program needs to use, without making it "publically" available to other apps. (Of course, they could always ''source [[file join $pathToLibFolder moduleX.tcl]]'', but they'd have to know exactly where to find it.)
Hope that helps a little :)
------
[Robert Abitbol], Monday 28 February 2005. I now more or less know what a widget is. I think the idea of a widget is just brilliant. The way I see it, a widget is a sort of library, a sort of series of macros where the most important functions can be programmed real easily and real quickly through very few commands.
Now my question is: who does program those TCL/TK widgets? Is there a list of widgets available anywhere?
----
[LV] Robert, a widget can come from various sources.
There are a number that come with the [Tk] extension - check that page, which I believe lists the widgets that come in the extension. However, note that
on Windows and MacOS in some Tk versions, one wouldn't find all the code
for the widgets that Tk supports - that's because on those platforms,
the Tk widget is implemented based on the version of the widget that
comes in the windowing system.
Other Tk extension writers also have created various kinds of widgets.
In some cases, they are called [megawidget]s - combinations of Tk
widgets, with some additional behavior coded. In other cases, they are
unique widgets.
So there really isn't a list of widgets available. That's really too bad.
I mean, some professions can find ''catelogs'' of particular kinds of
components that they use to build things. I've always wanted this wiki
to be a kind of catelog like that. However, there are only so many
hours in a day that can be dedicated, at this time anyways, to such
a task.
----
And is this concept of widgets also established for other languages or is it just a concept available only in TCL? - [RS]: Just see [widget]. This term was introduced in X - in the MS [Windows] world they call it "form".
[LV] Robert, if a language supports [GUI] development, then they will have
some kind of terminology for those entities which can be combined together
to create an application. Many languages use the term [widget]s for that
class of objects.
-----
I am using iwidget::scrolledframe. Inside it I am adding a frame which contains a canvas. Now on adding a frame , I want that vertical scrollbar should automatically move to show me that frame. This frame can be added anywhere in the scrolledframe. So every time I add a frame , I want that it should be visible.
Is it possible ??
Help me out.
Thanks
Manish Khanna
manish_khanna@mentor.com
[MG] Can you show us the code you have so far, for creating the scrolledframe and for creating and packing a frame inside it? That'd be helpful...
[MK] The code looks like this :
set topLevel [toplevel .timingpage]
wm protocol $topLevel WM_DELETE_WINDOW
wm title $topLevel "Timing"
wm resizable $topLevel no no
iwidgets::labeledframe $Timing.cd -labeltext "Clock Domains" -labelpos nw
set clockdomains [$Timing.cd childsite]
grid $Timing.cd -row 1 -column 0 -ipadx 5 -ipady 5 -sticky nsew
set ClkDomain(ScrolledFrame) [iwidgets::scrolledframe $clockdomains.sf -vscrollmode dynamic \
-hscrollmode dynamic \
-width 500 \
-height 200 \
-highlightcolor black \
-highlightthickness 1]
pack $ClkDomain(ScrolledFrame) -expand yes -fill both
set ClkDomain(sfchildsite) [$clockdomains.sf childsite]
.
.
.
AddDomain
# This proc is called by a button in GUI which adds a frame containing a canvas inside a scrolledframe . The frame can be placed in different order inside scrolledframe depending on variable "i" used. I want that scrollbar should move accordingly such that this frame which i have currently added becomes completely visible.
#I have written down the idea how am I using it .
proc AddDomain {} {
set Domainframe [frame $ClkDomain(sfchildsite).domain$i -bd 1 \
-height 80 \
-width 200 \
-takefocus 0 ]
grid $Domainframe -row $i -column 0 -sticky nw
set Clock(canvas) [canvas $Domainframe.clock -width 500 \
-height 50 \
-bg black \
-takefocus 0 \
-cursor hand2]
grid $Clock(canvas)
}
[MG] has looked over your code and the manpages for the scrollframe/grid, and is afraid he isn't sure quite how to do it...
[Peter Newman] 23 February 2005: Looks to me like you'd be struggling with the ''iwidgets'' ScrolledFrame. But with the ''BWidget'' ScrollableFrame, it looks to me like a piece of cake. Check out the ''see'' command.
In my experience, putting multiple widgets inside a single Scrollbar Manager widget leads to VERY sluggish performance. Could you not use just the one canvas - and divide it into imaginary rows. I'm sure that would scroll much faster - and you can use ''xview'' to show the content you've just added.
[MK] thanks for your advice . I have solved the problem. I have done event