Re: [PyQt] Weird problem with QSystemTrayIcon

2010-09-15 Thread Hans-Peter Jansen
On Wednesday 15 September 2010, 20:34:12 Eric Frederich wrote:
>
> In the end, I wound up with a small sample application where for 
> some reason I need to call QtGui.QGroupBox() with some string or I'll
> never see the system tray icon.
>
> Below is example code.
>
> If you remove the line ...
> self.WHY_DO_I_NEED_TO_DO_THIS = QtGui.QGroupBox("A")
> ... then I don't see any system tray icon.
>
> Can anyone else verify this?
> I'm on Linux 64 bit with Python 2.6.5 and PyQt 4.7.2.

I cannot confirm this with
Python version: 2.6
sip version: 4.10.5
Qt4 version: 4.6.3
PyQt4 version: 4.7.4

on openSUSE 11.1/i586 with KDE3 window manager.

and the code looks fine without your voodoo speel. I cannot imagine, why 
this should make any difference. 

Mind you checking the Qt4 example? (If it's not compiled already, a 
"qmake && make" should do)

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Weird problem with QSystemTrayIcon

2010-09-15 Thread Eric Frederich
I looked at the example with PyQt for system tray icons and tried to use it
in my application.
I couldn't get it to work.
I couldn't find what the example was doing that I wasn't doing.  I even did
the stuff in the same order.

I wound up taking the example and in-lining a bunch of functions then bit by
bit removing things until I got a minimalistic system tray icon program.
In the end, I wound up with a small sample application where for some reason
I need to call QtGui.QGroupBox() with some string or I'll never see the
system tray icon.

Below is example code.

If you remove the line ...
self.WHY_DO_I_NEED_TO_DO_THIS = QtGui.QGroupBox("A")
... then I don't see any system tray icon.

Can anyone else verify this?
I'm on Linux 64 bit with Python 2.6.5 and PyQt 4.7.2.
Thanks,
~Eric

#!/usr/bin/env python

from PyQt4 import QtCore, QtGui

class Window(QtGui.QDialog):
def __init__(self):
super(Window, self).__init__()

self.WHY_DO_I_NEED_TO_DO_THIS = QtGui.QGroupBox("A")

self.restoreAction = QtGui.QAction("&Restore", self,
triggered=self.showNormal)

self.quitAction = QtGui.QAction("&Quit", self,
triggered=QtGui.qApp.quit)

self.trayIconMenu = QtGui.QMenu(self)
self.trayIconMenu.addAction(self.restoreAction)
self.trayIconMenu.addSeparator()
self.trayIconMenu.addAction(self.quitAction)

self.trayIcon = QtGui.QSystemTrayIcon(self)
self.trayIcon.setContextMenu(self.trayIconMenu)

self.trayIcon.setIcon(QtGui.QIcon("./logo.png"))

mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(QtGui.QPushButton("Help Please"))
self.setLayout(mainLayout)

self.trayIcon.show()
self.setWindowTitle("Systray")
self.resize(400, 300)

if __name__ == '__main__':

import sys

app = QtGui.QApplication(sys.argv)

if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
QtGui.QMessageBox.critical(None, "Systray",
"I couldn't detect any system tray on this system.")
sys.exit(1)

#QtGui.QApplication.setQuitOnLastWindowClosed(False)

window = Window()
window.show()
sys.exit(app.exec_())
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt