-
-
Notifications
You must be signed in to change notification settings - Fork 844
log.push
support classes
, style
, and props
#4750
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
log.push
support classes
, style
, and props
#4750
Conversation
Proposed Documentation text Styling linesOn the basis that individual lines in Note that if applied, this would clear any existing classes/style/props currently set as default on |
Two quick questions:
|
Yes. It is for symmetry and maximum flexibility (aka "just in case"). It also may be useful to select/filter those elements via looking for the
But otherwise, if I set default style I fear Especially, I don't think the |
Ok, I agree. Just because log lines happen to be implemented using As a demo for the documentation I could imaging something like this: log = ui.log(max_lines=10).classes('w-full h-20')
ui.button('Log debug', on_click=lambda: log.push('Some detail information', classes='text-gray-600'))
ui.button('Log info', on_click=lambda: log.push('Everything is fine', classes='text-blue-600'))
ui.button('Log warning', on_click=lambda: log.push('Something is fishy', classes='text-yellow-600'))
ui.button('Log error', on_click=lambda: log.push('Something is wrong', classes='text-red-600'))
Good question. I can't remember why the |
…icegui into log-label-customization
I think the Added an unstyled text so as to make it more clear. Introduced the use of |
My first pytest. Review with care! |
see https://ngdemo.bitplan.com/log_handler combining the two approaches would IMHO be great. Especially in the context of Shell calls see https://github.com/WolfgangFahl/nicegui_widgets/blob/main/ngwidgets/shell.py |
Let's keep this PR focused on the minimum functionality as requested in #2508 If you find these approaches interesting for inclusion into NiceGUI, you can head to https://github.com/zauberzeug/nicegui/discussions/categories/ideas-feature-requests and start a thread. I'd love to discuss more when I have time after exams! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request, @evnchn!
I just added the new parameters to the docstrings, cleaned up the pytest and shortened the demo lines for better readablity.
Ready to merge! 🚀
This PR addresses the most basic demand highlighted in #2508, that is to color individual lines in
ui.log
.Implementation details
Note that, the user may have already styled the
ui.label
viadefault_classes
,default_style
and/ordefault_props
.Since:
log.push
ui.label
instances and style it themselves sinceself.remove(0)
I have elected to make the
classes
,style
, andprops
, should they be passed in, replace existing one and be final.Test script
What this PR doesn't do
ui.log
Xterm.js
in AddXterm
element #4520To-do
Questions left on the table, which is best if we can answer them
replace
forprops
, and I had to dolabel.props.clear()
?