Csabi's blog

Software Craftsmanship, Agile, and other Ideas about Programming

Ruby Plasmoid and Qt::Timer (time events)

, , , ,

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:
@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

A Couple of Words. The Pragmatic ProgrammerUsing Ruby's Watcher for Continuous Bash (shUnit) Testing

Write a comment

New comments have been disabled for this post.