I am trying to get a progress bar to work in Ruby with Green Shoes. My problem is that the progress of the bar that I am creating isn't showing. The state of my bar is either empty at the begining and during the execution of the code or full at the end.
Here is the structure of my code:
Shoes.app do
button("Run") do
progress_bar = progress left: 10, top: 10, width: 235
backup_exe = File.open(File.dirname(__FILE__) + "/backuplist.txt","r+")
count = 0
File.open(backup_exe) {|f| count = f.read.count("\n")}
counter = 0
count = count.to_f
puts count
animate do |counter|
backup_exe.each do |line|
counter=counter+1
progress_bar.fraction = ((counter/count)*10).round / 10.0
puts progress_bar.fraction
sleep(2)
end
end
end
end
Thank you in advance for your help!
Resolved! I need to put values that populates fraction in a new Thread. Thanks mudasobwa for your input!