Updated 2017-10-04 16:10:43 by bll

brad.lanam.comp _at_ gmail.com

Currently unemployed.

Tcl/Tk, C, perl, php, shell, MySQL/MariaDB, HTML, CSS, porting, legacy systems, system administration.


https://gentoo.com/ (registered 1992-03-26) No, this is not gentoo linux, they're at http://gentoo.org/ (registered 1999-10-04).


A ballroom music player written in tcl/tk.

All code I post here is under the MIT License.

Created Pages:

Major Contribution:

Bugs filed:

Window screen height/width returns height/width of primary display: [1]

Putting a window into fullscreen mode moves the window to the primary display: [2]

    set vx [winfo vrootx .] ; # so we can tell if monitors are 1-2 or 2-1
    set vy [winfo vrooty .]

    wm state $w zoomed
    set nsh [winfo reqheight $w]
    set nsw [winfo reqwidth $w]
    wm overrideredirect $w yes
    if { $vx < 0 } {
      set nx $vx
    } else {
      set sw [winfo screenwidth .]
      set nx [expr {$sw+1}]
    set ny 0
    wm geometry $w ${nsw}x${nsh}+$nx+0

(fixed) tk_getOpenFile crashes when passed a bad type variable (windows, new file interface) [3]

Workaround for bug in 8.6.3 tk_getOpenFile:
  # work around 8.6.3 bug
  if { $fn == {} || [regexp {^after#} $fn] } {


Using update rather than update idletasks prevents windows from putting the tk window into a not responding state.

tcltest's -relateddir doesn't sort the directories. This does not work if the tests are dependent on each other. Unfortunately, mine are. It is also a very poor choice for cross platform testing. This is fixed in a recent change (2016-7).

Windows starts up the tcl scripts with wish, which uses the wish icon. Starting with tclsh uses the icon set using 'wm iconbitmap'. So to get the wanted icon to display, restart the program with tclsh.
package require Tk

set tclsh [info nameofexecutable] 
if { [regexp {wish\d*.exe} $tclsh] } { 
  regsub {wish\d*.exe} $tclsh tclsh.exe tclsh 
  exec $tclsh [info script] & 
wm iconbitmap . -default [file join $myimages bdj_icon.ico] 

wm iconphoto only works with .gif files on windows, and only seems to allow a single image (despite the documentation).

ActiveState Tcl/Tk doesn't seem to get a dock icon. Everything seems to work with MacPorts Tcl/Tk.

Most of the issues here due to the way ActiveState Tcl works. If a tclkit is used, AppMain.tcl doesn't need to be used, and everything works pretty normally.

Mac OSX application name in menubar:

a) Symlink the application name to the wish executable.

a1) It seems that CFBundleExecutable has to be the same name as the application name (this seems a bit odd -- the python examples don't have this issue).

a2) I needed to run wish during the installation to get the real wish executable path. It seems that stdout gets completely lost. I had to open a file and save the output there, then I could retrieve the information from the output file in the postinstall script.

a3) info nameofexecutable will return the symlink in (a).

b) Create Resources/Scripts/AppMain.tcl. This script is executed when (a) is run. Always. So I use:
set script [file normalize [file join \
    [file dirname [file dirname [file dirname [info script]]]] \
    MacOS MyApp.tcl]]

if { $argc > 0 } {
  set script [lindex $::argv 0]
  set ::argv [lrange $::argv 1 end]

source $script

so that the appropriate script is run. This does have the advantage that the application name in the menubar stays intact.

In general (from what I've read) it seems that the python users using the symlink trick have fewer problems getting their application name in the menubar. CFBundleExecutable doesn't have to match the application name, there's no startup script. Why is tk more complicated?

Why shrinking a window doesn't shrink the widget you want it to: https://groups.google.com/forum/#!topic/comp.lang.perl.tk/ZYD71t2tYDk

It would be nice if there was a way to configure this. Why doesn't shrinking the window honor the '-expand true' flags?

(Expanding the window honors the weight/expand flags. Shrinking the window uses the packing order of the widgets)

Mac OS X:

# kbs does not check to see if required programs exist.

sudo port install cvs wget gmake # macports: probably more, but I may already have them installed

./kbs.tcl -CC=clang -make=gmake --enable-aqua --enable-64bit -r -mk-bi -bi="img1.4.6 tdom0.8.3" install kbskit8.6

This seems correct.

I cannot get kbs.tcl to work on windows.

I am trying tclkits from kitcreator, but these executables are not printing to stdout on windows.

APN I responded on c.l.t but the short answer is that you should be using the console mode tclkitsh or tclkit-cli, not the GUI mode tclkit.

I believe I have found the right options to build the tclkit. I will work on this some more.

What I did before with ActiveState Tcl was to use 'wish' in the shortcut to start the program. The program would then restart itself with tclsh so that icons would work. That's an ActiveState weirdness.

With tclkit, I will need to package up both tclkit-dyn and tclkit-gui with the Windows version so that the program can be started with the wish-like version so that there is no command window and restart with tclsh so that stdout works for the pieces that need it.

I was able to create Mac OS X and 64-bit Windows tclkits that include tdom.

  • Had to fix a compile error with kitcreator/kitsh.
  • STATICTK needs to be set to -1 for tclsh with an included Tk.
  • kitcreator also does not check to see if its prerequisites exist.
  • I ended up pulling the trunk version of tdom, not 0.8.3.
  • Msys2 mingwxx-tcl acts a little like wish, and during the build of kitsh, the window needs to be closed.

tdom is not building correctly (or something) under 32-bit Windows within the tclkit. When run, it cannot locate one of the gcc dll files.