Simple menu system #10230
Replies: 5 comments 3 replies
-
PicoTui is an option, though with some caveats. It was originally written for MicroPython and, although the author has since gone off in a different direction, it should still work. It doesn't have a tree widget but perhaps you can work with what is provided - or add such a widget. Ideally I'd like to have a port of Textual - but that's a large undertaking! Another option is to create the app using Textual (or whichever library in CPython) and then use Belay to call across to your device when necessary. |
Beta Was this translation helpful? Give feedback.
-
I'd implement the device side as a simple microdot web service to receive commands + arguments over wifi sent from a remote client written in ordinary Python using cmd or cmd2. That is all very trivial to do and if happy with the result then you could later on re-implement the client side in a web framework like vue. |
Beta Was this translation helpful? Give feedback.
-
Hello, fellows, thanks for your inputs. Actually I was thinking in a much simpler (I think) solution, old school pure text solution, not even curses(ish). Instead, something of the sorts print (sub)menu list, print "choose and option", react to the option by calling the callback, print the same (sub)menu again, unless the choice was leaving the (sub)menu, in which case the parent (sub)menu would be printed. PicoTui does look like the closest from what I need though, despite the curses style (but still overkill); I will certainly have a look at it. BR. |
Beta Was this translation helpful? Give feedback.
-
I have been looking at the suggestions and some more and they look like overkill for what I need. Even picotui. It turns out the menu control part itself seems to be fairly simple to implement, the core is probably pretty small and the whole structure would be constituted by a set of lists. The menus would be like these:
If '1' is selected:
If '2' is selected:
If '3' of the above is selected, then the callback would get the numeric value from stdin or the serial port (technically they would the same) and validate it.
Now what I am struggling with now is more basic, how to get the options from the terminal in a non-blocking way, i.e., only when the option identifier (an alphanumeric character) is pressed, the menu object callback is called with the option and invokes the option callback with its arguments. In the case a numeric entry is requested, then a more involved non-blocking input class with edition capabilities (e.g. backspace to correct a typo, ESC to cancel the option, CR(LF) to accept the entry) would be called. As mentioned in my OP, I am trying to avoid reinventing the wheel if I can, I am sure there must be some builtins or modules that do what I described above but I am not being able to find them (my experience with python and MP is still limited, I may be using the wrong keywords to do my search). So, any pointers to documents that allow me to read the options and, if possible, off-the-shelf classes that allow me to do the numeric entry would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
Did you try: https://awesome-micropython.com/#gui |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to control a micropython based embedded system via the USB/Serial port using a simple text based menu system
The menu itself will have a tree structure where items are selected by typing an ASCII character (typically numeric) with esc or '0' to return to the previous upper level. Each (sub)menu would be described by a list with each item having some "menu item text to show", a callback, maybe some object to be passed to the callback. Most menu items will simply chose an operating mode, but some will require entering numeric values, so some consistency check library would also be needed.
I think these are quite simple requirements but I could not find anything after a quick search. Before I dig deeper in the search or worse, write some code myself, possibly reinventing the wheel, I would like to ask the good fellows in the forum if you know some library or libraries that meet the (IMO) simple requirements above.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions