Ruby Plasmoid and Qt::Timer (time events)
Sunday, December 18, 2011 8:15:45 PM
In the past couple of days I was working on a simple plasmoid for KDE and my NVidia video card. This time it is written in Ruby.
However I had a big problem. I lost more than a day to figure out how to use a timer in Ruby in a plasmoid. There are several tutorials and examples out there but all I could find is outdated and not working. Finally, I found a working ruby plasmoid and adapted a solution from it. It is, as everything in Ruby, more simple than anyone would expect. So, here it is.
In your 'def init' write this:
And than define a timer event:
My plasmoid can be found on kde-look:
http://kde-look.org/content/show.php/Simple+NVidia+Info+v2?content=147669
However I had a big problem. I lost more than a day to figure out how to use a timer in Ruby in a plasmoid. There are several tutorials and examples out there but all I could find is outdated and not working. Finally, I found a working ruby plasmoid and adapted a solution from it. It is, as everything in Ruby, more simple than anyone would expect. So, here it is.
In your 'def init' write this:
@refresh_interval = 10000 start_timer(@refresh_interval)
And than define a timer event:
def timerEvent(event) # your code to be run every @refresh_interval miliseconds end
My plasmoid can be found on kde-look:
http://kde-look.org/content/show.php/Simple+NVidia+Info+v2?content=147669






