Version 10 of Peter Newman

Updated 2004-10-29 05:06:00

EDIT/RECENT CHANGES


Mail

Robert Abitbol

Thanks Peter for your excellent presentation on the "Answered Questions on ..." pages. The idea to put trails on each page (Home, back, and forward) was grand. The idea for a table of contents for each page was also very appropriate.

The same goes for the excellent presentation on the Answered Questions Index Page.

This is very professional work which makes those pages a pleasure to read. Thanks again!



Please don't edit anything below this line. It's stuff from Ask, and it shall be given. that's being transferred to the "Answered Questions On: Whatever" pages. Thanks. Peter Newman, 29 October 2004.



Category:

Nov 04, 2003 Newbie asks: I'm trying to create a "yellow stick note" app. I have created a little decoration-less window using wm overrideredirect, and now I need to generate window-moving events so that I can manually place the sticky note. I believe I need to use event generate, but how do I get drag coordinates into a little script, which would (I believe) call wm geometry? Thanks...

 Here's a solution:

 set ::moveable 0
 wm overrideredirect . 1
 bind . <ButtonPress> {set ::moveable 1}
 bind . <ButtonRelease> {set ::moveable 0}
 bind . <Motion> {if {!$::moveable} {break}; wm geometry %W +[expr %X-10]+[expr %Y-10]}

 JPT

Newbie responds: Sacrosanct bovine, Batman! You guys sure make it look easy! Just to make myself feel better, I modified your solution so that the frame wouldn't 'jump' to the cursor:

 set ::moveable 0
 set ::X 0
 set ::Y 0
 wm overrideredirect . 1
 bind . <ButtonPress> {set ::moveable 1; set ::X [expr %X-$::X]; set ::Y [expr %Y-$::Y]}
 bind . <ButtonRelease> {set ::moveable 0; set ::X [expr %X-$::X]; set ::Y [expr %Y-$::Y]}
 bind . <Motion> {if {!$::moveable} {break}; wm geometry %W +[expr %X-$::X]+[expr %Y-$::Y]}

Category:

22-Oct-2003 I'm using tclkit to run tcl stuff on windows plattforms, but i can't open files under Windows XP. Win 2000 works fine, are there any known issues with Win XP, maybe concerning filepaths? Bernd

Vince -- no, there are no known problems on XP. You'll have to be much more precise about what your doing. Provide a short script (< 10 lines) which works on 2000 but fails on XP. This should be easy if you can't open files.

Well, a single line will do: "set FILE open test/file.txt r". This works fine on 2000 but fails to find the requested file on xp. The problem remains when i replace slash by backslash, i'd think both variants should work. There is nothing else in the script i used for my test, the script is wrapped for win using: "sdx wrap tclxp.exe -runtime tclkit-win32.upx.exe". -- Bernd

I'm really surprised now, because i can't even open a file in the same directory ("set FILE open file.txt r"). So it's not a slash, backslash problem. -- Bernd

Vince with any bug report, the error message you get is critical. Anyway, I suggest you report this on comp.lang.tcl or on sourceforge, not here.


Question on text widgets displaying large files moved to text.


Category:

18-Oct-2003 Hello! I have a question about Winico. I have installed the package and have trouble loading it. After copying the winico03.dll into the working directory, I enter the following: load winico03.dll

I get a cannot find library winico03.dll or one of its dependants. What would cause this and what do I do to overcome it? Thanking you in anticipation.


Category:

Broken Link??? Sep 30 - 2003

Hello.

I tried the following link that was on the wiki site (ftp://ftp.dcade.de/pub/ml/tcl/packages/tcl_messageBox10.zip ) but could not get through. Anyone have any luck as I would like to view this.

Thanks

Ep


Category:

Tcl Installation/Uninstallation Sep 30 - 2003

Hi all!

I easily compiled and installed the latest Tcl source code. I was needing it for compiling expect. Now I am done with my tasks, I have successfully uninstalled expect, but I found that there is NO make uninstall available for the Tcl code.

Does anybody know any way to uninstall Tcl source code, apart from searching by date and removing file by file!?

Your help is much appreciated!! Have fun, Oscar


Category:

Sep 29 - 2003

How can i use the options(-error,-sockname,-peername) of configure command of socket ? The main problem is, like -sockname option returns three elements so how can i store these values to use further?


Category:

Sep 25, 2003

I have a channel that I have opened as:

 set cid [ socket -server cfg $port ]

From time to time the client times out reading this channel. When that happens the data in the buffer (from a puts command) is no longer valid. I would like to throw it away. NOT flush it, which just sends it to the client the next time the client tries to do a read, but actually empty the buffer and throw the data away. How can I do this? Thank you in advance.


Category:

20-Sep-2003

I'm messing around with tk_setPalette I have a problem with the foreground being black on black or more precisely very dark blue this is only a problem with errors which I can't read unless I edit both libs: dialog.tcl and bgerror .tcl. I made the foreground red which is readable. I hate messing with the lib scripts though, is there a way I can do this from within the main script?


Category:

08/27/2003

DEBUGGING C/C++ EXTENSIONS

I am trying to write and debug a set of C/C++ extensions. I have complied them to the .so file with the -g flag. I can start my TK application and it loads the extension fine. When I use gdb to connect to the process, it loads the symbol table correctly for the extension, and I can access the names of functions and variables and set breakpoints on the function names. However, I cannot get gdb to access the source code to the extension, which makes setting break points within functions impossible. Does anyone know how to get this to work? I am currently using printf / cout statements, which does not seem very modern!

gtr Answered my own question. Or rather my colleague did - in our Makefile we has a "-s" flag to gcc, that strips all symbol information from the binary file. This appears to override the "-g" option. I have left the original question in case anyone runs into this difficulty.


Category:

05/Aug/2003

I want to compile a "C" program in windows/dos environment, which included tcl/tk also in that program. like #include <tclExtend.h> #include <tk.h> etc..

I compiled in linux by giving following options and its succeed.

$(BINDIR)/tcli: tcli.o $(DB_OBJECTS)

        cc -o $@ tcli.o $(DB_OBJECTS) -ltcl -ltclx -lm \
                -L/usr/X11R6/lib -lX11 $${REDHAT4_1:+-ldl}

But in dos version how can I compile from the command prompt, which options I have to mention and how ? I am having the VC++ in my system.

Could you please suggest me !!!

ANSWER: Use an existing VC++ project - and export or generate

        an NMAKE file - study the commands used in the file.

Category:

04/August/2003

   (Formerly 31/July/2003, with added details)

I am trying to analyze some hex numbers with odd size bit fields and was trying to write a tool to break up the bit fields. The problem is that I haven't been able to figure out how to enter hex numbers and have them not converted to decimal in the ENTRY field. It's hard to figure out if the rest of the code works when the display keeps changing to decimal on me. Thanks in advance!

Okay. I had vTCL write a GUI where I enter a number at the top which will be HEX in the final version. Then I have fields that allow entry of up to 16 bit-field sizes and a a display area for each field's value. The last element is a "doit" button. The code then figures out how many fields there are and for each field it uses shifts to eliminate all bits outside the current field with the field ending up in the low order bits so it can be displayed. Now that I have the basic GUI, I'll make all the other changes myself. Here's an example:

   Initial number is A5A5, divide it into a 5 bit field, a six bit field and a five bit field:

     15  14  13  12  11  10  9   8   7   6   5   4   3   2   1   0   <-- Bit number
   | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | <-- Bit Value
   -----------------------------------------------------------------
   | 1   0   1   0   1 | 0   1   0   1   0   1 | 0   1   0   1   0 | <-- Desired fields
           0x15                 0x15                   0xA           <-- Values of desired fields in HEX

The problem is the initial entry of the hex numbers. Here's my current entry command where I've tried to limit the input to hex digits, but it treats the entry as a decimal integer (I currently have to enter decimal to get it to take a number, so I had to increase the field size and chose 8):

     entry $base.ent61 \
         -background white -takefocus {} -textvariable RawHex -width 8 \
         -validate key -vcmd {expr {[string is xdigit %P] && [string length %P] < 8]}

FW: So does it treat the entry as a decimal integer, or actually convert it? You've said both.


Category:

Question (12 June 2003)

MAK I recently had a visually-impaired prospective customer, who uses a screen reader program called Jaws [L1 ] evaluating one of my products that uses Tcl/Tk for the GUI. I decided to try it myself to see how the GUI could be improved for such use. Not surprisingly there were some problems, mainly with some custom megawidgets that aren't really conducive to screen reader use, though many would be fairly simple to fix (such as allowing elements to take focus that currently don't). Some basic widgets/elements such as menus and text widgets seem to work okay, others like entry widgets don't, at least the way they're currently used. Some work partly: the text widget speaks when you select text, but for some reason my syntax highlighting causes only parts of the text (the non-highlighted parts) to be spoken.

Perhaps someone has experience writing screen-reader-friendly Tcl/Tk applications and could write a bit of a tutorial or tips page of some sort on developing Tcl/Tk applications that are compatible with screen readers? Thanks.

Note: I did see Speech Synthesis, or Talk to me Tcl but it seems like it might be better to make use of any features inherent in Tcl/Tk widgets to tie into Windows Accessibility features that a screen reader such as Jaws use. Some items work fine, so why not all?


Category:

Question (9 jun 2003) : I'm trying to compile a c++ dll library (under Windows 2000, using Dev-Cpp) that interfaces with tcl scripts. Even if I've linked the tcl83.lib and tk83.lib, and include tcl.h, I get the linking error: "undefined reference to _imp__Tcl_CreateInterp" and other similar. Same error if I try to compile a simple c/c++ program. The strangest thing is that, if I split the tcl functions in a testing procedure in the same file as the main it works. But as I use a different file for the procedure, the compiler gives the same linking error. Could anyone help me? Please write to: [email protected]


Answered Questions should be moved beneath the following line:


Category:

08/26/2003

INTERCOMMUNICATION

You start two wish-interpreters, wish1 and wish2. In wish1 you create a variable:

  % set x(val1) 0
  0

My question: How can I make x accessable for wish2? Thanks for all solutions or ideas! PB

FW: What OS are you using? Do you mean multiple executions of one interpreter, or a slave interpreter within one application? Are you developing cross-platform?

If you mean multiple applications, you're in luck by using Tcl, which is very strong for inter-application communication. Tk has a built-in send command, and the comm package provides similar functionality via sockets that works cross-platform.

It's even easier with slave interpreters - just look at the interp page to find out how to send commands to a slave interp.

PB: I'm using XP for this project and primarily I try to find an easy concept for an applications conversation and interp is my favorite now. Thank you...

FW: So does that mean you're using slave interpreters or separate applications?

PB: (curios?) I use slave interps althought separate applications would be better. therefore better because if master interp has a problem, slaves will have a problem too. sure, there are possibilities to catch and handle such cases, but that costs a lot of time and time is money. on the other side I have a problem to exchange common data using seperate applications because they run in different enviroments.

FW: Thanks for clarifying. Just use [interp eval] to run commands within the slaves. If and when you start using separate applications, I'd use the comm package (based on the venerable send) for inter-app communication.


Category:

14/Aug/2003

I am trying to define a data structure recursively and can't get it to work.

Any suggestions?

The idea is from: http://users.pandora.be/koen.vandamme1/papers/tcl_fileformats/tcl_fileformats.html

I would expect "A=atts" I would expect "B={atta bttb} {cttc dttd}" Then I would expect "A=pins" I would expect "B={pin4 four} {pin5 five}"

I do not get that. I have also tried numerous other things like concat, subst, etc... to no avail.

   proc mycommand { args } {

    foreach { a b } [concat $args] {
        puts "A=$a"
        puts "B=$b"
    }
   }

   mycommand {
    atts {
        { atta bttb }
        { cttc dttd }
    }

    pins {
        { pin4 four }
        { pin5 five }
    }
   }

tje Aug 20 2003 - Try this:

    proc mycommand {in} {foreach {a b} $in { puts "A=$a" ; puts "b=$b" } }

Remember that args is a special argument that wraps multiple arguments into one.



Category:

12/Aug/2003

Is there a method to emulate a third (middle) button by pressing both buttons together when using a two button mouse?

tje Aug 20 2003 - How about...

    bind Toplevel <ButtonPress-1> {set ::bp1 [clock clicks -milliseconds] ; catch emu2}
    bind Toplevel <ButtonPress-3> {set ::bp3 [clock clicks -milliseconds] ; catch emu2}
    bind Toplevel <ButtonRelease-1> {unset ::bp1}
    bind Toplevel <ButtonRelease-3> {unset ::bp3}
    proc emu2 {} {
        if {[expr abs($::bp1 - $::bp3)] <= 150} {event generate . <2>}
    }

Adjust the '150' to your liking for timing, and populate 'event generate' with stuff you need.

FW: Bear in mind you can often configure your window manager to globally emulate a 3-button mouse.


Category:

04/Aug/2003

When I am using "for_file" in windows version TCL/TK then I am getting error like invalid command name "for_file" while executing for_file std_msg c:/Tool/iisver {break}

Is for_file command is not exist in windows version, if so, then what's the best way to use in windows instead of for_file ?

lv for_file is a part of tclx. Make certain you have downloaded and installed that extension, and that your application includes a line such as

 package require Tclx

before you use for_file. RS: If you can't get TclX, see the for_file page.


Category:

04/Aug/2003

when I am using below systax executing in tcl/tk, then I am getting error. Syntax is

set dirinfo exec command.com/c dir

Error I am getting, when I am executing this is

'invalid command name "command.com/c"'

How can I execute this? Could you please suggest me.

lv does DOS bat magic help? - RS Put a space between the filename command.com and the switch /c. DOS shells can do without the space, but Tcl requires whitespace between words.


Category:

30/July/2003

I am facing some problems in tcl/tk windows version I am using tcl/tk 8.4.4.0 version on win 98. When I am using "exec" then I am getting errors. example: set msg exec c:\cssplit.exe; where cssplit is "C" program and cssplit.exe executable file, when executing this, it's giving error "child process exited abnormally while executing exec cssplit". when I am executing batch files then it's givng couldn't execute test-spec.bat no such file or directory, but file is existing, not only this what ever I give with "exec" command all are getting errors. Could you please suggest me to execute this command.

lv I suspect that the problem here is that cssplit is either producing output on stderr or returning a non-zero return code. See catch for a way to account for these two alternatives. Note that it is easier to answer a question when you show us exactly what you type and what the output in return is, than when someone tries to summarize; in cases of errors, more information is likely to be beneficial...

And another question is related to "ctoken". ctoken in windows version tcl/tk not working why? Is there any another method replacing this in windows version tcl/tk?

Could you kindly suggest me.

lv ctoken is a part of tclx, not of tcl. After you do a package require Tclx ; does that help any?


Category:

(JULY 30, 2003)

How does someone make interactive graphics with Tk? I mean, smooth presentations.

Environment of our program is somewhat loaded (many background checks for events), and redrawing of screen leaves it in grey background color for noticeable amount of time. It would be good to at least preserve old picture before draw anything new. What tricks or what methods do you use to achieve smooth Tk graphics performance?

SZ

lv by interactive graphics what do you mean? Smooth animation? SZ Yes, smooth change of pictures composed of text and images. When we destroyed previous frame with picture and creating new one we get gray (standard background) regions on a screen for a moment. What technique to use to avoid that? FW: Try reconfiguring the -file for the image, which (I believe) will redraw it without destroying anything.