Update a WebDialog
-
Hi,
Is there a way to give a WebDialog enought time to let it update. I mean a 'progress bar' scenario when ruby is doing something and the WD needs to be updated. As far as I know WDs sit on the same thread as Ruby ... I guess it will be hard to force the update. -
I think a few people has tried this - without much luck.
-
So we should file a feature request to haveweb_dialog.refresh
method added. -
Did you try to use Js to refresh the html ??
PC MSIE [window.location.reload()](http://msdn.microsoft.com/en-us/library/ms536691(v)
reload from browser cache:
dlg.execute_script("window.location.reload(false)")
reload from file:
dlg.execute_script("window.location.reload(true)")
The MSDN page says, "Standards Information: There is no public standard that applies to this method."
So this may be a MSIE only method.I do NOT know if it will work on Mac Safari.
.
See also:
[window.location.assign](http://msdn.microsoft.com/en-us/library/ms536342(v)
[window.location.replace](http://msdn.microsoft.com/en-us/library/ms536712(v) -
@dan rathbun said:
Did you try to use Js to refresh the html ??
That'd just require even more cycles - and it'd cancel out any HTML changes made by JS since it was first loaded.
The problem is that the webdialog is not allowed any CPU time to update it's UI until after the Ruby loop that's processing is done.
-
@thomthom said:
@dan rathbun said:
Did you try to use Js to refresh the html ??
That'd just require even more cycles - and it'd cancel out any HTML changes made by JS since it was first loaded.
Well I didn't go into detail.. but you would need to pass anything (vars) that you want to save over to the Ruby side... the page init Js function would request the values again from the Ruby side, same as it did on the initial load, for the default values.
@thomthom said:
The problem is that the webdialog is not allowed any CPU time to update it's UI until after the Ruby loop that's processing is done.
So they don't run in a new process huh ? But the Ruby loop, could have embedded execute_script calls to periodically give the WD cycles ??
-
Hey guys!
I have to pick up this topic again!
My problem: I have a WebDialog to create "Tools" - when a user created a new Tool, one has to update the webdialog.
In my case, it looks like this:
html = " .... " dlg = UI;;WebDialog.new("Model2GCode - Tools", true, "Model2GCode - Tools", 800, 300, 50, 50, true); dlg.set_html html dlg.show dlg.add_action_callback("saveNewTool") { }
Is there a possibility to close the WbDialog, "jump" to the start of the script and open it again? I tried a lot, but I didn't get a running solution.
Thanks for all your help!
-
Your first problem is very easy to solve, just make sure that your ruby script executes asynchronously.
I use this function in a couple of my scripts instead of the outer-most loop:def asyncLoop(range, &proc) from = range.min to = range.max iteration = lambda do |index| last = (index > to) proc.call(index, last) if !last then UI.start_timer(0.02, false) { iteration.call(index.succ) } end end iteration.call(from) return nil end
You can use it like this:
asyncLoop(0...16) do |i, last| if (!last) then # Perform ith iteration else # Put code to be run after this operation here instead of outside the loop end # Code here will run immediately, so leave it empty
Advertisement