Using “boomy” icons with tcl/tk

I spent some time over the last few days trying to populate the TK images folder with a usable image library. The activestate version and the standard only permits the use of .gif images in the image manipulation commands. (Not true now, see the comments!) I might need to look at the tkImg package to use an alternative format. Continue reading “Using “boomy” icons with tcl/tk”

What’s my IP address?

Useful question, this is how I answer it on my windows systems.

Its a TCL/TK script that invokes the windows XP shell command ping.

info

As noted, I use an information graphic to decorate the box. This is not part of activestate’s tcl/tk distribution, and thus needs to be copied to $tklibrary/images. (See also Scripting on Windows, on this wiki.)

I am not happy with the triming of the ip address, which is displayed into the address variable using square brackets. Since these have a specific syntactical meaning, I can’t find the syntax to remove them from the string.

wm title . {Query site ip?}
wm iconname . {Query site ip?}
wm geometry . 225x65+500+100
# This is not part of the package, it needs to be copied here 
image create photo infopic -file [file join $tk_library images info.gif]

set pingreply {} 
# windows XP 
set pingreply [exec ping -n 1 davelevy.info] 
set address [ lindex $pingreply 2 ] 
# only tested on one ip address, do I need to subtract two from length 
# to remove the first and last. What is the syntax to remove leading and 
# trailing []. 

set daddress [string range $address 1 [expr [ string length $address ] - 2]]
set messagetext " public tcp/ip no : $daddress" 
set buttontext " Done "

frame .top 
frame .bottom

label .top.icon -image infopic 
frame .top.f -width 50 label .top.f.mess -text $messagetext

pack .top.f.mess -side top -fill x 
pack .top.icon .top.f -side left
button .bottom.dismiss -text $buttontext -command "exit" 
pack .bottom.dismiss pack .top .bottom

proc exit {} { destroy . }

The script can be downloaded whatsmyip.zip.

Chris advises that

set daddress [string trim $address {[]} ]

removes the brackets from the address and is obviously much neater and is character based. It implements a remove the unwanted character rule, not remove the first and last characters.

External Disk on an XP system

This article was originally written in 2008, and was copied to this wiki in June 2013. It covers both moving XP windows directories from the internal local drive to the external disk, and some wish scripting to check the disk was on and remind people to turn it on if not already done. This article talks about the disk, filesystems, transferring the data, and writing some tcl/tk scripts including an motd to manage the remote “My Documents” folder. I changed the title from “External Disk on the Dell” since I had re-purposed the disk by 2013. Continue reading “External Disk on an XP system”