Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:16:27+00:00 2026-05-25T19:16:27+00:00

I recently upgraded to the development release of wxPython (wxPython 2.9.2.4) since I needed

  • 0

I recently upgraded to the development release of wxPython (wxPython 2.9.2.4) since I needed the functionality of wx.NotificationMessage within my application. I have been trying unsuccessfully to create notification bubbles on certain user events due to something I think might be a possible bug. Before submitting such bug, I wanted to go ahead and ask the people of the mailing list what they think might be the problem and hopefully find a solution from within my code.

Here is the code I have used:

import wx, sys

app = wx.PySimpleApp()

class TestTaskBarIcon(wx.TaskBarIcon):

    def __init__(self):
        wx.TaskBarIcon.__init__(self)
        # create a test icon
        bmp = wx.EmptyBitmap(16, 16)
        dc = wx.MemoryDC(bmp)
        dc.SetBrush(wx.RED_BRUSH)
        dc.Clear()
        dc.SelectObject(wx.NullBitmap)

        testicon = wx.EmptyIcon()
        testicon.CopyFromBitmap(bmp)

        self.SetIcon(testicon)
        self.Bind(wx.EVT_TASKBAR_LEFT_UP, lambda e: (self.RemoveIcon(),sys.exit()))

        wx.NotificationMessage("", "Hello world!").Show()

icon = TestTaskBarIcon()
app.MainLoop()

On my Windows 7 computer, the code creates a small white task bar icon and creates a popup with the phrase “Hello World!”. The problem? The message is not on my icon. Another icon is being created and the message is being placed there.
See this image:
http://www.pasteall.org/pic/18068″>

What I thought was that this is probably due to the fact that I have passed no parent parameter on line 22:

wx.NotificationMessage("", "Hello world!").Show()

Here is what I changed it to:

wx.NotificationMessage("", "Hello world!", self).Show()

Where ‘self’ refers to the task bar icon. When I do that, I get an error:

Traceback (most recent call last):
  File "C:\Python27\testnotificationmessage.py", line 24, in <module>
    icon = TestTaskBarIcon()
  File "C:\Python27\testnotificationmessage.py", line 22, in __init__
    wx.NotificationMessage("", "Hello world!", self).Show()
  File "C:\Python27\lib\site-packages\wx-2.9.2-msw\wx\_misc.py", line 1213, in __init__
    _misc_.NotificationMessage_swiginit(self,_misc_.new_NotificationMessage(*args))
TypeError: in method 'new_NotificationMessage', expected argument 3 of type 'wxWindow *'

What’s going on? If I remove that argument, I don’t get my result, if I add the argument, I get an error! How am I supposed to use wx.NotificationMessage with a wx.TaskBarIcon!

Please help! I hope I’ve provided enough details. Please comment if you need more!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:16:28+00:00Added an answer on May 25, 2026 at 7:16 pm

    I would not recommend using 2.9 just yet. I have encountered some strange bugs when trying it out.

    You can have the same functionality in 2.8. I am using somewhat modified code that I have found some time ago.

    import wx, sys
    
    try:
        import win32gui #, win32con
        WIN32 = True
    except:
        WIN32 = False
    
    class BalloonTaskBarIcon(wx.TaskBarIcon):
        """
        Base Taskbar Icon Class
        """
        def __init__(self):
            wx.TaskBarIcon.__init__(self)
            self.icon = None
            self.tooltip = ""
    
        def ShowBalloon(self, title, text, msec = 0, flags = 0):
            """
            Show Balloon tooltip
             @param title - Title for balloon tooltip
             @param msg   - Balloon tooltip text
             @param msec  - Timeout for balloon tooltip, in milliseconds
             @param flags -  one of wx.ICON_INFORMATION, wx.ICON_WARNING, wx.ICON_ERROR
            """
            if WIN32 and self.IsIconInstalled():
                try:
                    self.__SetBalloonTip(self.icon.GetHandle(), title, text, msec, flags)
                except Exception:
                    pass # print(e) Silent error
    
        def __SetBalloonTip(self, hicon, title, msg, msec, flags):
    
            # translate flags
            infoFlags = 0
    
            if flags & wx.ICON_INFORMATION:
                infoFlags |= win32gui.NIIF_INFO
            elif flags & wx.ICON_WARNING:
                infoFlags |= win32gui.NIIF_WARNING
            elif flags & wx.ICON_ERROR:
                infoFlags |= win32gui.NIIF_ERROR
    
            # Show balloon
            lpdata = (self.__GetIconHandle(),   # hWnd
                      99,                       # ID
                      win32gui.NIF_MESSAGE|win32gui.NIF_INFO|win32gui.NIF_ICON, # flags: Combination of NIF_* flags
                      0,                        # CallbackMessage: Message id to be pass to hWnd when processing messages
                      hicon,                    # hIcon: Handle to the icon to be displayed
                      '',                       # Tip: Tooltip text
                      msg,                      # Info: Balloon tooltip text
                      msec,                     # Timeout: Timeout for balloon tooltip, in milliseconds
                      title,                    # InfoTitle: Title for balloon tooltip
                      infoFlags                 # InfoFlags: Combination of NIIF_* flags
                      )
            win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, lpdata)
    
            self.SetIcon(self.icon, self.tooltip)   # Hack: because we have no access to the real CallbackMessage value
    
        def __GetIconHandle(self):
            """
            Find the icon window.
            This is ugly but for now there is no way to find this window directly from wx
            """
            if not hasattr(self, "_chwnd"):
                try:
                    for handle in wx.GetTopLevelWindows():
                        if handle.GetWindowStyle():
                            continue
                        handle = handle.GetHandle()
                        if len(win32gui.GetWindowText(handle)) == 0:
                            self._chwnd = handle
                            break
                    if not hasattr(self, "_chwnd"):
                        raise Exception
                except:
                    raise Exception, "Icon window not found"
            return self._chwnd
    
        def SetIcon(self, icon, tooltip = ""):
            self.icon = icon
            self.tooltip = tooltip
            wx.TaskBarIcon.SetIcon(self, icon, tooltip)
    
        def RemoveIcon(self):
            self.icon = None
            self.tooltip = ""
            wx.TaskBarIcon.RemoveIcon(self)
    
    # ===================================================================
    app = wx.PySimpleApp()
    
    class TestTaskBarIcon(BalloonTaskBarIcon):
    
        def __init__(self):
            wx.TaskBarIcon.__init__(self)
            # create a test icon
            bmp = wx.EmptyBitmap(16, 16)
            dc = wx.MemoryDC(bmp)
            dc.SetBrush(wx.RED_BRUSH)
            dc.Clear()
            dc.SelectObject(wx.NullBitmap)
    
            testicon = wx.EmptyIcon()
            testicon.CopyFromBitmap(bmp)
    
            self.SetIcon(testicon)
            self.Bind(wx.EVT_TASKBAR_LEFT_UP, lambda e: (self.RemoveIcon(),sys.exit()))
    
            self.ShowBalloon("", "Hello world!")
    
    icon = TestTaskBarIcon()
    app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently upgraded my SharePoint development machine to VSeWSS 1.3 and have noticed a
I have recently upgraded to Rails 3 and created a new application with Rails
I recently upgraded my (Windows 7) development environment to Eclipse 3.7.1 (Indigo). I have
I recently upgraded a 1.3.6 application to Grails2. My test cases have started failing
I recently upgraded VS 2005 to VS 2008. Unfortunately I have a very basic
I recently upgraded a Web Application Project (as well as some dependent projects) from
I recently upgraded a 1.1 web project to a 2.0 web application. After going
I've recently upgraded my development machine from Windows XP to Windows 7. How can
I recently upgraded Xcode to start ios5 development, but for some reason I encounter
I recently upgraded to Xcode 4.2, for SDK 5.0 support, but since I've done

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.