473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text Animation

Hello,

I was wondering if anyone has done any simple text-based animation?

I mean things such as text-based pre-loaders. One example would be
when you use the *nix utility called `wget.` You get that fancy "
====> " type of animation as you download a large file. Or maybe even
a rotating " | " that I have seen before in some installation
programs.

Any ideas how these effects can be achieved?

Thanks a lot!

Faizan
Jul 18 '05 #1
4 6466
Fazer wrote:
Hello,

I was wondering if anyone has done any simple text-based animation?

I mean things such as text-based pre-loaders. One example would be
when you use the *nix utility called `wget.` You get that fancy "
====> " type of animation as you download a large file. Or maybe even
a rotating " | " that I have seen before in some installation
programs.

Any ideas how these effects can be achieved?

Thanks a lot!

Faizan

Yeah, don't print linefeed ('\n') characters, only print carriage
returns ('\r').

import time
for i in xrange(75):
print '*'*i, '\r',
time.sleep(.1)

- Josiah
Jul 18 '05 #2
Fazer wrote:

snip
Or maybe even
a rotating " | " that I have seen before in some installation
programs.


On each loop use the \b backspace character to move the cursor back,
then overwrite with progressive characters for the spinner. This can
look bad if the cursor is visible.
Jul 18 '05 #3

faizan> Any ideas how these effects can be achieved?

You can start here:

http://www.musi-cal.com/~skip/python/progress.py

That module provides a couple simple progress counters.

Skip

Jul 18 '05 #4
Fazer wrote:
Hello,

I was wondering if anyone has done any simple text-based animation?

I mean things such as text-based pre-loaders. One example would be
when you use the *nix utility called `wget.` You get that fancy "
====> " type of animation as you download a large file. Or maybe even
a rotating " | " that I have seen before in some installation
programs.

Any ideas how these effects can be achieved?

Thanks a lot!

Faizan


I use this:

###################################
import sys

class Spinner:
SYMBOLS = '|/-\\'
def __init__(self):
self.index = 0

def __call__(self):
sys.stdout.write(Spinner.SYMBOLS[self.index]+'\b')
self.index = (self.index+1) % len(Spinner.SYMBOLS)

###################################

And call it like this:

###################################
if __name__ == '__main__':
import time

spin = Spinner()
for i in range(100):
spin()
time.sleep(0.1)
###################################
This looks fine under the Win2K cmd window; but, as pointed out in another
reply, you may need to turn off the cursor. I just tested it under Konsole
on Linux, and the block cursor doesn't allow the effect to show.

--Andy
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simena Dinas | last post by:
KToon: 2D Animation Toolkit KToon is a 2D Animation Toolkit designed by animators (Toonka Films) for animators, focused to the Cartoon's industry. This project is covered by the GPL License...
5
by: Brian Angliss | last post by:
I'm relatively new to scripting in JavaScript, so I'm not too surprised I'm having difficulty scripting up an animation effect for my personal site. What I'm trying to do is the following: When...
6
by: Darren | last post by:
X-No-Archive Hi all, Can anyone help me with structuring the data in a small tool I have to build? I'm trying to work out if there's a design pattern or data structure that would remove some...
0
by: Tom Sage via .NET 247 | last post by:
I am trying to display a Form (f2) using the AnimateWindow API. The Form animation works, but the text is shown on the Form AFTER the animation is done. Is there a way to put the text on the Form...
3
by: James | last post by:
Hello, I'm new to c# and have created an animation which draws directly to the window, it uses the code below which all works. I would like to know if this is the 'correct' way to do it - or...
4
by: petermichaux | last post by:
Hi, Is there any way to make DOM scripted animation smoother? Flash is far superior in this area. Any one here know what makes Flash so smooth by comparison? I don't like the fact that the...
2
by: rdemyan via AccessMonster.com | last post by:
My application has a lot of complicated SQL statements, calculations, processing that takes time. I've created a custom form to act like a messagebox. It has 10 small rectangles on it that change...
0
by: ngocviet | last post by:
I use ImageMagick to add text to my animation gif, It's OK but my file is 4-5 times bigger than before(47.5K --195K :( ) The animation have 15 frames Anyone know how to reduce file size or any...
4
by: Sin Jeong-hun | last post by:
Most applications, including Windows Explorer, show some sort of 'wait' dialog with animation when a lengthy operation is going on. For example, When the Windows Explorer is searching for...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.