Menu

How do i mage an image sensor reload?

Help
2007-01-10
2013-04-16
  • Mathias Homann

    Mathias Homann - 2007-01-10

    Hi,

    i made a simple theme that does nothing but load one single image by http from a webserver. Now i want to refresh that image on every refresh of the theme, so that it gets loaded from the webserver again. how do i do that?

    here's my theme:

    karamba x=500 y=600 w=32 h=32 interval=30000
    image x=0 y=0 path="http://sisiya.fonts.de/ksisiyaapplet.php?par_formID=8" name="sisiyastatus"

     
    • slightcrazed

      slightcrazed - 2007-01-18

      You will have to do this through python.

      There is a callback done on every theme update (based on your interval) and it would be pretty easy to 'wget' an image from the web, dump it in a temp dir, and then use setImagePath to point to the image, so that it 'refreshes' every so often. You'll need to do a redrawWidget to get it to refresh.

      Hope that helps.

       
    • Dan Davis

      Dan Davis - 2007-10-04

      I know that this thread is really old, but perhaps it will help others find what they need.

      First, I set interval to 1000 in my .theme.

      In my .py file, I setup a counter that is incremented when widgetUpdated(widget) is called. If the counter is 0, as it is on the initial call, the following code is executed:

          karamba.createImage(widget,0,0,"http://url.for.the/image/to/load")
          karamba.redrawWidget(widget)

      Other calls to widgetUpdated will increment the counter or reset it to 0 when it has reached the "true" refresh interval (1 minute, 1 hour, etc).

      I did this because I was not able to get my image to draw upon the initial load of the widget. I tried putting the createImage/redrawWidget code into initWidget... it fetched the image from the website, but it would not draw the image.

       
    • Charley

      Charley - 2008-09-06

      I have exactly the same problem: the widget doesn't reload every 5 minutes.
      This is my test.theme text:

      # general
      KARAMBA  karamba x=100 y=1 w=250 h=150 interval=300000
      #
      image x=50 y=50 path="http://www.website.com/status.png" interval=300000
      (The meaning of interval=300000 is to reload it every 5 minutes)

      This is my test.py text:

      #this import statement allows access to the karamba functions
      import karamba
      import time
      import urllib

      karamba.createImage(widget,"test.theme",0,0,"http://www.website.com/status.png")
      karamba.redrawWidget(widget "test.theme")

      Further comment: by creating test.py another file was created automagically: test.pyc, which is binairy. I also made another *.py document and there was NO *.pyc document created. What's the difference?

      When I look in /home/user/.xsession-errors I see this: (among very much other faults)

      sys.path.insert(0, '/usr/share/apps/superkaramba/themes/test/test/')
        File "/usr/share/apps/superkaramba/themes/test/test.py", line 7
          karamba.redrawWidget(widget "test.theme")
                                                   ^
      SyntaxError: invalid syntax
      ------------------------------------------------------
      What does ImportError mean?

      It means that I couldn't load a python add-on fonera.py
      If this is a regular theme and doesn't use python
      extensions, then nothing is wrong.                         (In my case: Yes, it IS wrong and it must use python extensions.)
      ------------------------------------------------------

      Something is wrong in line 7, but I cannot figure out "what". I have seen (and read!) lots of threads, but no one is according to my question.

      Where did I go wrong? Can somebody please change my documents, so that it does what I want it to do? I think it is quite simple.
      I understand -Absolutely Nothing- of programming in python or other programming at all.
      The only thing I can is cut and paste and then see what happens. Understanding? Not at all. (smile)

      Your answer is very welcome!

       

Log in to post a comment.