| 1 | #!/bin/env python |
| 2 | #---------------------------------------------------------------------------- |
| 3 | # Name: test5.py |
| 4 | # Purpose: Testing wxTaskBarIcon for win32 systems |
| 5 | # |
| 6 | # Author: Robin Dunn |
| 7 | # |
| 8 | # Created: 17-Nov-1998 |
| 9 | # RCS-ID: $Id$ |
| 10 | # Copyright: (c) 1998 by Total Control Software |
| 11 | # Licence: wxWindows license |
| 12 | #---------------------------------------------------------------------------- |
| 13 | |
| 14 | |
| 15 | from wxPython.wx import * |
| 16 | |
| 17 | |
| 18 | #--------------------------------------------------------------------------- |
| 19 | |
| 20 | class MyDialog(wxDialog): |
| 21 | def __init__(self): |
| 22 | wxDialog.__init__(self, NULL, -1, "wxTaskBarIcon Test", |
| 23 | wxPoint(-1,-1), wxSize(380,250), |
| 24 | wxDIALOG_MODELESS|wxDEFAULT_DIALOG_STYLE) |
| 25 | |
| 26 | # build the contents of the Dialog |
| 27 | wxStaticText(self, -1, |
| 28 | "Press OK to hide me, Exit to quit.", |
| 29 | wxPoint(10, 20)) |
| 30 | wxStaticText(self, -1, |
| 31 | "Double-click on the taskbar icon to show me again.", |
| 32 | wxPoint(10, 40)) |
| 33 | |
| 34 | okButton = wxButton(self, wxID_OK, "OK", wxPoint(100, 180), wxSize(80, 25)) |
| 35 | exitButton = wxButton(self, wxID_EXIT, "Exit", wxPoint(185, 180), wxSize(80, 25)) |
| 36 | okButton.SetDefault() |
| 37 | self.Centre(wxBOTH) |
| 38 | |
| 39 | EVT_BUTTON(self, wxID_OK, self.OnOK) |
| 40 | EVT_BUTTON(self, wxID_EXIT, self.OnExit) |
| 41 | |
| 42 | |
| 43 | # make the TaskBar icon |
| 44 | self.tbIcon = wxTaskBarIcon() |
| 45 | icon = wxIcon('bitmaps/smiles.ico', wxBITMAP_TYPE_ICO) |
| 46 | self.tbIcon.SetIcon(icon, "Test ToolTip") |
| 47 | EVT_TASKBAR_LEFT_DCLICK(self.tbIcon, self.OnTaskBarActivate) |
| 48 | |
| 49 | |
| 50 | |
| 51 | def OnTaskBarActivate(self, event): |
| 52 | self.Show(true) |
| 53 | |
| 54 | def OnOK(self, event): |
| 55 | self.Show(false) |
| 56 | |
| 57 | def OnExit(self, event): |
| 58 | self.Close(true) |
| 59 | |
| 60 | def OnCloseWindow(self, event): |
| 61 | self.Destroy() |
| 62 | del self.tbIcon # ensure the tbIcon is cleaned up... |
| 63 | |
| 64 | |
| 65 | |
| 66 | #--------------------------------------------------------------------------- |
| 67 | |
| 68 | class MyApp(wxApp): |
| 69 | def OnInit(self): |
| 70 | self.dlg = MyDialog() |
| 71 | self.dlg.Show(true) |
| 72 | self.SetTopWindow(self.dlg) |
| 73 | return true |
| 74 | |
| 75 | #--------------------------------------------------------------------------- |
| 76 | |
| 77 | |
| 78 | def main(): |
| 79 | app = MyApp(0) |
| 80 | app.MainLoop() |
| 81 | |
| 82 | |
| 83 | def t(): |
| 84 | import pdb |
| 85 | pdb.run('main()') |
| 86 | |
| 87 | if __name__ == '__main__': |
| 88 | main() |
| 89 | |
| 90 | |
| 91 | #---------------------------------------------------------------------------- |