How to use Spinner
Posted
#1
(In Topic #399)
Trainee
I want to launch the Spinner at the start of a Shell operation and stop it at the end of this operation, but when I call the start () function of the Spinner before the Shell line, the Spinner does not start until after the end of the shell command, how to fix this problem.
Thank you
Posted
Guru

Posted
Trainee
Posted
Regular

cogier said
Gambas can only do one thing at a time so you need to use a 'Task' to get this to work. Have a look at this example
Hi!
Would it be too much to ask you to write a snippet on that?
See here what I mean:
https://forum.gambas.o…/viewtopic.php?f=13&t=845
Greetings!
“The only thing necessary for the triumph of evil is for good men to do nothing.”― Edmund Burke;
It's easy to die for an idea. It is way harder to LIVE for your idea! (Me)
It's easy to die for an idea. It is way harder to LIVE for your idea! (Me)
Posted
Guru

Gambas, in normal use, only uses one processor so in this case while waiting for a 'Shell' command to finish not much else can happen. If you follow this thread you will see the way you can get around this limitation using 'Task'.
Posted
Regular

Out of curiosity, I threw this code together to see if using a spinner control, along with shell, would cause the spinner to not start until the shell operation was completed. From there, I planned to see how I could implement "Task" to fix the problem. I purposely used a shell operation that would take some time.
But for me, the spinner didn't freeze and worked as expected, without the need for "Task". It spins happily while the shell is executing and listing files in the textarea. Though it does freeze for the last 7 or so seconds of the shell's operation. I don't see that as much of a problem.
Maybe the OP is using spinner + shell in a different way that I'm not understanding. Here's my code, if it helps. Its a simple form with controls: Spinner1, TextArea1, and two Buttons (cmdGo + cmdExit):
Code (gambas)
Posted
Enthusiast

testSpinner:26163): Gtk-CRITICAL **: 14:33:22.484: gtk_text_buffer_emit_insert:
assertion 'g_utf8_validate (text, len, NULL)' failed
then it stopped spinning
Posted
Regular

grayghost4 said
I tried you program and the spinner did keep spinning while it was running, but it stopped after I got about 100 errors in the console and the text area.
testSpinner:26163): Gtk-CRITICAL **: 14:33:22.484: gtk_text_buffer_emit_insert:
assertion 'g_utf8_validate (text, len, NULL)' failed
then it stopped spinning
Oh yeah, focusing on the spinner, I didn't really take the textarea's buffer into account. That's probably the reason the spinner stops spinning on my computer near the end of my search, too. Though I don't get any console messages indicating errors like you did. Probably because I used a QT form instead of GTK. QT should indicate these kind of errors in the console, too. Maybe there's a setting somewhere that I don't know about?
Much of the text filling the buffer is all the "permission denied" messages, due to the "find" command preferably needing a SUDO password to search properly. For me, proper didn't matter. All i was interested in was a quick simple read-only command shell can run that doesn't finish in an instant. To give the spinner plenty of time to spin.
So after some research, I found a way to suppress all the "permission denied" messages. Thus, leaving plenty of space for the buffer. And to be on the safe side, I narrowed the search range to a much smaller window that should yield few, if any results.
After doing this, the spinner operates for me 100% as expected, without any freezes near the end of the shell operation.
I'll also try to edit my original post with this much more functional code.
grayghost4, thank you for your feedback my friend.
1 guest and 0 members have just viewed this.


