Philippe Lang
2009-Jan-13 08:39 UTC
[fxruby-users] No more GUI update after FXRuby app put in the background?
Hi,
Here is a small program that represents the GUI I use for deploying
FXRuby applications: a small window, with a progress bar in it.
It works fine, as long as the application is not put in the background.
Then the GUI stops being updated, even if the application is put back to
the foreground again.
Is there anything I can do for this?
Thanks,
Philippe Lang
Note: Windows XP, ruby 1.8.6, FXRuby 1.6.18
-------------------------------
#!/usr/bin/ruby
require ''fox16''
include Fox
class MyWindow < FXMainWindow
def initialize(app, title, icon=nil, miniIcon=nil, opts=DECOR_ALL,
x=0, y=0, width=0, height=0, padLeft=0, padRight=0, padTop=0,
padBottom=0, hSpacing=4, vSpacing=4)
super
@bar = FXProgressBar.new(self, nil, 0,
PROGRESSBAR_PERCENTAGE|LAYOUT_FILL_X)
@label = FXLabel.new(self, "")
end
def deploy
setTotal(100)
setProgress(0, "Step 0")
sleep 1
setProgress(10, "Step 1")
sleep 1
setProgress(20, "Step 2")
sleep 1
setProgress(30, "Step 3")
sleep 1
setProgress(40, "Step 4")
sleep 1
setProgress(50, "Step 5")
sleep 1
setProgress(60, "Step 6")
sleep 1
setProgress(70, "Step 7")
sleep 1
setProgress(80, "Step 8")
sleep 1
setProgress(90, "Step 9")
sleep 1
setProgress(100, "Step 10")
end
def setTotal(progress_total)
@bar.total = progress_total
end
def setProgress(progress_value, progress_text)
@bar.progress = progress_value
@label.text = progress_text
# Let''s try all the armada of refresh-redraw-repaint-everything
NOW.
update
recalc
layout
repaint
$app.forceRefresh
end
end
class MyApp < FXApp
def initialize(appName="Application",
vendorName="FoxDefault")
super
@window = MyWindow.new(self, "Deployment", nil, nil,
DECOR_ALL,
0, 0, 300, 40)
end
def create
begin
super
@window.show(PLACEMENT_SCREEN)
@window.deploy
@window.close
rescue Exception => e
end
end
end
# Main program
GC.disable # Does not help
$app = MyApp.new()
$app.disableThreads # Does not help
$app.create
-------------------------------
Philippe Lang
2009-Jan-13 09:42 UTC
[fxruby-users] No more GUI update after FXRuby app put in thebackground?
fxruby-users-bounces at rubyforge.org wrote:> Hi, > > Here is a small program that represents the GUI I use for deploying > FXRuby applications: a small window, with a progress bar in it. > > It works fine, as long as the application is not put in the > background. > Then the GUI stops being updated, even if the application is put back > to the foreground again. > > Is there anything I can do for this?Hi again, I found the solution, I hope it can help someone: the trick is to call "$app.runWhileEvents" now and then, to give a chance to fox to process OS events... I should have remembered that before... ! ------------------- #!/usr/bin/ruby require ''fox16'' include Fox class MyWindow < FXMainWindow def initialize(app, title, icon=nil, miniIcon=nil, opts=DECOR_ALL, x=0, y=0, width=0, height=0, padLeft=0, padRight=0, padTop=0, padBottom=0, hSpacing=4, vSpacing=4) super @bar = FXProgressBar.new(self, nil, 0, PROGRESSBAR_PERCENTAGE|LAYOUT_FILL_X) @label = FXLabel.new(self, "") end def deploy setTotal(100) setProgress(0, "Step 0") sleep 1 setProgress(10, "Step 1") sleep 1 setProgress(20, "Step 2") sleep 1 setProgress(30, "Step 3") sleep 1 setProgress(40, "Step 4") sleep 1 setProgress(50, "Step 5") sleep 1 setProgress(60, "Step 6") sleep 1 setProgress(70, "Step 7") sleep 1 setProgress(80, "Step 8") sleep 1 setProgress(90, "Step 9") sleep 1 setProgress(100, "Step 10") end def setTotal(progress_total) @bar.total = progress_total end def setProgress(progress_value, progress_text) @bar.progress = progress_value @label.text = progress_text layout $app.runWhileEvents end end class MyApp < FXApp def initialize(appName="Application", vendorName="FoxDefault") super @window = MyWindow.new(self, "Deployment", nil, nil, DECOR_ALL, 0, 0, 300, 40) end def create begin super @window.show(PLACEMENT_SCREEN) @window.deploy @window.close rescue Exception => e end end end # Main program GC.disable $app = MyApp.new() $app.disableThreads $app.create