Dyzlee
Dyzlee

Reputation: 85

Kivy Plyer Notification

I am very new to kivy and I just tried Plyer for the App I am making. But for some reason I cannot get the notify method to work and as soon as the Clock method runs, it gives me this Error: TypeError: notify() missing 1 required positional argument: 'self'

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.switch import Switch
from kivy.clock import Clock
from kivy.uix.label import Label
import datetime
from kivy.event import EventDispatcher
import plyer

count = 0


class ConnectPage(GridLayout):
    def __init__(self, **kwargs):
        super(ConnectPage, self).__init__(**kwargs)
        self.cols = 1
        self.switch = Switch()
        self.add_widget(self.switch)

        self.label = Label(text="0")
        self.add_widget(self.label)

    def manager(self):
        global count
        count += 1
        print("[", count, "]")
        plyer.facades.Notification.notify(title='hehe', message='huhu')

    Clock.schedule_interval(manager, 1 / 1.)


class TestService(App):
    def build(self):
        return ConnectPage()


TestService().run()

Upvotes: 3

Views: 2446

Answers (1)

O.O.Balance
O.O.Balance

Reputation: 3040

notify() is a method of the class Notification, and it is not marked @staticmethod. So you need an instance of the class to call it. According to the documentation, the proper way to create a notification is:

from plyer import notification
notification.notify(title='hehe', message='huhu')

Upvotes: 3

Related Questions