Notes on using logview for external programs #4191
ed2050
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently started using logview to show output from external programs. Works great, but ran into some tricky bits. Thought I'd share for others.
Usage
I wanted a function that does the following:
Implementation of this func as
runprog()
at end of this post. Pretty straightforward. Usage is like this:User clicks button,
imgstats
is invoked, results are shown on page. Beautiful.Tricky bits
Here's the result with default quasar styling. Total mess. I assure you there is output text in the box, though you have to really squint to see it (text is highlighted to help).
The tricky bits are fixing Quasar's default settings, which are awful:
Fixes
1 - easy to change width. You can use classes & props in nicegui. Even better, just set in css. I use width and max-width so it takes all available space but isn't ridiculously wide.
2 - easy to fix by setting text-wrap.
3 - opacity can be fixed once you figure out the issue. but have to use
!important
because quasar doesn't care about your styles.4 - this was the trickiest. You can set
height
but then height is fixed. If output is short, you don't want a huge empty box. If output is long, you don't want a short box with tons of scrolling. So just use max-height right?The problem is, logview contents change. We want height to adjust dynamically. On first display, logview is empty. Then we log 1 or 2 info lines while external program runs. When program finishes, we log more - maybe a little, maybe a lot.
You would think
height : fit-content
orheight : max-content
would do the trick. But no. They set the height once but don't adjust as content changes, from what I can tell.Another problem is that quasar sticks a
height
property on logview. Which overrides any css settings. Why style with css when you can hardcode properties on each element, right quasar? Brilliant! 🙄The solution is twofold. First, use
props('height=fit-content')
on your nicegui element to replace the pixel height crap quasar sticks on it. Second, in your css usefield-sizing : content
to make the textarea resize dynamically. Withmax-height
as a limit.Et voila!
CSS
Here's the css incorporating these fixes. And some decent margins because quasar / tailwind believe whitespace is the tool of the devil - readability be damned. 👿
Code
Here's the implementation of
runprog
.Beta Was this translation helpful? Give feedback.
All reactions