Shell_NotifyIcon + wxPython = perte d'evt

Shell_NotifyIcon + wxPython = perte d'evt - Python - Programmation

Marsh Posté le 03-08-2007 à 17:16:15    

Yop,  
 
 
J'ai une icone dans la barre des tâches (via wx.TaskBarIcon)
Cet objet peut créé un p'tit popup menu (pour les clicks droit) via la redefinition de CreatePopupMenu(self)
 
Ca, ça marche nickel.
 
Maintenant, j'aimerais mettre une p'tit notification avec un BalloonTip donc j'utilise cette grosse repompe de code :
(code que je maitrise mal pour l'instant)  

Code :
  1. import win32gui
  2. import win32con
  3. TTS_BALLOON = 0x40
  4. WM_TRAYMESSAGE = win32con.WM_USER + 20
  5. def _get_nid(hwnd, id, flags, callbackmessage, hicon, title, msg):
  6.         nid = (hwnd, id, flags, callbackmessage, hicon)
  7.         nid = list(nid)
  8.         nid.append('') # the tip
  9.         nid.append('msg') # the balloon message
  10.         nid.append(5) # the timeout
  11.         nid.append('title') # the title
  12.         nid.append(win32gui.NIIF_INFO) # also warning and error available
  13.         print repr(nid)
  14.         return tuple(nid)
  15. _hwnd = None
  16. def find_traywindow_hwnd():
  17.     global _hwnd
  18.     if _hwnd is None:
  19.         try:
  20.             _hwnd = win32gui.FindWindowEx(0, 0, 'wxWindowClassNR', '')
  21.         except:
  22.             pass
  23.     return _hwnd
  24. def SetBalloonTip(hicon, title, msg):
  25.     hwnd = find_traywindow_hwnd()
  26.     id = 99 # always 99
  27.     flags = win32gui.NIF_MESSAGE | win32gui.NIF_ICON | win32gui.NIF_INFO
  28.     callbackmessage = WM_TRAYMESSAGE
  29.     nid = _get_nid(hwnd, id, flags, callbackmessage, hicon, title, msg)
  30.     try:
  31.         win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid)
  32.     except:
  33.         pass


 
Ca m'affiche bien la balloonTip et là, boom. impossible d'obtenir a nouveau mon menu via le click droit.
A mon avis, c'est le Notify Icon Data (nid) qui flingue le bordel : ça doit remplacer mon icone courant et en mettre un autre, du coup, cette icone n'es plus bindé.


---------------
my flick r - Just Tab it !
Reply

Marsh Posté le 03-08-2007 à 17:16:15   

Reply

Marsh Posté le 06-08-2007 à 10:12:53    

up ?

 


EDIT :

 

Bon, bah, apparament, c'est le flag win32gui.NIF_MESSAGE qui fout la merde (ligne 33). je ne comprend pas trop pourquoi. (Donc si quelqu'un a une explication...)


Message édité par zapan666 le 06-08-2007 à 10:26:47

---------------
my flick r - Just Tab it !
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed