Version 9 of Answered Questions to be classified

Updated 2004-11-01 19:17:48 by skm

Edit/Recent Changes


Navigation


Robert Abitbol Thursday 28 October 2004, 7h 48 pm

The Ask and you shall be given file is huge and I am having a proportionally huge headache working with it.

I will take 10 answered questions at a time from the Ask and you shall be given. monster, ask teclers to write a category and a title for them and I'll move the pages to the appropriate "Answered Question on".

Here is the first batch of 10.

Please write down the category and the title for each.

Thanks to yall!


2) Category Iwidgets bindings, Iwidget childsites

Title:

2004/11/1 sheila I moved my question on Iwidget bindings and childsites to a new page called Learning Iwidgets


3) Category:

Title:

2004/10/26

I have a tk script that does the following but the height/width options don't seem to make any difference. Thanks in advance.

    set mainframe [MainFrame .mainframe -menu $descmenu -height 1000 -width 1000 -textvariable Demo::status]
    set dversion "Dice version 2.00"
    $mainframe addindicator -text "BWidget [package version BWidget]"
    $mainframe addindicator -text "$dversion"
    pack $mainframe -fill both -expand yes

4) Category:

Title: How to invoke package require when the okg index file is byte-compiled

2004/10/20 sheila

How will I invoke package require if the pkgIndex file is byte-compiled? Will I need to alter tclPkgUnknown to also check for pkgIndex.tbc files? Should I call package unknown to get the handler name rather than assuming that it is handled by tclPkgUnknown?

For example, package.tcl has in one spot

 foreach file [glob -directory $dir -join -nocomplain \
  • pkgIndex.tcl] {

Which I can change to include pkgIndex.tbc, as below

 (test) 89 % ls
 C:/home/test:
 pkgIndex.tbc   pkgIndex.tcl
 (test) 90 % glob -directory [pwd] -nocomplain pkgIndex.tcl pkgIndex.tbc
 C:/home/test/pkgIndex.tcl C:/home/test/pkgIndex.tbc

I could go through tclPkgUnknown to scrub for places where pkgIndex.tcl is assumed

2004/11/1 sheila

I eventually posted this question in comp.lang.tcl and received some good feedback. TclApp has an option to to maintain the .tcl extension when wrapping code into a starpack.

http://groups.google.com/groups?threadm=i9ydnW05M-oy3eTcRVn-ow%40novus-tele.net


5) Category:

Title:

01/20/2004

Hello, I am having trouble with displaying scrollbars after loading a list in windows (98 & XP). I have been using the AutoScroll package [L1 ], however, when I load a list into a listbox, the first time the scrollbars appear, they are disabled, even though my list is longer than the size of the listbox displayed. However, when the window is modified, or the mouse is moved within the listbox, then the scrollbar activates, and remains activated until the window is closed. The problem with deactivated scrollbars only happens once, and once the scrollbars are activated, then the scrollbars begin to function correctly.

Does anyone have any suggestions as to what I may be doing wrong, or what I can do to fix this?

The code below can clearly show what my problem is. If you click on Load once, you will notice inactive scrollbars.

Thanks in advance for your assistance! :0) ~KND

 # remove the following line if autoscroll is on the package path
 source autoscroll.tcl

 package require autoscroll
 namespace import ::autoscroll::autoscroll

  #create a frame for listbox area
  frame .fr

   listbox .fr.list -width 40 -height 10 \
       -yscrollcommand [list .fr.y set] -xscrollcommand [list .fr.x set] \
       -font {Courier 12}
   scrollbar .fr.y -orient vertical -command [list .fr.list yview]
   scrollbar .fr.x -orient horizontal -command [list .fr.list xview]

   grid .fr.list -row 0 -column 1 -sticky nsew
   grid .fr.y -row 0 -sticky ns \
       -column 2; # change to -column 0 for left-handers
   grid .fr.x -row 1 -column 1 -sticky ew

   grid columnconfigure . 1 -weight 1
   grid rowconfigure . 0 -weight 1

   autoscroll .fr.x
   autoscroll .fr.y

  grid .fr -column 0 -row 0

  # create buttons to appear below listbox
  button .button -text "Load List" -command {loadList} 
  grid .button -column 0 -row 1 -sticky news

  button .button2 -text "Remove List" -command {.fr.list delete 0 end}
  grid .button2 -column 0 -row 2 -sticky news

  #Procedure to add 25 items to the list.
  proc loadList {} {
   for { set i 1 } { $i < 26 } { incr i } {
     .fr.list insert end "$i This is a long List, isn't it?  Yes, Very Long."
   }
  }

6) Category:

Title:

01/20/2004

Hi. With interp-concept I've a small problem in understanding. I hope someone can help me.

My claim is to create a parent-application, which creates and controls it's children. Each child has a special job. (e.g. checking files in a directory for modifying) The idea is that each child gives regulary an alive-sign to parent (e.g. in a global var). parent checks this sign an set it back. if some child can't renew it's state parent kills the prozess and restart it. what I need is a common channel for direct communication, a common access to a global variable. Does someone knows how I can solve that problem?

fw I thinks there are two ways, using "signal" command or pipe communication. Since parent and child are independent processes, they cannot have common(share) memory.

In using "signal", child process sends signal to parent process in period. parent apply event for some signal by using "signal trap ...", and if gets signal, some action performs. You may see "signal", "kill" command and UNIX signals.

On other way, in tclx(tcl extension), "pipe" command can enalble communication for two processes. you may see "pipe", "fork" command in tclx.

Nams.

I understand. My applications are independent processes and, you are right, they couldn't share their enviroment. But while reading your answer I had another idea: I could use simple network-sockets. So I'm be able to have common pipe for exchanging data ...


7) Category:

Title:

Jan-19-2004

Hi, I am nams.

"exec" command cannot return binary data into stdout

In linux, I runs like this :

 set msg [exec tcl read_binary.tcl]

"read_binary.tcl" puts binary data into stdout. "read_binary.tcl" works well by executing "exec tcl read_binary.tcl > temp.dat". But "msg" has only PARTIAL data of whole binary data. I changes stdout into binary using "translation" option of "fconfigure" command, but gets same result.

If "read_binary.tcl" puts not binary but text data into stdout, "exec" command returns whole text data well.

In the result of test, "exec" command cannot return binary data, but return text data well.

What's problem or any solution?

Regards from Nams. Thank you. :)

BR - 2004-01-20 - With exec you can not control the encoding of the data in the calling app, that's your problem. Try open instead like this (untested)

  set pipe [open "|tcl read_binary.tcl" r]
  fconfigure $pipe -encoding binary -translation binary
  set binarydata [read $pipe]
  close $pipe

8) Category:

Title:

MSH 2003/12/12 Does anyone know if it is possible to write to the real stdout from wish under windows ? I have a Tcl/TK program which has a command line fo rbatch control but when called from a batch file I cannot puts to the Msdos window to give user feedback. TCL/TK 8.4.2 with freewrap. PS I added this question to 'Ask, and it shall be given # 2' with no success, does any one read that page ?

BR - 2003-12-14 - wish.exe on Windows doesn't have a stdout, no. That is a consequence of being a Windows GUI app. With 8.4.2, you should be able to use tclsh84 instead. You need to add a "package require Tk" to the top of your script to load Tk as an extension, unless the script already has that. That statement doesn't do any harm if the script is actually executed in wish.exe, so you don't need a separate script for this.


9) Category:

Title:

December 9, 2003

Hi, Do anyone know how different between "lsearch" and "info exists" in tcl 8.0?

I has 50,000 fixed-lists and 80,000,000 urls. I test whether url is in fixed-list by using "lsearch".

In other way, I make arrays of fixed-lists and test whether url is in fixed-list by using "info exist"

In result, "info exist" has more faster at least 5 times than "lsearch". What difference?

Regards from Nams. Thanks!

schlenk Basically lists are lists and arrays are arrays. ;-) lsearch operates on a list and has to do a linear search, info exists on an Tcl array is basically a check in a hash table which has more or less O(1), but needs a little bit more memory. For your use case arrays are the better solution.


10) Category:

Title:

December 03, 2003

Does anyone know how to disable a listbox? I have searched hi and low and it seems like this scenario is not common. What I need to do with my listbox is to select one item from the listbox, and then, when a start button is pressed, a user should not be able to change the selection on the listbox. I have used the single selectmode when defining my listbox.

Any help is greatly appreciated! Thx.

-K.

FW: All you have to do is change the binding for a click to do nothing. To disable the widget, just do:

 bind .a <1> break