File: NotificationMessage.py

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (61 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import wx
import wx.adv

class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        self.log = log
        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)

        # Various options can be set after the message is created if desired.
        # notify.SetFlags(# wx.ICON_INFORMATION
        #                 wx.ICON_WARNING
        #                 # wx.ICON_ERROR
        #                 )
        # notify.SetTitle("Wooot")
        # notify.SetMessage("It's a message!")
        # notify.SetParent(self)

        notify.Show(timeout=5) # 1 for short timeout, 100 for long timeout
        # notify.Close()       # Hides the notification.


def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win


#---------------------------------------------------------------------------


overview = """\
This class allows to show the user a message non intrusively.

Currently it is implemented natively for Windows and GTK and
uses (non-modal) dialogs for the display of the notifications
under the other platforms.

The OS X implementation uses Notification Center to display native
notifications. In order to use actions your notifications must use the
alert style. This can be enabled by the user in system settings or by
setting the NSUserNotificationAlertStyle value in Info.plist to alert.
Please note that the user always has the option to change the notification
style.
"""


if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])