File: NotificationMessage.py

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (56 lines) | stat: -rw-r--r-- 1,652 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
#!/usr/bin/env python

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.
"""


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