TaskBarIcon not displaying on Windows 7

Hi,

when the attached minimal app is run on a Windows 7 box (64-bit,
Python 2.7.1, wx 2.8.11.0 - stock install from exe) from a command
shell like: c:\python27\python.exe test_app.py

the window title icon and the alt-tab icon is set correctly, but the
task bar icon is set to the python default (its the python.exe icon)

what am I doing wrong?

(incidently the stock install of the wxDemo exibits the same behavior
- the task bar icon is the python default)

thanks,

Jeff

···

-----------

import wx
from wx.lib.embeddedimage import PyEmbeddedImage

games = PyEmbeddedImage(

"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABsZJ"
    "REFUWIXNlntQVOcZxp+zeziHXZZld9kb93ARUZB6AW
+sBS1WShMl1mkKdpJpMpmMTNJk0tRk"
    "Gm9pMpM0IY5JjWMy02ZqMGmNrWG8FCOJgkqViBql4brAuizLsste2Os5Z/ec/
iFOE2SFBNLp"
    "8+f3zfe+v+99n+8C/D+rc/d8scSwPa+2vj/7+8ohijahzF311IHIY+by
+3ydQydf6d316t5r"
    "I6xsw1wDiKcafPhAu04RMDYNW4bjV+anIzNVS3Acp0+U7KnRpGQGLjZ/
3jpXAES0idMXr9bu"
    "3vHiH8p/
uEq2rtQA2+goOI5DZlYObx6PbKr5ieHEXABEbcGGkqUHHBFJUVZWdt9rdfvQerkd"
    "EYFAY2Oj6FrL6bcUO+30XABMq6OfXV50pqkpsrqkRCAIQhCJxMIvqquFH1duevp/
AgAATZ+d"
    "7W5paREeeGCjAIIQKIoSdu75ve3Jj27FzzZ21BZ8XYcbmh498/
lZQSqXg46TgeU4HK4/pP3d"

"BtUzswWYkZrPrhG9+PKrDarkFCFBpxfilCoBgFBZ9aDrgD1WNZvYM6pA6drzfKKE3PzEU8/
s"
    "paQSgZbLEZuQgAvN5xSSC0eemw3At9bZLuO2lPwCXpObK4hpWlhQXDyufuldzXeNF/
UeuJe2"
    "bX/hixONp4oCHg+Y8XG89Mbev5AJunrjmNOqaZ3ft/
NQMfO9AawoKTFIpL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vo+6bh5Y2vXV/9+2u/
zQSwWwzJk"
    "ERyOU0RSUjLmzc9DolYLlSweSqUSAoBgKIRxrxdjDgd6urvR3dOD/v5+FC5ZevOPe
+sOAhgG"
    "wE3lt7sATKb+JrVGvck95nqQEBHFUpnsUrxcfo6mqNxQMPiz/t7uQiboJ
+Li5WACfpiMvXA5"
    "neju6oTFYgHDshARBGQyGWwOx3uBQGBgqp3fUbSLKBaAAoB8YrELtw2rKSpaUZF
+X1pdcnIy"
    "abVa0dXZCfvoKBcMBs0EQQzGxFBOkqJKwUcSUzMyytvb2loARKIB3FWBCYUAjOC/
prljHM/o"
    "qPXQytWrqtMy0lZ8ef1616jd/meG4254vV4nAN/9VVVau81WabOOfNre1tYLgI
+SA8D0jxGP"
    "b7o20te31TNktZ4639IiPLGtNuuD
+g9zS35UYXtu12uCPyysLVq2fD9FUWGWZd4EMDZp/V36"
    "Tv+B9PR0pVqtfUyA8NvSdeu0pWVl4DgOIzYbLrVexJVLbW/
09HS9iSmO3ZwATKxLyMrKyhGJ"
    "yEdYlllDxpCxbrfbJhaJztvt9nrcPnZTOn8uAO4oBrfNqgJATyT04HbpZ/
Qrmi3AHYkmYgmY"
    "xnST9R94X+IxKHx+VgAAAABJRU5ErkJggg==")

getgamesData = games.GetData
getgamesImage = games.GetImage
getgamesBitmap = games.GetBitmap

class TaskBarFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        self.tbicon = wx.TaskBarIcon()
        icon = games.getIcon()
        self.tbicon.SetIcon(icon, 'task bar frame')
        self.SetIcon(icon)

app = wx.App(False)
frame = TaskBarFrame(None)
frame.Show(True)
app.MainLoop()

Your application is working fine here, including your icon
that appears in the taskbar: Linux Debian sid & wx V. 2.12.1.-6

It may be a w$ feature...

BTW thanks for that: I was asking myself how to achieve that :wink:

···

On Wed, 4 Jan 2012 06:01:01 -0800 (PST) Jeff <jeffreback@gmail.com> wrote:

the window title icon and the alt-tab icon is set correctly, but the
task bar icon is set to the python default (its the python.exe icon)

what am I doing wrong?

--
A life spent in search of the perfect hash brownie is a life well
spent.

I can confirm that this code doesn’t work on my Windows 7 box either. What’s weird is I have code that uses the SetIcon() method in one of my production apps that DOES work. I wonder if the icon has to be a certain minimum size for it to be applied for the frame’s title icon? I’m sure Robin will know.

···

Mike Driscoll

Blog: http://blog.pythonlibrary.org

IIRC the main taskbar icon comes from the executable now instead of from the frame, probably because by default all frames of an application are stacked on one icon. If you use py2exe or similar to make an executable, and have it set the same ico file as the icon for the .exe, then you will see the expected icon on the taskbar.

···

On 1/4/12 6:01 AM, Jeff wrote:

Hi,

when the attached minimal app is run on a Windows 7 box (64-bit,
Python 2.7.1, wx 2.8.11.0 - stock install from exe) from a command
shell like: c:\python27\python.exe test_app.py

the window title icon and the alt-tab icon is set correctly, but the
task bar icon is set to the python default (its the python.exe icon)

what am I doing wrong?

(incidently the stock install of the wxDemo exibits the same behavior
- the task bar icon is the python default)

--
Robin Dunn
Software Craftsman

So the task bar icon is not availabe to wx programatically at all? (as
an aside - if I create the main frame with style=wx.FRAME_NO_TASKBAR,
then it does the correct
thing - e.g. no taskbar icon at all)

Is there any other option if I don't want to use py2exe?

I run this app in a shared code environment (via samba/nfs), so I can
easily just make a change and not have to worry about propogation,
thus py2exe is not as attractive to me

···

On Jan 4, 12:55 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 1/4/12 6:01 AM, Jeff wrote:

> Hi,

> when the attached minimal app is run on a Windows 7 box (64-bit,
> Python 2.7.1, wx 2.8.11.0 - stock install from exe) from a command
> shell like: c:\python27\python.exe test_app.py

> the window title icon and the alt-tab icon is set correctly, but the
> task bar icon is set to the python default (its the python.exe icon)

> what am I doing wrong?

> (incidently the stock install of the wxDemo exibits the same behavior
> - the task bar icon is the python default)

IIRC the main taskbar icon comes from the executable now instead of from
the frame, probably because by default all frames of an application are
stacked on one icon. If you use py2exe or similar to make an
executable, and have it set the same ico file as the icon for the .exe,
then you will see the expected icon on the taskbar.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

IIRC the main taskbar icon comes from the executable now instead of from the frame, probably because by default all frames of an application are stacked on one icon. If you use py2exe or similar to make an executable, and have it set the same ico file as the icon for the .exe, then you will see the expected icon on the taskbar.

I haven't investigated this too deeply yet (so I might be wrong about this), but I think it might be possible to alter the icon on the Taskbar programmatically. As far as I can tell, it might involve using SHGetPropertyStoreForWindow (which is necessary to customize a window's taskbar pinning behavior anyway). Or at least, something related to Win7's new Taskbar APIs.

Robert O'Connor

···

From: Robin Dunn
Sent: Wednesday, January 04, 2012 12:55 PM