Closed 0xrushi closed 1 year ago
Hey again! I'm taking a bit of time off from all things programming related for personal reasons, but once I'm back I'm planning on focusing on the new documentation, which will detail this type of usecase!
Haha been there, I hope all is well. I'll be waiting for you to be back in God mode :-)
Since documentation is taking a lot longer than intended, here is what I would do in your case:
You already have self._container
defined, so you can manipulate its widgets as much as you want. Simply adding widgets won't do you too well, so you can use the Container.set_widgets
method:
widgets: list[Widget] = []
for line in st:
# We do `line=line` here to avoid some odd behaviour from python closures, where
# `line` would only be evaluated when the function is called, so it would always
# be the last element
widgets.append([f"Button {line!r}", lambda *_, line=line: do_something_with(line)])
self._container.set_widgets(widgets)
Does this answer your question? 😄
I'm trying to build a file explorer like
ranger
In this case I'm taking the output of ls command and listing it in the output box
st = subprocess.check_output(self._input.value, shell=True, text=True)