Hi folks,
I recently wrote a demo of the Urwid text user interface library (
http://excess.org/urwid ) for purposes of giving the most basic of introductions to the library at a local conference (LinuxFest Northwest). My demo was about providing a nicer UI for the 'paster create' command. The source code for that demo is here:
I decided to take a look at the paste script source code to see how tough it would be to integrate. Here are some initial thoughts and assumptions:
Assumptions:
* Urwid support would need to be optional, and gracefully degrade back to the current behavior if urwid isn't installed.
* The API can't break backwards compatibility, since there are projects that use paste script as a library for template creation. In particular, the behavior of Command.challenge() would need to remain, and return the user-supplied value immediately
Thoughts:
* Create a new UserInterface class type, and two new implementations of that base class (BasicUI and UrwidUI)
* Instantiate a UserInterface in Command.run(), and save the instance as a property of Command
* Pass through calls to Command.challenge() to UserInterface.challenge(). This always synchronously returns the result of the challenge.
* Implement a new Command.queue_challenge() method.
* Implement Command.present_challenge_queue(), which returns the list of responses from the queued challenges. This would be implemented in BasicUI by merely calling UserInterface.challenge() on everything in the queue, but would be implemented in UrwidUI by presenting the list of questions in a single form.
* Modify Template.check_vars() to call queue_challenge and present_challenge_queue rather than calling challenge.
That last step would have the effect of presenting a screen somewhat like what I'm showing in the attached screenshot when used with basic_package. One nice thing about Urwid is that it's very good at multi-line forms, inserting rows as necessary to accommodate longer text, and providing scrolling when the form size exceeds the given screen real estate.
I may tackle this if there's interest in incorporating the code, if I end up having the time, and if it appears that I'm on the right track. If someone else wanted to take my idea and run with it, I'd be quite happy with that, and provide whatever help you'd need.
Thoughts?
Rob
--
You received this message because you are subscribed to the Google Groups "Paste Users" group.
To post to this group, send email to
paste...@googlegroups.com.
To unsubscribe from this group, send email to
paste-users...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/paste-users?hl=en.