Replies: 1 comment 1 reply
-
I'm pretty sure the source code is in the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear Textualize team,
Let me start by thanking you for this great project! I am already a big Rich fan and have just started picking up Textual.
While prototyping a small project, I encountered a few use cases where I wasn't sure what the best practices would look like regarding their implementation.
Thank you very much in advance for considering my questions 🙏🏻
Context
The project is a small command line utility that interacts with another device in the local network. The CLI allows the user to specify the address of the device manually. Alternatively, the device announces its service via Bonjour/mDNS. So if the user does not provide an address, I want to show a small textual app that lists all available devices and lets the user select one. This is what my current prototype (source code) looks like:
These are the situations where I would appreciate your input regarding best practices:
Questions
Listing available devices
I want to list all devices with a fixed height, in a table-like manner. The current implementation uses a table that redraws from scratch on every key input, keeping track of the selected index. Looking at DockView and the focus/hover functionality of widgets, this feels like reinventing the wheel.
Scrollable DockView
Ideally, the view would scroll in case of overflow. My first approach was to wrap a DockView in a ScrollView. But in that case, nothing gets rendered.
The example in this tweet looks like exactly what I need but I did not find the source code yet.
Reloading DockView content
What is the best practice to reload the content of a dock view? Should I simply regenerate the whole DockView?
Shutdown
I want to clean up the network resources on shutdown. I saw the
event.Shutdown
class butMyApp.on_shutdown
does not seem to be called on shutdown. My current approach is to overwriteApp.shutdown()
which does not feel clean.Returning information on shutdown
Once the user selected a device, I would like to stop the textual app and use the selection for the actual command line utity. What would be the best practice to return a status code/information from the application? Something as easy as a custom attribute containing the result that can be accessed after shutdown?
Beta Was this translation helpful? Give feedback.
All reactions