python - NSUserNotification not working with wx.app.MainLoop() method -
here simple code uses pyobjc interface show desktop notification. when call notify method without wx.app.mainloop() works fine wx.app.mainloop() not.
import foundation, objc nsusernotification = objc.lookupclass('nsusernotification') nsusernotificationcenter = objc.lookupclass('nsusernotificationcenter') def notify(title, subtitle, info_text, delay=0, sound=false, userinfo={}): notification = nsusernotification.alloc().init() notification.settitle_(title) notification.setsubtitle_(subtitle) notification.setinformativetext_(info_text) notification.setuserinfo_(userinfo) if sound: notification.setsoundname_("nsusernotificationdefaultsoundname") notification.setdeliverydate_(foundation.nsdate.datewithtimeinterval_sincedate_(delay, foundation.nsdate.date())) nsusernotificationcenter.defaultusernotificationcenter().schedulenotification_(notification) if __name__ == '__main__': app = wx.app() notify("notify tittle", "notify subtitle", "notify body") app.mainloop() # commenting line shows desktop notification
Comments
Post a Comment