![]() |
2010-06-14
, 03:42
|
Posts: 13 |
Thanked: 20 times |
Joined on Jun 2010
|
#2
|
#!/usr/bin/env python2.5 # -*- coding: utf-8 -*- import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4 import QtGui, QtCore class notifyMe(object): def __init__(self, parent=None): # this is the constructor import pynotify pynotify.init('something') n = pynotify.Notification("my message", "message") n.show() if __name__ == '__main__': app = QtGui.QApplication(sys.argv) print "hello, world" x = notifyMe()
The Following User Says Thank You to timconradinc For This Useful Post: | ||
![]() |
2010-06-14
, 04:22
|
Posts: 1,746 |
Thanked: 2,100 times |
Joined on Sep 2009
|
#3
|
I just spent some time looking at this (Not that my python skills are that great), but, I can replicate this exact problem. I did find a work-around, though. I created a simple notifyMe class and in it's constructor (The __init__ bit, this is what gets called when the object gets created), I added the import there. This allows for the PyQt4 stuff to be imported, then pynotify.
I extensively tested this script on my n900 at least 2 or 3 times. I'm not sure how useful this would be with any sizable PyQt code, but this is at least a workaround.Code:#!/usr/bin/env python2.5 # -*- coding: utf-8 -*- import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4 import QtGui, QtCore class notifyMe(object): def __init__(self, parent=None): # this is the constructor import pynotify pynotify.init('something') n = pynotify.Notification("my message", "message") n.show() if __name__ == '__main__': app = QtGui.QApplication(sys.argv) print "hello, world" x = notifyMe()
![]() |
2010-06-14
, 05:19
|
Posts: 3,428 |
Thanked: 2,856 times |
Joined on Jul 2008
|
#4
|
class notifyMe(object): def __init__(self, title=None, message=None): # this is the constructor import pynotify pynotify.init('something') n = pynotify.Notification(message, title) n.show() def MyMainWindow(QWidget): #skip to buttons... f = QPushButton("With Chickes!") x = lambda: notifyMe("with", "chickens") #... self.connect(b, SIGNAL("clicked()"), d.close) self.connect(f, SIGNAL("clicked()"), x) #... rest of app
The Following User Says Thank You to fatalsaint For This Useful Post: | ||
![]() |
2010-06-14
, 13:40
|
Posts: 13 |
Thanked: 20 times |
Joined on Jun 2010
|
#5
|
The Following User Says Thank You to timconradinc For This Useful Post: | ||
![]() |
2010-06-14
, 18:07
|
Posts: 3,428 |
Thanked: 2,856 times |
Joined on Jul 2008
|
#6
|
Going OT, but using lambda functions with buttons like that is a handy technique. There's a lot of times that you just want to use a signal/slot with a clicked() and identify the caller, this is a simple way to work around this.
![]() |
2010-06-14
, 18:35
|
Posts: 3,319 |
Thanked: 5,610 times |
Joined on Aug 2008
@ Finland
|
#7
|
The Following 2 Users Say Thank You to attila77 For This Useful Post: | ||
![]() |
2010-06-14
, 18:37
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#8
|
![]() |
2010-06-14
, 19:15
|
Posts: 3,428 |
Thanked: 2,856 times |
Joined on Jul 2008
|
#10
|
epage provided this link on my pyqt tips thread for the 'proper' way of doing this.
I'm playing around with fatalsaint's example, and extended it to act on one of the buttons in the pop up dialog. The goal was to make a notification pop up on the screen when tapped.
Unfortunately, after paring the code down to this: