Add live updating for any render#382
Conversation
Allows for a dedicated area in the project to mess around with code.
Codecov Report
@@ Coverage Diff @@
## master #382 +/- ##
========================================
Coverage 99.72% 99.72%
========================================
Files 54 55 +1
Lines 4654 4794 +140
========================================
+ Hits 4641 4781 +140
Misses 13 13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
I think this is a good idea! A number of people have asked for it. It probably should have an option for thread-based auto refreshing so you could modify your data without having to explicitly refresh it. I'd also need typing, docstrings and tests, but I think you're on the right path. Let me know if you need any pointers. |
|
Great, I'm going to add in the threading next and then clean it up a bit. I think afterwards I can consolidate some of the design decisions this feature contains, that way it can be discussed upon what needs to be done. Then once those get through I can add testing and documentation. |
large. Instead terminal too small will be displayed. This can be turned off with the hide_overflow flag.
|
@willmcgugan I'm currently facing an issue trying to check the output of these live Renders for testing in python 3.6. It seems to be related to handling of utf-8 encoding. Do you know of any workarounds? |
|
Note there are still issues with fluctuating sized displays. Will have to look into deeper. |
|
no worries. Let me know if you need any help with debugging. Will review soon (busy with the day job). |
Mainly the issue comes between ensuring an ordering between new console messages and the live render. Not really sure how to add unit testing for this functionality.
|
Ok so with some additional locking in the LiveRender and RefreshThread, it is now stable (and not deleting console log statements non-deterministically) |
|
Can this pr solve #262 ? |
|
@yihong0618 No, this pr doesn't add any user input handling. |
Thanks a lot. |
|
Sorry for the delay @nathanrpage97! Will look at this soon. |
|
Excellent work @nathanrpage97 Testing now... |
|
Works great. I think my only request would be the ellipsis in the center. You could render it like this, which would also solve the unlikely scenario of a terminal of 2 characters. from rich.text import Text
yield from console.render(
Text('...', overflow="crop", justify="center", end="")
) |
|
Alright the changes have been added in for table_movie_live.py -> table_movie.py and centered overflow ellipsis. |
|
Looks good. Thanks. |
|
@nathanrpage97 Do you have a Twitter handle? I'd like you give you a shoutout when I release the next version of Rich. |
|
Awesome, I don’t use Twitter, so a GitHub plug instead? |
Type of changes
Checklist
Description
I've been looking at ways to have live updating data table from
rich. Whenever I usedLiveRenderit always faced any issues if something else was being logged.So with that in mind I took what was there already from the
Progresscomponent and made a generalized Live Updating view. It allows for the component to be updated by the user with anupdate()function. It currently isn't threaded like Progress is, but could be expanded maybe with a LiveThreaded?Limitations
If the render component is too large, then it will start too not fully clear any of the Renderable above the console view. I have messed around with creating a
safeflag that will have it print "the terminal is too small" instead when this is true. I didn't want to add it here yet before getting feedback.Showcase
Some gist examples