The indeterminate progress bar doesn't appear

Hi,

I placed an indeterminate progress bar in a form, initially set to “Not Visible.”
During program execution, I press a key to make it visible (myform.myprgbar.visible = True), but it doesn’t appear. I also tried writing myform.myprgbar.refresh, but it has no effect.
However, if I initially set it to visible, it does appear.
What strange mystery can I not understand?

Thanks

Try making it 1 pixel wider, to trick it into refreshing internally?

Hi Graham,

Unfortunately, it didn’t produce any results. I think it’s a bug.

Hi @GUERINO_IANDIORIO

Is it possible to upload a zip of your project here? Or a simple project showing the problem?

Create a sample project that shows this, zip it, upload to your post.
The standard questions:
Xojo version?
Windows 10 or 11? (not sure if there should be a difference)

I tried to reproduce it but it does work normally here.

Are you sure you set the control.Visible and not some other item?

The progress bar will only update when your app is not running Event code. Thus, something like this will not work as you might expect

progressbar1.visible = true
for i = 1 to 100
  progressbar1.value = i
  [... do some other lengthy computation ...]
next

If it is this, then make the control visible and then call Timer.CallLater with the addressOf a method to run the actual code

Thanks everyone for the replies.
I’ve done some testing and found that the command that makes the indeterminate progress bar visible works if I insert it alone into a button.
But if I insert it into another button where I perform a select on a database, it doesn’t turn it on.
Figure 1 shows the progress bar and the buttons that correctly make it visible and invisible.
Figure 2 shows the content of the code where I placed the command that makes it visible, but it doesn’t work.
Why?

1 Like

Please show us all the code from that method.
Paste the code as text into the forum, and use the “code” tag button to format it properly for the forum.

This is the button you use:

image

On a side note: The Xojo indeterminate progress bar in macOS26 does not work. It shows the progressbar but you do not see the animation.

Note: this issue is only seen when you use the script that alters the Xojo app thinking it is compiled against SDK26

Xojo does not update the gui after every line of code. I think it does it at key moments like end of a function. There is a app.doevents method you can call to request the update. However be careful using it as it can cause unexpected event propagation

as i remember changes to the ui appear if the main event loop continue.

that does not happen if you are inside of a normal method.

sometimes it need the Thread class.

or you iterate lists one step at a time to have execution of methods faster.

// Ok Mike. Here’s the code.It appears in the MouseDown event of a Canvas object.

db = New MySQLCommunityServer
db.Host = “xxx.xxx.xxx.xxx”db.UserName = “yyyyyyyyyyyyyyyy”db.Password = “zzzzzzzzzzzzzzzz”db.DatabaseName = “wwwwwwwwwww”db.port = nnnn
Try
db.ConnectIf db.Error ThenMessageBox("Errore di connessione: " + db.ErrorMessage)Return FalseEnd If
inizio1.progress_ctr.visible = True
// Esegui la queryVar rs As RowSet = db.SelectSQL(“SELECT * FROM testata WHERE tes_003 like ?”,ricerca_ctr1.Text.Trim + “%”)
If rs <> Nil Then
inizio1.ListBox1.Visible = True
inizio1.msg_ctr.TextColor = RGB(0, 0, 0)
inizio1.msg_ctr.Text = "Ricerca in corso ..."
inizio1.msg_rag.Text = ""
inizio1.msg_cli.Text = ""

// Pulisci eventuali dati precedenti
ListBox1.RemoveAllRows
ListBox1.ColumnCount = 8
ListBox1.HasHeader = True

ListBox1.HeaderAt(0) = "Soc"
ListBox1.HeaderAt(1) = "Fil"
ListBox1.HeaderAt(2) = "Contratto"
ListBox1.HeaderAt(3) = "Ragione sociale"
ListBox1.HeaderAt(4) = "Città"
ListBox1.HeaderAt(5) = "Pr"
ListBox1.HeaderAt(6) = "Codice fiscale"
ListBox1.HeaderAt(7) = "Partita Iva"

Listbox1.HeaderHeight = 30

// Riempie la ListBox
For Each row As DatabaseRow In rs
  ListBox1.AddRow(row.Column("tes_001").StringValue, row.Column("tes_002").StringValue, row.Column("tes_003").StringValue, row.Column("tes_010").StringValue, row.Column("tes_013").StringValue, row.Column("tes_014").StringValue, row.Column("tes_019").StringValue, row.Column("tes_020").StringValue)
Next

inizio1.AutoSizeColumns(Listbox1)


inizio1.msg_ctr.TextColor = RGB(0, 128, 0)
inizio1.msg_ctr.Text = "Ricerca terminata"
inizio1.progress_ctr.visible = False

rs.Close
end if
Catch e As DatabaseExceptioninizio1.msg_ctr.TextColor = RGB(128, 0, 0)inizio1.msg_ctr.Text = "Problema su Testata " + e.Messageinizio1.progress_ctr.visible = FalseEnd Try

You can try

// Start of method: 

inizio1.Progress_ctr.Visible = True
inizio1.Progress_ctr.Refresh(True) // Force refresh, this should not be needed

// Maybe your code after this is blocking..(needs to much cpu time?)
// Also make sure your control is Front-Most in the IDE or at least try to make it front-most (use the icons in the layout editor)

// Do your db stuff after the call:
db = New MySQLCommunityServer

Try
db.Connect 
// Note do not check DB.Error, the exception handler should "catch" this. 

Catch e As DatabaseException
// Inform user that there was an exception


Finally
// Stop the progress, after success and error. (e.g. Always)
inizio1.Progress_ctr.Visible = False
inizio1.Progress_ctr.Refresh(True) // Force refresh, this should not be needed

End Try

@Mike_D is correct. UI changes will not show until after the event finishes. @Graham_Busch provides a good solution using CallLater.

2 Likes

Here is a sample project showing how to run a lengthy computation in a Thread, while updating the User Interface properly.


progressbar_thread.v1.xojo_binary_project.zip (6.6 KB)

2 Likes

Hi DerkJ,

I tested following the logic of your code, but what happens is that the progress bar appears but remains still instead of moving as an indeterminate progress bar should.
Basically, and in general, I can’t display anything graphical that gives the impression of “searching.” As mentioned previously, I tried displaying an animated GIF image. It appears but remains still and doesn’t animate.

I see, ok then it’s clearly your loop (or code) that blocks the main ui refreshes. If you run it in a thread, you won’t have this issue.

Check the examples for thread code. There should be some examples that show how to do this and keep the UI refreshed.

Xojo doesn’t handle GIF animations in desktop applications.