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

how to remove icon from taskbar in win10 (move to tray)

103 views
Skip to first unread message

two...@gmail.com

unread,
Aug 8, 2018, 7:55:23 PM8/8/18
to
I wrote a tcl/tk app on windows 10. It will run all the time so I'd like to remove it from the windows taskbar and move it to the system tray.

I found in twapi a way to setup the tray icon, but I can't figure out how to remove the big feather icon from the taskbar area. Is there a way to do this in a tcl program?

Ashok

unread,
Aug 9, 2018, 1:04:08 AM8/9/18
to
Bind to <Unmap> to withdraw the window.

Something along the lines of (cut'n'pasted from a working app but not
tested separately)

bind $::mainWin <Unmap> "+minimize %W"

proc minimize {win args} {
if {$win ne $::mainWin} return

# A second binding can fire when we withdraw below so ignore that
# else might fire the event continuously
if {[wm state $win] eq "withdrawn"} return

wm withdraw $::mainWin
}

I'm only a dabbler in Tk so there might be a better way.

/Ashok

two...@gmail.com

unread,
Aug 9, 2018, 1:14:19 PM8/9/18
to
On Wednesday, August 8, 2018 at 10:04:08 PM UTC-7, Ashok wrote:
> Bind to <Unmap> to withdraw the window.
>
> Something along the lines of (cut'n'pasted from a working app but not
> tested separately)
>
> bind $::mainWin <Unmap> "+minimize %W"
>
> proc minimize {win args} {
> if {$win ne $::mainWin} return
>
> # A second binding can fire when we withdraw below so ignore that
> # else might fire the event continuously
> if {[wm state $win] eq "withdrawn"} return
>
> wm withdraw $::mainWin
> }
>
> I'm only a dabbler in Tk so there might be a better way.
>
> /Ashok
>


Thanks, that worked for me.

The only thing left is how to remove the windows tray icon on exit. Right now, it stays until I hover over it with the mouse, then it goes away.


The code I'm using comes from the wiki, as follows:

package require twapi_resource
package require twapi_shell
package require twapi_ui
# Create with X
set ID [twapi::systemtray addicon [twapi::load_icon_from_system hand] cb]
# Change to Triangle NAME must be one of sample, hand, ques, bang, note, winlogo, warning, error, information or shield.
twapi::systemtray modifyicon $ID -hicon [twapi::load_icon_from_system bang]
# Set tooltip help
twapi::systemtray modifyicon $ID -tip "New Tooltip"

proc cb {ID Message lPos TimeStamp} {
lassign $lPos xPos yPos
switch $Message {
select - keyselect {
# click action here
}
contextmenu {
if {![winfo exists .guiWinicoPopup]} {
menu .guiWinicoPopup -tearoff 0
.guiWinicoPopup add command -label "exit" -command {exit}
.guiWinicoPopup add command -label "restore" -command {wm deiconify .}
}
set hWinNotify [::twapi::Twapi_GetNotificationWindow]
::twapi::set_foreground_window $hWinNotify
.guiWinicoPopup post $xPos $yPos
.guiWinicoPopup activate 0
::twapi::PostMessage $hWinNotify 0 0 0
}
}
}


Mike Griffiths

unread,
Aug 9, 2018, 4:33:10 PM8/9/18
to

two...@gmail.com

unread,
Aug 9, 2018, 10:05:58 PM8/9/18
to
On Thursday, August 9, 2018 at 1:33:10 PM UTC-7, Mike Griffiths wrote:
> See http://twapi.magicsplat.com/v3.1/shell.html#systemtray%20removeicon
>
>
Thanks, that did it.

Alexandru

unread,
Aug 11, 2018, 5:10:16 AM8/11/18
to
Am Donnerstag, 9. August 2018 01:55:23 UTC+2 schrieb two...@gmail.com:
> I wrote a tcl/tk app on windows 10. It will run all the time so I'd like to remove it from the windows taskbar and move it to the system tray.
>
> I found in twapi a way to setup the tray icon, but I can't figure out how to remove the big feather icon from the taskbar area. Is there a way to do this in a tcl program?

I read the Twapi description and I'm doing the same thing as you. One question: How do I specify the Icon? There are no details regarding the icon on the Twapi help page.

Harald Oehlmann

unread,
Aug 12, 2018, 3:23:04 PM8/12/18
to
Maybe, the section "Tray Icons using TWAPI" on http://wiki.tcl.tk/4089
may help you ?

Enjoy,
Harald

Alexandru

unread,
Aug 12, 2018, 4:10:13 PM8/12/18
to
Cool. Thanks, that helped. The twapi::load_icon_from_* was missing for me.
From https://stackoverflow.com/questions/31200418/loading-icon-from-kit-using-twapi I found the alternative to system icons so that I can set own icons.
0 new messages