how can i update a progress bar while doing some a...
# tornadofx
h
how can i update a progress bar while doing some async stuff? running the piece of code attached, the ui block is only ran once, and only at the very end instead of after each time the image is generated. i have added printout statements inside the async thread and it prints out every time for each image (in the for loop) but the ui thread is only called once
a
As far as I understand, ui is used to "finalize" the work with single call in FX thread. Probably you need to create a property like
Bindings.divide(page, pages)
and bind your UI to it. I'm still new to JavaFX, so others might correct me.
h
im still lost and confused by what you mean! can you link me to some page where i can understand what you mean
a
ProgressBar class has
progressProperty
. You can bind your own property (defined as
val myprop = Bindings.divide(page, pages)
, for example) to it, so property mechanism will automatically notify UI when chances of
myprop
occur. If you don't understand what's property mechanism is, I'd rather recommend to read the docs or watch some Youtube tutorials. I don't mind trying to explain, but my writing English skills are not that good.
h
ooh, thank you! I should’ve thought of binding. i use it so much around the rest of the app.. 🤦
g
You can search in this channel using
progress task in:#tornadofx
for some ideas/previous discussions
h
Alright. I'll see what I can find
a
@Hamza what are you trying to accomplish that requires run async? Are you trying to match the progress?
h
yep
a
Did this one get figured out? If not, this would be a fun problem for me to look at.
h
yeah, i just binded the progress property and updated it in the loop
👍 1
a
@Hamza did you post a solution? I'd love to check it out!
I think there should be a function added in tfx for it bc it would be a great little whistle as a way to streamline UI
h
ill post it soon