Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Replace wish's taskbar icon with another?

236 views
Skip to first unread message

Dave

unread,
Apr 25, 2015, 3:18:17 PM4/25/15
to
This is for Win7x64 with Active State's Tcl

I've tried both the twapi* and winico** packages. Both allow me to
create a >new< taskbar icon. However the original icon for wish remains.
Is there a way to >replace< wish's icon in the taskbar with my own? (Or
at least remove wish's icon so that only my custom icon remains?)

* "twapi::systemtray removeicon" leaves the icon visible until the mouse
moves over the icon--then it disappears. I don't know if this is a bug...

** I found a version of winico that compiles with the MingGW 64-bit gcc
for windows: https://github.com/vitalyster/winico

--
computerjock AT mail DOT com

JMar...@comcast.net

unread,
Apr 25, 2015, 5:43:45 PM4/25/15
to
This is how I do it with TWAPI:

#-- this path must be absolute, because the Windows API LoadImage is called
#-- within the twapi call
set szImageName [ file join $szImagesPath Menu.ico ]
set i [ twapi::load_icon_from_file $szImageName ]
set j [ twapi::systemtray addicon $i TbarHandle ]
twapi::systemtray modifyicon $j -tip "left-click to de-iconify, right-click for menu"
set taskbar_menu [ menu .popup -tearoff 0 ]
$::taskbar_menu add command -label Show -command show_application
$::taskbar_menu add command -label Exit -command exit

Olivier

unread,
Apr 25, 2015, 6:36:50 PM4/25/15
to

> Is there a way to >replace< wish's icon in the taskbar with my own? (Or
> at least remove wish's icon so that only my custom icon remains?)
>

Hi !

You may create a shortcut to Tcl/bin/wish.exe and change its icon with your custom icon. When moving your script to this shortcut, using the mouse pointer, this icon will appear in the taskbar. A "bat" file should work but I don't have the syntax in my mind... I had it..

Olivier.

Dave

unread,
Apr 25, 2015, 8:18:21 PM4/25/15
to
Unfortunately, the icon for wish is still there. I was hoping for a way
to remove/replace wish's icon.

Out of curiosity, does your app's icon disappear when the app exits or
does it remain visible in the system tray until you move the mouse over it?

I'm on Win7x64, Active State Tcl 8.5.17, twapi 4.0.61 (bundled w/ Active
State Tcl)

Dave

unread,
Apr 25, 2015, 8:22:10 PM4/25/15
to
Thanks, I was aware of that but it's sort of a pain to setup the
shortcut (and provide instructions if I share my app to someone else)
so I was hoping there was a completely scriptable solution.

Olivier

unread,
Apr 26, 2015, 6:10:42 AM4/26/15
to

> >
> >> Is there a way to >replace< wish's icon in the taskbar with my own? (Or
> >> at least remove wish's icon so that only my custom icon remains?)
> >>

Then, the ultimate solution is to create your executable ( tlckit, freewrap... ) and change its icon through this kind of utility : http://www.restuner.com/howto-replace-an-icon.htm . You are not theoricaly allowed to change directly icon in ActiveState "wish" . For Freewrap, trimming the icon is not straightforward as the choice of icons is very specific in size and colors. On the other hand, letting the "feather" or "ActiveState" icon is also a good bet to let Tcl/Tk spread the World !!

Olivier.

JMar...@comcast.net

unread,
Apr 26, 2015, 11:25:30 PM4/26/15
to
Yes, sometimes the icon remains in the task bar and doesn't remove until I move the mouse over it.

If the wish icon is remaining, then your code isn't finding your icon file. Try this - add a "package require Tk" statement at the top of your code and run it from the command prompt. You should see an error if your icon file is not found.

Dave

unread,
Apr 28, 2015, 12:42:52 PM4/28/15
to
This is a bit off my original question but the above problem was my
fault for not using "twapi::systemtray remove_icon". After fixing that,
running the app using tclsh from the command line gives no error: both
wish's icon and my icon appear in the system tray and both icons are now
removed when the app exits.

As mentioned by Oliver in response to my original question, it seems
that the only way to remove the wish icon is to create a starkit or
something like that for my app. That's more trouble than I'm willing to
undertake for an app that I'd share with one other person max. I'll just
tell them how to create a shortcut.

FWIW, here's my test app:

package require Tk
package require twapi

button .quit -text quit -command Quit
pack .quit

proc TbarHandle { id event loc time } {
switch -exact $event {
"lbuttondown" {
switch -exact [wm state .] {
normal {
wm iconify .
}
iconic -
withdrawn {
wm deiconify .
}
}
}
}
}

proc Quit {} {
twapi::systemtray removeicon $::iconid
twapi::free_icon $::hicon
exit
}

set hicon [ twapi::load_icon_from_file BL2Logo.ico ]
set iconid [ twapi::systemtray addicon $hicon TbarHandle ]

Brad Lanam

unread,
Apr 29, 2015, 7:49:00 PM4/29/15
to
Well, a bit of overhead just to get an icon, but it does work.

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

Dave

unread,
Apr 29, 2015, 10:08:25 PM4/29/15
to
So it does! Very interesting!

I don't need twapi at all with this approach.

My terminology will not be exact since I'm not really a windows guy, but
I'm guessing that this works because tclsh.exe is a "console" executable
and wish.exe is a "windows" executable?

Brad Lanam

unread,
Apr 29, 2015, 10:20:30 PM4/29/15
to
On Wednesday, April 29, 2015 at 7:08:25 PM UTC-7, Dave wrote:
> I don't need twapi at all with this approach.

Yes, I think 'wm iconbitmap' (or wm iconphoto, which seems buggy on windows) does all that work for you.

> My terminology will not be exact since I'm not really a windows guy, but
> I'm guessing that this works because tclsh.exe is a "console" executable
> and wish.exe is a "windows" executable?

I'm not a windows person either. That's probably correct.
0 new messages