1

I'm trying to develop a simple digital signage system with raspberry-pi computer. What I'm actually trying to do is open a web page (which carrying information to be displayed) in full screen mode and refresh this page at certain interval of time. I came across some web view codes in python using "gtk" and "webkit" I managed to open a url in full screen mode, but I dont know how to use reload function as per my needs. Please help me.

2 Answers2

1

Besides the two ways that are already described using a cron job (not an elegant way) or using javascript, it is also possible to schedule the reload in the python script.

from gi.repository import Gtk, GLib
from gi.repository import WebKit2

class  ReloadView:
    def __init__(self):
        window = Gtk.Window()
        window.connect('delete-event',Gtk.main_quit)

        self.view = WebKit2.WebView()
        self.view.load_uri('http://example.net')
        GLib.timeout_add_seconds(5, self.reload) #every 5 seconds

        window.add(self.view)
        window.fullscreen()
        window.show_all()

    def reload(self):
        self.view.reload()
        #self.view.reload_bypass_cache() for complete reload
        return True

if __name__ == "__main__":
    ReloadView()
    Gtk.main()
elya5
  • 2,236
  • 1
  • 11
  • 27
  • 1
    Please consider accepting the answer and upvoting what is helpful to you. This way others can benefit from your experience. – Roy Prins Jan 27 '15 at 08:18
  • sir I have a doubt about putting this pyton script on auto start. I've tried some methods but nothing worked. can you help me? the code you menotioned works fine when run mannually. but i want to run this script automatially when raspberry pi get turned on. what should i do? – Pradeep Sathyan Feb 26 '15 at 08:21
  • Maybe [these instructions](http://embeddedday.com/projects/raspberry-pi/a-step-further/running-python-script-at-boot/) can help you. Otherwise, you should probably post this as a new question. – elya5 Feb 27 '15 at 11:41
0

Please check out this resource that seems to have some valid solutions for your problem: https://raspberrypi.stackexchange.com/questions/6981/auto-refresh-for-midori

These scheduled actions are usually handled by cron jobs, but there is nothing preventing you from writing your own simple action scheduler.

edit: alternatively if you control the website itself, you could set the website itself to refresh with a certain interval. The ways to do this are described here: How to reload page every 5 second?

Community
  • 1
  • 1
Roy Prins
  • 2,790
  • 2
  • 28
  • 47