Kivy : If there is no Internet, Show me Warning Message?

60 views
Skip to first unread message

Mecra Yavcin

unread,
Jun 25, 2023, 10:18:15 AM6/25/23
to Kivy users support
Hi Kivy Masters.

I have an app and i need a function that if there is no internet, i want the app to show an message that Please activate your wifi or internet connection (a warning message).

I created my app with buildozer and Internet is necessarry.
If there is no internet, when i try to run, it it does not run so i need an error message for this.

How can i do that? 
I need some example codes.

Could you Please help me?

Thanks very much

Elliot Garbus

unread,
Jun 25, 2023, 10:58:16 AM6/25/23
to kivy-...@googlegroups.com
How are you accessing the network? Are you using https://kivy.org/doc/stable/api-kivy.network.urlrequest.html#module-kivy.network.urlrequest



Sent from my iPhone

On Jun 25, 2023, at 4:18 PM, Mecra Yavcin <mecra...@gmail.com> wrote:

Hi Kivy Masters.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d3b6cb45-331a-48a0-ac25-a902c5a1a1b1n%40googlegroups.com.

Mecra Yavcin

unread,
Jun 25, 2023, 12:10:08 PM6/25/23
to Kivy users support
Thanks very much
this is my function

def datas(self, *args):          
       
        try:
            source = requests.get("http://11.11.11.11/tek.json").json()
            print('updated')
            self.data = source    
            return source
        except:
            source = {"home": {"Database": [0, 0, 0, 0, 0, 0, 0, 0, 0], "Please": [0, 0, 0, 0, 0, 0, 0, 0, 0]}, "away": {"Is Being Updated":  [0, 0, 0, 0, 0, 0, 0, 0, 0], "Try Again Later":  [0, 0, 0, 0, 0, 0, 0, 0, 0]}, "today": {"home": ["Database", "Please"], "away": ["Is Being Updated", "Try Again Later"]}}
            self.data = source    
            return source

If there is a problem in json file it uses datas that in except section 
But if there is no internet i need a wardining message.

Mecra Yavcin

unread,
Jun 25, 2023, 12:11:30 PM6/25/23
to Kivy users support
I used import requests

On Sunday, June 25, 2023 at 5:58:16 PM UTC+3 ElliotG wrote:

Elliot Garbus

unread,
Jun 25, 2023, 12:15:10 PM6/25/23
to kivy-...@googlegroups.com
Use kivy’s url request, it is asynchronous. It provides callbacks for error (and success) conditions. 

Sent from my iPhone

On Jun 25, 2023, at 6:11 PM, Mecra Yavcin <mecra...@gmail.com> wrote:

I used import requests

Elliot Garbus

unread,
Jun 25, 2023, 12:20:30 PM6/25/23
to kivy-...@googlegroups.com
You can also try using the timeout from requests. 


Sent from my iPhone

On Jun 25, 2023, at 6:15 PM, Elliot Garbus <elli...@cox.net> wrote:

Use kivy’s url request, it is asynchronous. It provides callbacks for error (and success) conditions. 

Robert

unread,
Jun 25, 2023, 12:51:41 PM6/25/23
to Kivy users support
Not a Kivy question Google:   python test internet connection
And see how to use request timeout, for example
https://www.adamsmith.haus/python/answers/how-to-check-internet-connection-in-python
Reply all
Reply to author
Forward
0 new messages