Testing on Linux Mint 22.3.
When I ran the NotificationMessage example from the wxPython Demo on 4.3.1, I noticed that no notification appeared when I pressed the button and no error messages appeared in the terminal. However, the same code on 4.2.5 does show a notification.
Here is a simplified standalone version of the example:
import wx
import wx.adv
class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
self.btn = wx.Button(self, -1, "Notify me of something...!", pos=(50,50))
self.btn.Bind(wx.EVT_BUTTON, self.OnButton)
def OnButton(self, event):
notify = wx.adv.NotificationMessage(
title="This is a Notification!",
message="wxPython is awesome. Phoenix is awesomer! Python is awesomest!!\n\n"
"The quick brown fox jumped over the lazy dog.",
parent=None, flags=wx.ICON_INFORMATION)
notify.Show(timeout=5)
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
self.SetSize((300, 200))
self.SetTitle("Test Notification Message")
TestPanel(self)
self.Layout()
if __name__ == '__main__':
app = wx.App()
frame = TestFrame()
frame.Show()
app.MainLoop()
I also downloaded the following raw test files from the master branch on GitHub:
https://github.com/wxWidgets/Phoenix/blob/7488693a120925af94f4c375e5e4b9c610b0d6f6/unittests/test_notifmsg.py
https://github.com/wxWidgets/Phoenix/blob/7488693a120925af94f4c375e5e4b9c610b0d6f6/unittests/wtc.py
I modified test_notifymsg.py to import the wtc module from the current directory and extended the duration the timeout to give:
import unittest
import wtc
import wx
import wx.adv
#---------------------------------------------------------------------------
class notifmsg_Tests(wtc.WidgetTestCase):
def test_notifmsg1(self):
nf = wx.adv.NotificationMessage("The Title", "This is the message")
nf.Show()
self.waitFor(3000)
nf.Close()
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
When I ran that test file on 4.3.1, it did show a notification.
Does anyone know why the unittest works on 4.3.1, but the demo example doesn’t?