Progress wheel/Loading Bar Question

Good afternoon,

I am a super beginner to using xojo, so I do apologize if what I am asking sounds silly. So I wanted to have a progress bar/progress wheel, to popup and loop for a certain duration of time whenever a user clicks on a button. I am just not sure how to implement the code.

Thank you

What have you tried that hasn’t worked?

I guess that is kind of the issue that I am having. I am not sure what code to use for it.

Hi @Joseph_Weeks, welcome!
I am away from my computer, but I am pretty sure there is an example project that will demonstrate this.

I just you open that, run it to make sure it does what you are wanting to do. Then set some break points in the code so you can watch it execute line-by-line.

This is a great community so when you get stuck feel free to post here and someone will usually be able to point you in a good direction and on occasion will even supply code snippets.

Have you tried the ProgressBar Example? (I guess you want Desktop):
image

1 Like

A progress bar needs to be incremented and is usually used to count down or up to completion of some task and feels like the wrong thing to use when pressing a button unless it actually is counting some processing task. The ProgressWheel on the other hand may be a better choice if you are just wanting to show that activity is taking place. You can do this by normally hiding the ProgressWheel until the button is pressed. When pressed, unhide the ProgressWheel and then launch a timer from the button set for the minimum time you want the progress wheel to show, and then perform the action when the timer expires. If the action runs a while and interferes with the UI thread you may want to put the action into a separate thread to run so that the ProgressWheel continues to spin. At the end of the action then hide the ProgressWheel again.

I think that this sounds like a great idea for what I would like to do. Out of curiosity is there any sort of code tutorial or examples in order to perform something like this?

@AlbertoD has already pointed you at an example.

There are many examples in many places, but the starting place for you should probably be the examples included with Xojo. Start with using a timer, using a thread in the updating UI from a thread as well as looking at the progress bar example.

If you get stuck or can’t get your code to work, post it here using the code formatting button </> so it is readable as code. People are happy to help but you need to first try to write what you are looking to make happen.

// Make ProgressWheel1 Visible to the User 
ProgressWheel1.Visible = True
// Set the length of time in code to override the control setting
// However you can also set the control setting to 3000 milliseconds, (3 seconds)
Timer1.Period = 3000
// start the timer
Timer1.RunMode = Timer.RunModes.Single

// When the timer expires it will perform your processing which can be done within a thread that you start

Thank you guys for the help, I was able to use the suggestions for my project and it worked! Thank you!

1 Like