def close_toasters(): pool.clear() for toaster_id in toasters: # NOTE: The version of zroya on PyPi currently has a bug # in it that prevents the `hide` function from working correctly. # I was able to rebuild a new version of zroya with a working # hide function thanks to this issue: https://github.com/malja/zroya/issues/14 if zroya.hide(nid=toaster_id): logger.info(f'Successfully closed toaster {toaster_id}.') else: logger.warning(f'Failed to close toaster {toaster_id}.')
def notify_zroya(): def onClick(nid, action_id): print("clicked") # never called # Initialize zroya module. Make sure to call this function. # All parameters are required zroya.init("YourAppName", "CompanyName", "ProductName", "SubProduct", "Version") # Create notification template. TYPE_TEXT1 means one bold line withou image. template = zroya.Template(zroya.TemplateType.Text1) # Set first line template.setFirstLine("My First line") template.setSecondLine("It is nice to meet you.") template.setThirdLine("How are you?") # Save notification id for later use notificationID = zroya.show(template, on_click=onClick) sleep(10) # Hide notification zroya.hide(notificationID)
def test_BadType(self): self.assertRaises(ValueError, lambda: zroya.hide("test"))
def test_NoParam(self): self.assertRaises(TypeError, lambda: zroya.hide())
def test_ProperParamKeywords(self): t = zroya.Template(zroya.TemplateType.Text1) notID = zroya.show(t) self.assertTrue(zroya.hide(nid=notID))
def test_ProperParam(self): t = zroya.Template(zroya.TemplateType.Text1) nid = zroya.show(t) self.assertTrue(zroya.hide(nid))
def test_NegativeId(self): self.assertRaises(ValueError, lambda: zroya.hide(-1))
def hide(self) -> None: if self._nid is not None: zroya.hide(self._nid)