Comments (4)
The problem that you've got is that I've yet to expose a method to draw the next frame, so you need to reverse the logic and put your status into an Effect. For example:
from asciimatics.effects import Print
from asciimatics.renderers import BarChart
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError, StopApplication
import sys
from random import randint
# Simple progress indicator - from 0 to 100
progress = 0
def get_progress():
global progress
if randint(0, 100) > 10:
progress += 1
return progress
class ProgressBar(Print):
def __init__(self, screen):
super(ProgressBar, self).__init__(
screen,
BarChart(
7, 60, [get_progress],
char=">",
scale=100.0,
labels=True,
axes=BarChart.X_AXIS),
x=(screen.width - 60) // 2,
y=(screen.height - 7) // 2,
transparent=False, speed=2)
def _update(self, frame_no):
global progress
if progress >= 100:
raise StopApplication("100% complete")
else:
super(ProgressBar, self)._update(frame_no)
def demo(screen):
scenes = []
effects = [
ProgressBar(screen)
]
scenes.append(Scene(effects, -1))
screen.play(scenes, stop_on_resize=True)
while True:
try:
Screen.wrapper(demo)
sys.exit(0)
except ResizeScreenError:
pass
from asciimatics.
@erturpin was that helpful? Can I close this down now?
from asciimatics.
with no response in 2 weeks, I'm assuming that this can now be closed...
from asciimatics.
Thanks was helpful for me
from asciimatics.
Related Issues (20)
- Asciimatics doesn't print anything. HOT 3
- Custom subprocess integration HOT 2
- Rain test fails randomly HOT 10
- Load another form after initialization HOT 5
- RayCaster sample "swallows" key when commenting out RayCaster effect HOT 6
- DarkGray access on Windows/Powershell? HOT 7
- Automate user inputs HOT 4
- Leave and re-enter asciimatics mode? HOT 2
- Emojis with "hidden characters"? HOT 11
- particles HOT 4
- Mouse Events in Win11 HOT 4
- Implementing Widget's Custom Color Palettes HOT 4
- Can we donate to the project via Paypal? HOT 3
- New release? HOT 3
- Incompatible with Python 3.12 (imp module removed)
- Support multi-line text rolling in a rect HOT 3
- The effect of selecting the check box in version 1.15.0 is different from that in version 1.14.0 HOT 1
- Right side will not align if you use Unicode character. HOT 1
- Add a way to let the user provide a custom text wrapping function HOT 8
- `RadioButtons` does not consider the right pallet when item is selected without focus HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciimatics.