Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3109 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  Shell_NotifyIcon + wxPython = perte d'evt

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Shell_NotifyIcon + wxPython = perte d'evt

n°1595691
zapan666
Tout est relatif
Posté le 03-08-2007 à 17:16:15  profilanswer
 

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 !
mood
Publicité
Posté le 03-08-2007 à 17:16:15  profilanswer
 

n°1596081
zapan666
Tout est relatif
Posté le 06-08-2007 à 10:12:53  profilanswer
 

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 !

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  Shell_NotifyIcon + wxPython = perte d'evt

 

Sujets relatifs
perte d'adresses à l'appel d'une fonction[shell script] Question sur l'init d'une variable
[shell] menu contextuelleasp.net: rechargement->perte de la position dans la page
Appeler une fonction C à partir d'un shellscript shell
[shell] recuperer le numero de process d'un fils[SHELL SH/BASH] Passage du caractère * en parametre
[SHELL] Supprimer les lignes blanches d'un fichier 
Plus de sujets relatifs à : Shell_NotifyIcon + wxPython = perte d'evt


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)