Exemplo n.º 1
0
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}.')
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
 def test_BadType(self):
     self.assertRaises(ValueError, lambda: zroya.hide("test"))
Exemplo n.º 4
0
 def test_NoParam(self):
     self.assertRaises(TypeError, lambda: zroya.hide())
Exemplo n.º 5
0
 def test_ProperParamKeywords(self):
     t = zroya.Template(zroya.TemplateType.Text1)
     notID = zroya.show(t)
     self.assertTrue(zroya.hide(nid=notID))
Exemplo n.º 6
0
 def test_ProperParam(self):
     t = zroya.Template(zroya.TemplateType.Text1)
     nid = zroya.show(t)
     self.assertTrue(zroya.hide(nid))
Exemplo n.º 7
0
 def test_NegativeId(self):
     self.assertRaises(ValueError, lambda: zroya.hide(-1))
Exemplo n.º 8
0
 def hide(self) -> None:
     if self._nid is not None:
         zroya.hide(self._nid)