-
QuestionThank you for the awesome web ui lib!
However, the widths of every characters in For example:
and:
And there are no space has been deleted! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
log = ui.log()
log.push('AAAA'*9)
log.push('1234'*9) |
Beta Was this translation helpful? Give feedback.
-
You could simply use a monospace font: content = '''A B C D
. . . .
1 2 3 4'''
ui.textarea(value=content).style('font-family: "Courier New, Courier, monospace;') |
Beta Was this translation helpful? Give feedback.
-
Thank you everyone for nice help. I compared the default
So I chose from nicegui import binding, ui
AUTO_COMPLETE = "hi = len('world')\nprint(hi)".split('\n')
class Console:
MAX_LINES:int = 16
lines:str = binding.BindableProperty()
def __init__(self):
self.lines = ""
def _pop(self):
if self.lines.count('\n') == self.MAX_LINES:
self.lines = self.lines[:self.lines[:-1].rfind('\n')+1]
def push(self, line):
self._pop()
self.lines = f"{line}\n" + self.lines
def echo(value): # some external program to talk with
return value
console = Console()
with ui.card().classes('w-50 h-50'):
i = ui.input(autocomplete=AUTO_COMPLETE)
with ui.scroll_area().classes('w-full h-96'):
o = ui.code().classes('w-full h-full').bind_content(console, 'lines')
i.on('keydown.enter', lambda: console.push(echo(i.value)))
ui.run(port=8888) |
Beta Was this translation helpful? Give feedback.
You could simply use a monospace font: