[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QSystemTrayIcon not hide when quit program
From:       Erik Hvatum <ice.rikh () gmail ! com>
Date:       2015-04-30 16:59:53
Message-ID: CAJOi7ysEhhrsJAyiXyCRcbVqyiH-Bsw5aD=tmELchmFp1+4XCw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sun, Apr 26, 2015 at 8:29 AM, Flya Flyaa <flyaflyaa@gmail.com> wrote:

> I found when exit the program, the system tray icon is still here.
>
> I tried example code in folder PyQt-gpl-5.4.1\examples\desktop\systray, it
> also has this problem.
>
> My system is windows xp 32 bit, python 2.7 with code PyQt-gpl-5.4.1.
>

It is generally not safe to assume that objects are destroyed at exit.  The
underlying memory is often simply released.  The problem here is that a
systray icon will remain visible until something like
shell_notifyicon(NMI_DELETE, handle) is called, and that call happens in
QSystemTrayIcon's destructor.  (I haven't done any winapi development for
about seven years; that call may not be exactly correct).

Python provides various mechanisms for ensuring destruction such as the
*with* statement, but in this case, I would simply call
systemtrayiconinstance.hide() the instant that the event triggering a
graceful exit occurs.

Cheers,
Erik

[Attachment #5 (text/html)]

<div dir="ltr">On Sun, Apr 26, 2015 at 8:29 AM, Flya Flyaa <span dir="ltr">&lt;<a \
href="mailto:flyaflyaa@gmail.com" target="_blank">flyaflyaa@gmail.com</a>&gt;</span> \
wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">I found when exit the program, the system tray \
icon is still here.  <div><br></div><div>I tried example code in folder \
PyQt-gpl-5.4.1\examples\desktop\systray, it also has this problem.  \
</div><div><br></div><div>My system is windows xp 32 bit, python 2.7 with code  \
PyQt-gpl-5.4.1.<br></div></div></blockquote><div><br></div><div>It is generally not \
safe to assume that objects are destroyed at exit.   The underlying memory is often \
simply released.   The problem here is that a systray icon will remain visible until \
something like shell_notifyicon(NMI_DELETE, handle) is called, and that call happens \
in QSystemTrayIcon&#39;s destructor.   (I haven&#39;t done any winapi development for \
about seven years; that call may not be exactly correct).<br><br>Python provides \
various mechanisms for ensuring destruction such as the <i>with</i> statement, but in \
this case, I would simply call systemtrayiconinstance.hide() the instant that the \
event triggering a graceful exit \
occurs.<br><br></div><div>Cheers,<br></div><div>Erik<br></div></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic