How can I create a trivial "spinner" etc, to see if image is busy?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I create a trivial "spinner" etc, to see if image is busy?

Uko2
Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko
Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Henrik-Nergaard
http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser

---------------------
| ston file|

ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
file := (FileStream fileNamed: 'file.ston').

ston whileDisplayingProgress
        action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
        open;
        fillOwner
---------------------

Best regards,
Henrik

-----Opprinnelig melding-----
Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
Sendt: 05 February 2017 16:56
Til: Pharo Development List <[hidden email]>
Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko
Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Sven Van Caekenberghe-2
A bit off topic, but I would do the STON writing as follows:

[
(FileLocator temp / 'file.ston') writeStreamDo: [ :out |
  (STON writer on: out) in: [ :stonWriter |
    30 timesRepeat: [
      stonWriter nextPut: Smalltalk allClasses ] ] ].
] timeToRun. "0:00:00:02.176"

But in light of alternative streams and some optimisation, this works too:

[
| file |
file := (File named: '/tmp/file.ston') openForWrite.
[
  ZnBufferedWriteStream on: (ZnCharacterWriteStream on: file) do: [ :out |
    (STON writer on: out) in: [ :stonWriter |
      30 timesRepeat: [
        stonWriter nextPut: Smalltalk allClasses ] ] ]
] ensure: [ file close ].
] timeToRun. "0:00:00:00.385"

Which is faster.

Total file size is ~1.2MB.

BTW, we need #readStreamDo: and #writeStreamDo: on File I think, as it encourages proper resource management.

> On 5 Feb 2017, at 19:16, Henrik Nergaard <[hidden email]> wrote:
>
> http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser
>
> ---------------------
> | ston file|
>
> ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
> file := (FileStream fileNamed: 'file.ston').
>
> ston whileDisplayingProgress
> action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
> open;
> fillOwner
> ---------------------
>
> Best regards,
> Henrik
>
> -----Opprinnelig melding-----
> Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
> Sendt: 05 February 2017 16:56
> Til: Pharo Development List <[hidden email]>
> Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
>
> Hi all,
>
> is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?
>
> Cheers.
> Uko


Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Uko2
This is a really nice solution for STON, thank you!

But in general terms, imagine I have some task and it’s not the trivial to add a progress bar. I could spawn a string morph and make circle the digits with some interval, but maybe there is something easier. For example Kommiter had a spinner morph that you could just open and it would be spinning. So when you run a task you can easily see that the task is still running

Uko

> On 5 Feb 2017, at 20:01, Sven Van Caekenberghe <[hidden email]> wrote:
>
> A bit off topic, but I would do the STON writing as follows:
>
> [
> (FileLocator temp / 'file.ston') writeStreamDo: [ :out |
>  (STON writer on: out) in: [ :stonWriter |
>    30 timesRepeat: [
>      stonWriter nextPut: Smalltalk allClasses ] ] ].
> ] timeToRun. "0:00:00:02.176"
>
> But in light of alternative streams and some optimisation, this works too:
>
> [
> | file |
> file := (File named: '/tmp/file.ston') openForWrite.
> [
>  ZnBufferedWriteStream on: (ZnCharacterWriteStream on: file) do: [ :out |
>    (STON writer on: out) in: [ :stonWriter |
>      30 timesRepeat: [
>        stonWriter nextPut: Smalltalk allClasses ] ] ]
> ] ensure: [ file close ].
> ] timeToRun. "0:00:00:00.385"
>
> Which is faster.
>
> Total file size is ~1.2MB.
>
> BTW, we need #readStreamDo: and #writeStreamDo: on File I think, as it encourages proper resource management.
>
>> On 5 Feb 2017, at 19:16, Henrik Nergaard <[hidden email]> wrote:
>>
>> http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser
>>
>> ---------------------
>> | ston file|
>>
>> ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
>> file := (FileStream fileNamed: 'file.ston').
>>
>> ston whileDisplayingProgress
>> action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
>> open;
>> fillOwner
>> ---------------------
>>
>> Best regards,
>> Henrik
>>
>> -----Opprinnelig melding-----
>> Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
>> Sendt: 05 February 2017 16:56
>> Til: Pharo Development List <[hidden email]>
>> Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
>>
>> Hi all,
>>
>> is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?
>>
>> Cheers.
>> Uko
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Sven Van Caekenberghe-2
You could also have a look at ZnClientTests>>#testProgress where Notification are used, try the example in the comment. But that is probably not what you are looking for.

> On 5 Feb 2017, at 20:32, Yuriy Tymchuk <[hidden email]> wrote:
>
> This is a really nice solution for STON, thank you!
>
> But in general terms, imagine I have some task and it’s not the trivial to add a progress bar. I could spawn a string morph and make circle the digits with some interval, but maybe there is something easier. For example Kommiter had a spinner morph that you could just open and it would be spinning. So when you run a task you can easily see that the task is still running
>
> Uko
>
>> On 5 Feb 2017, at 20:01, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>> A bit off topic, but I would do the STON writing as follows:
>>
>> [
>> (FileLocator temp / 'file.ston') writeStreamDo: [ :out |
>> (STON writer on: out) in: [ :stonWriter |
>>   30 timesRepeat: [
>>     stonWriter nextPut: Smalltalk allClasses ] ] ].
>> ] timeToRun. "0:00:00:02.176"
>>
>> But in light of alternative streams and some optimisation, this works too:
>>
>> [
>> | file |
>> file := (File named: '/tmp/file.ston') openForWrite.
>> [
>> ZnBufferedWriteStream on: (ZnCharacterWriteStream on: file) do: [ :out |
>>   (STON writer on: out) in: [ :stonWriter |
>>     30 timesRepeat: [
>>       stonWriter nextPut: Smalltalk allClasses ] ] ]
>> ] ensure: [ file close ].
>> ] timeToRun. "0:00:00:00.385"
>>
>> Which is faster.
>>
>> Total file size is ~1.2MB.
>>
>> BTW, we need #readStreamDo: and #writeStreamDo: on File I think, as it encourages proper resource management.
>>
>>> On 5 Feb 2017, at 19:16, Henrik Nergaard <[hidden email]> wrote:
>>>
>>> http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser
>>>
>>> ---------------------
>>> | ston file|
>>>
>>> ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
>>> file := (FileStream fileNamed: 'file.ston').
>>>
>>> ston whileDisplayingProgress
>>> action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
>>> open;
>>> fillOwner
>>> ---------------------
>>>
>>> Best regards,
>>> Henrik
>>>
>>> -----Opprinnelig melding-----
>>> Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
>>> Sendt: 05 February 2017 16:56
>>> Til: Pharo Development List <[hidden email]>
>>> Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
>>>
>>> Hi all,
>>>
>>> is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?
>>>
>>> Cheers.
>>> Uko
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Henrik-Nergaard
In reply to this post by Uko2
You can create a morph that steps until the process is terminated.
Attached is an example class:

====================
StepForProcessMorph new
        process: [ 10 seconds asDelay wait ];
        extent: 200 asPoint;
        openCenteredInWorld
====================

Best regards,
Henrik

-----Opprinnelig melding-----
Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
Sendt: 05 February 2017 20:33
Til: Pharo Development List <[hidden email]>
Emne: Re: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

This is a really nice solution for STON, thank you!

But in general terms, imagine I have some task and it’s not the trivial to add a progress bar. I could spawn a string morph and make circle the digits with some interval, but maybe there is something easier. For example Kommiter had a spinner morph that you could just open and it would be spinning. So when you run a task you can easily see that the task is still running

Uko

> On 5 Feb 2017, at 20:01, Sven Van Caekenberghe <[hidden email]> wrote:
>
> A bit off topic, but I would do the STON writing as follows:
>
> [
> (FileLocator temp / 'file.ston') writeStreamDo: [ :out |  (STON writer
> on: out) in: [ :stonWriter |
>    30 timesRepeat: [
>      stonWriter nextPut: Smalltalk allClasses ] ] ].
> ] timeToRun. "0:00:00:02.176"
>
> But in light of alternative streams and some optimisation, this works too:
>
> [
> | file |
> file := (File named: '/tmp/file.ston') openForWrite.
> [
>  ZnBufferedWriteStream on: (ZnCharacterWriteStream on: file) do: [ :out |
>    (STON writer on: out) in: [ :stonWriter |
>      30 timesRepeat: [
>        stonWriter nextPut: Smalltalk allClasses ] ] ] ] ensure: [ file
> close ].
> ] timeToRun. "0:00:00:00.385"
>
> Which is faster.
>
> Total file size is ~1.2MB.
>
> BTW, we need #readStreamDo: and #writeStreamDo: on File I think, as it encourages proper resource management.
>
>> On 5 Feb 2017, at 19:16, Henrik Nergaard <[hidden email]> wrote:
>>
>> http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser
>>
>> ---------------------
>> | ston file|
>>
>> ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
>> file := (FileStream fileNamed: 'file.ston').
>>
>> ston whileDisplayingProgress
>> action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
>> open;
>> fillOwner
>> ---------------------
>>
>> Best regards,
>> Henrik
>>
>> -----Opprinnelig melding-----
>> Fra: Pharo-dev [mailto:[hidden email]] På vegne av
>> Yuriy Tymchuk
>> Sendt: 05 February 2017 16:56
>> Til: Pharo Development List <[hidden email]>
>> Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
>>
>> Hi all,
>>
>> is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?
>>
>> Cheers.
>> Uko
>
>


StepForProcessMorph.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

philippeback
In reply to this post by Henrik-Nergaard
In the base image

Smalltalk allClasses 
do:[:aClass| (Delay forMilliseconds: 1) wait]
displayingProgress:[:aClass| 'Processing ', aClass name].

Phil

On Sun, Feb 5, 2017 at 7:16 PM, Henrik Nergaard <[hidden email]> wrote:
http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser

---------------------
| ston file|

ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
file := (FileStream fileNamed: 'file.ston').

ston whileDisplayingProgress
        action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
        open;
        fillOwner
---------------------

Best regards,
Henrik

-----Opprinnelig melding-----
Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
Sendt: 05 February 2017 16:56
Til: Pharo Development List <[hidden email]>
Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko

Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

philippeback
In reply to this post by Uko2
Maybe time to resurrect the AnimatedImageMorph that can load an animated gif... 



Phil

On Sun, Feb 5, 2017 at 8:32 PM, Yuriy Tymchuk <[hidden email]> wrote:
This is a really nice solution for STON, thank you!

But in general terms, imagine I have some task and it’s not the trivial to add a progress bar. I could spawn a string morph and make circle the digits with some interval, but maybe there is something easier. For example Kommiter had a spinner morph that you could just open and it would be spinning. So when you run a task you can easily see that the task is still running

Uko

> On 5 Feb 2017, at 20:01, Sven Van Caekenberghe <[hidden email]> wrote:
>
> A bit off topic, but I would do the STON writing as follows:
>
> [
> (FileLocator temp / 'file.ston') writeStreamDo: [ :out |
>  (STON writer on: out) in: [ :stonWriter |
>    30 timesRepeat: [
>      stonWriter nextPut: Smalltalk allClasses ] ] ].
> ] timeToRun. "0:00:00:02.176"
>
> But in light of alternative streams and some optimisation, this works too:
>
> [
> | file |
> file := (File named: '/tmp/file.ston') openForWrite.
> [
>  ZnBufferedWriteStream on: (ZnCharacterWriteStream on: file) do: [ :out |
>    (STON writer on: out) in: [ :stonWriter |
>      30 timesRepeat: [
>        stonWriter nextPut: Smalltalk allClasses ] ] ]
> ] ensure: [ file close ].
> ] timeToRun. "0:00:00:00.385"
>
> Which is faster.
>
> Total file size is ~1.2MB.
>
> BTW, we need #readStreamDo: and #writeStreamDo: on File I think, as it encourages proper resource management.
>
>> On 5 Feb 2017, at 19:16, Henrik Nergaard <[hidden email]> wrote:
>>
>> http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser
>>
>> ---------------------
>> | ston file|
>>
>> ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
>> file := (FileStream fileNamed: 'file.ston').
>>
>> ston whileDisplayingProgress
>>      action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
>>      open;
>>      fillOwner
>> ---------------------
>>
>> Best regards,
>> Henrik
>>
>> -----Opprinnelig melding-----
>> Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
>> Sendt: 05 February 2017 16:56
>> Til: Pharo Development List <[hidden email]>
>> Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
>>
>> Hi all,
>>
>> is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?
>>
>> Cheers.
>> Uko
>
>



Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

HilaireFernandes
In reply to this post by Uko2
Hi Yuriy,

For DrGeo I wrote this spinner

DrGLoader start.
DrGLoader stop

--
Dr. Geo
http://drgeo.eu

DrGLoader.st.zip (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

kilon.alios
In reply to this post by Uko2
Fork can be used to avoid freezing issues unless of course they are caused by the VM. VM usually prefer to crash.

I have used fork once to load a very glitchy package when StHub was misbeheaving.

You do not need a spinner in this case because you can keep using the image. But if you want to find out if the process indeed has frozen in that case I can see its need.

On Sun, Feb 5, 2017 at 5:56 PM Yuriy Tymchuk <[hidden email]> wrote:
Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko
Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Henrik-Nergaard
In reply to this post by philippeback

Yes, but that will block the UI.

The progress bar update (world rendering) is done by force using “self currentWorld displayWorld”, which also means that if the #do:displayingProgress: is forked there will be more than one UI rendering at the same time.

 

Open a window, evaluate the script below, drag and drop the window around.

[

Smalltalk allClasses 

do:[:aClass| (Delay forMilliseconds: 1) wait]

displayingProgress:[:aClass| 'Processing ', aClass name].

] fork

 

Best regards,

Henrik

 

Fra: Pharo-dev [mailto:[hidden email]] På vegne av [hidden email]
Sendt: 05 February 2017 21:43
Til: Pharo Development List <[hidden email]>
Emne: Re: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

 

In the base image

 

                        Smalltalk allClasses 

                                    do:[:aClass| (Delay forMilliseconds: 1) wait]

                                    displayingProgress:[:aClass| 'Processing ', aClass name].

 

Phil

 

On Sun, Feb 5, 2017 at 7:16 PM, Henrik Nergaard <[hidden email]> wrote:

http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser

---------------------
| ston file|

ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
file := (FileStream fileNamed: 'file.ston').

ston whileDisplayingProgress
        action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
        open;
        fillOwner
---------------------

Best regards,
Henrik

-----Opprinnelig melding-----
Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
Sendt: 05 February 2017 16:56
Til: Pharo Development List <[hidden email]>
Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko

 

Reply | Threaded
Open this post in threaded view
|

Re: How can I create a trivial "spinner" etc, to see if image is busy?

Uko2
Hey guys, thanks for all the replies,

I know there there are many ways to do it right, but I don’t have time to do a nice implementation because I want to see if I can hack something out of the data that I have and so I just need a way to see whether my image is busy.

This did a job for me (and it’s the shortest thing I came up with, so I can put into my snippets collection):
(Morph newAnonymousSubclass
compile: 'step self color: self color negated';
compile: 'stepTime ^ 500';
new) openInHand

Cheers
Uko


On 5 Feb 2017, at 22:39, Henrik Nergaard <[hidden email]> wrote:

Yes, but that will block the UI.
The progress bar update (world rendering) is done by force using “self currentWorld displayWorld”, which also means that if the #do:displayingProgress: is forked there will be more than one UI rendering at the same time.
 
Open a window, evaluate the script below, drag and drop the window around.
[
Smalltalk allClasses 
do:[:aClass| (Delay forMilliseconds: 1) wait]
displayingProgress:[:aClass| 'Processing ', aClass name].
] fork
 
Best regards,
Henrik
 
Fra: Pharo-dev [[hidden email]] På vegne av [hidden email]
Sendt: 05 February 2017 21:43
Til: Pharo Development List <[hidden email]>
Emne: Re: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?
 
In the base image
 
                        Smalltalk allClasses 
                                    do:[:aClass| (Delay forMilliseconds: 1) wait]
                                    displayingProgress:[:aClass| 'Processing ', aClass name].
 
Phil
 
On Sun, Feb 5, 2017 at 7:16 PM, Henrik Nergaard <[hidden email]> wrote:
http://smalltalkhub.com/#!/~Latsabben/GafletFremgangFremviser

---------------------
| ston file|

ston := (1 to: 30) flatCollect: [:ix |STON toStringPretty: Smalltalk allClasses].
file := (FileStream fileNamed: 'file.ston').

ston whileDisplayingProgress
        action: [ :stream | file nextPutAll: stream ] whenDone: [ file close ];
        open;
        fillOwner
---------------------

Best regards,
Henrik

-----Opprinnelig melding-----
Fra: Pharo-dev [mailto:[hidden email]] På vegne av Yuriy Tymchuk
Sendt: 05 February 2017 16:56
Til: Pharo Development List <[hidden email]>
Emne: [Pharo-dev] How can I create a trivial "spinner" etc, to see if image is busy?

Hi all,

is there an easy was to do some thing that is constantly changing? so if my image freezes (to export a 1gb ston file for example) I can see when it’s done.    Or maybe there is a way to send a mac notification from Pharo?

Cheers.
Uko