[fxruby-users] Getting fewer paints per second than I expected
Wayne Conrad
wconrad at yagni.com
Sun Nov 5 12:27:58 EST 2006
I've got a program that puts 20 text labels in the main window. Each
label updates itself to a global counter on SEL_UPDATE. The counter
increments 10 times a second.
To my surprise, the labels skip counter updates. I expected to see
each label painting a new timer value 10 times per second. Instead,
each label paints about 3 times per second. CPU is about 100% idle
when the program is running.
Have I made a newbie mistake? Is this a question for the regular Fox
list?
Fox 1.4.34, FXRuby 1.4.7, Debian testing.
Program follows.
#!/usr/bin/ruby1.8
require 'fox14'
include Fox
class Main
def initialize
@i = 0
end
def run
@app = FXApp.new
main = FXMainWindow.new(@app, File.basename(__FILE__))
FXButton.new(main, "&Quit") do |button|
button.layoutHints = LAYOUT_CENTER_X
button.connect(SEL_COMMAND) do
exit
end
end
20.times do
FXLabel.new(main, format_count) do |label|
label.connect(SEL_UPDATE) do
label.text = format_count
end
end
end
main.show(PLACEMENT_SCREEN)
start_timer
@app.create
@app.run
end
private
def format_count
"%04d" % @i
end
def start_timer
@app.addTimeout(100, method(:timer))
end
def timer(sender, sel, data)
@i += 1
start_timer
end
end
Main.new.run if $0 == __FILE__
More information about the fxruby-users
mailing list