[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide option to render more than one spinner at the same time #17

Open
danieltdp opened this issue Oct 3, 2017 · 8 comments · May be fixed by #155
Open

Provide option to render more than one spinner at the same time #17

danieltdp opened this issue Oct 3, 2017 · 8 comments · May be fixed by #155

Comments

@danieltdp
Copy link
danieltdp commented Oct 3, 2017

Suppose you get multiple long tasks at hand.
It should be nice to be able to start more than one spinner before finishing the last one

take this as an example:

 from halo import Hal
 
 a = start_task_a()
 a_spinner = Halo({'text': 'Do A', 'spinner': 'dots'})
 a_spinner.start()
 a_is_spinning = True
 
 b = start_task_b()
 b_spinner = Halo({'text': 'Do B', 'spinner': 'dots'})
 b_spinner.start()
 b_is_spinning = True
 
 while a_is_spinning or b_is_spinning:
     if a.is_finished():
         a_spinner.succeed()
         a_is_spinning = False
     if b.is_finished():
         b_spinner.succeed()
         b_is_spinning = False
@bertokhoury
Copy link

@manrajgrover maybe one simply needs to initialize that if two spinners are spinning. Then, simply print a new line betweem them?

@manrajgrover
Copy link
Owner

@bertokhoury It can surely be tried. I was also looking to explore how other libraries do the same thing. listr is one of them. Do let me know if you get a chance to implement your solution. Also, feel free to send a PR for the same. 😄

@winterjung
Copy link
Contributor

@manrajgrover I found that they use list and line counter to push string, render and clear in listrlistr-update-rendererlog-updateansi-escapes.
How about wrapping frame in something like output?

example

# render
output = ['/ First task', '- Second task', '+ Last task']
stream.write('\n'.join(output))
# output maybe
# / First task
# - Second task
# + Last task

# clear
line_count = len(output)
for i in range(line_count):
    stream.write('\r')
    stream.write(CLEAR_LINE)
    stream.write('\033[1A')  # Move the cursor up 1 line

refer

ansi-escapes source

@manrajgrover
Copy link
Owner

@jungwinter That is such a clever solution! I guess we can support that. We would need to think of a design to accommodate this considering each spinner has its own thread and we would need to get the frame from each spinner before rendering. Let me know if you have already thought about the same.

@thisHermit
Copy link
thisHermit commented Oct 4, 2019

I would like to work on this issue. @manrajgrover could you assign me on this?

@JustinTervala
Copy link

Any updates on this feature? I would like to use something like this

@manrajgrover
Copy link
Owner

@JustinTervala there seems to be some progress in #155 which implements something similar. Have a look at the PR to see if it meets your requirement.

@frostming frostming linked a pull request Oct 30, 2020 that will close this issue
3 tasks
@JustinTervala
Copy link

#155 looks like it would work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants