Kynn Jones | 30 Jun 2012 17:31
Picon

Looking for simple record-oriented table navigator in urwid

As part of a unix CLI utility, I would like to implement a widget to help the user act on the contents of this one directory (which is special for this utility).

(FWIW, the directory interface I have in mind is inspired by Emacs's dired mode, although for my purposes I need only a small subset of dired's functionality.)

So, to be more specific, I'm looking for a *simple* urwid-based implementation of a "navigable table of records", with the properties similar to the following (they are all quite basic and commonplace by today's standards):

  • the table takes up the entire window (irrespective of the number of records available), and consists of one fixed header row at the top the window, one message/status row at the bottom, and a records "pane" in-between, showing as many records as can be accommodated in the available space;
  • the table can be "navigated" by pressing the up- and down-arrow keys; here "navigation" consists of nothing more than changing the record that "has the focus", aka, "the current record", as indicated by a change of color (e.g. reverse video), or simply by the vertical position (i.e. the row) of a typical character-sized rectangular cursor;
  • all records consist of the same number of fields, and always take up one row per record (hence, field contents are clipped if necessary);
  • all fields except for the rightmost have fixed widths; the width of the rightmost field expands to fill up the window's width; only the width of the rightmost field is affected by resizing of the containing window.
I am hoping that this bare-bones functionality can be implemented very simply with urwid.  ISimplicity is essential for me here, because, although I have been programming for decades, I have no prior experience whatsoever programming text-based UIs, and only minimal experience with GUI programming).

So, if anyone knows of a *simple* urwid implementation of an interface similar to the one outlined above, and that I could at least study, please point me to it.

Thanks!

PS: I was really excited to discover urwid and to find the example file browser at http://excess.org/urwid/browser/examples/browse.py, since I thought I could adapt this code to what I'm trying to do.  But, after studying browse.py for a few hours (along with the rest of the urwid docs), I had to give up.  I just couldn't wrap my brain around it!  Clearly, browse.py is well beyond my IQ.  In fact, after inspecting browse.py, I now fear that urwid in general is beyond my IQ.  So I'm bummed, because I was really psyched to use urwid for this.  What keeps this hope still alive is that, since the functionality I have in mind is *significantly simpler* than browse.py's (for example, I don't need tree navigation, with expanding and collapsing of nodes, etc.), an urwid-based implementation of it may still be something that I can handle.  Hence my first post to the urwid list.

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Ian Ward | 30 Jun 2012 18:50
Favicon
Gravatar

Re: Looking for simple record-oriented table navigator in urwid

Welcome Kynn,


See the attached example, it should be enough get you started.  It's the sort of thing I've been planning to add to the tutorial because many people build interfaces like this.

I'm sorry you find the documentation confusing. We are working on it though!  Detailed feedback about things you find confusing is helpful. Join the IRC channel if you'd like to help.

Ian

On Sat, Jun 30, 2012 at 11:31 AM, Kynn Jones <kynnjo <at> gmail.com> wrote:
As part of a unix CLI utility, I would like to implement a widget to help the user act on the contents of this one directory (which is special for this utility).

(FWIW, the directory interface I have in mind is inspired by Emacs's dired mode, although for my purposes I need only a small subset of dired's functionality.)

So, to be more specific, I'm looking for a *simple* urwid-based implementation of a "navigable table of records", with the properties similar to the following (they are all quite basic and commonplace by today's standards):
  • the table takes up the entire window (irrespective of the number of records available), and consists of one fixed header row at the top the window, one message/status row at the bottom, and a records "pane" in-between, showing as many records as can be accommodated in the available space;
  • the table can be "navigated" by pressing the up- and down-arrow keys; here "navigation" consists of nothing more than changing the record that "has the focus", aka, "the current record", as indicated by a change of color (e.g. reverse video), or simply by the vertical position (i.e. the row) of a typical character-sized rectangular cursor;
  • all records consist of the same number of fields, and always take up one row per record (hence, field contents are clipped if necessary);
  • all fields except for the rightmost have fixed widths; the width of the rightmost field expands to fill up the window's width; only the width of the rightmost field is affected by resizing of the containing window.
I am hoping that this bare-bones functionality can be implemented very simply with urwid.  ISimplicity is essential for me here, because, although I have been programming for decades, I have no prior experience whatsoever programming text-based UIs, and only minimal experience with GUI programming).

So, if anyone knows of a *simple* urwid implementation of an interface similar to the one outlined above, and that I could at least study, please point me to it.

Thanks!

PS: I was really excited to discover urwid and to find the example file browser at http://excess.org/urwid/browser/examples/browse.py, since I thought I could adapt this code to what I'm trying to do.  But, after studying browse.py for a few hours (along with the rest of the urwid docs), I had to give up.  I just couldn't wrap my brain around it!  Clearly, browse.py is well beyond my IQ.  In fact, after inspecting browse.py, I now fear that urwid in general is beyond my IQ.  So I'm bummed, because I was really psyched to use urwid for this.  What keeps this hope still alive is that, since the functionality I have in mind is *significantly simpler* than browse.py's (for example, I don't need tree navigation, with expanding and collapsing of nodes, etc.), an urwid-based implementation of it may still be something that I can handle.  Hence my first post to the urwid list.


_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid


Attachment (simple.py): application/octet-stream, 901 bytes
_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Kynn Jones | 1 Jul 2012 01:14
Picon

Re: Looking for simple record-oriented table navigator in urwid

On Sat, Jun 30, 2012 at 12:50 PM, Ian Ward <ian <at> excess.org> wrote:

See the attached example, it should be enough get you started.

Hi Ian!

That code is exactly what I was looking for.  Thanks!

The script had a small typo that was causing it to fail, but the code is so clear and simple that I had no trouble fixing it.  All I had to do was change a couple of lines, from

def cols(a, b, c):
    return urwid.Columns([
        (10, urwid.Text(a)),
        (10, urwid.Text(b)),
        urwid.Text(c, wrap='clip')])

to

def cols(a, b, c):
    return urwid.Columns([
        ('fixed', 10, urwid.Text(a)),
        ('fixed', 10, urwid.Text(b)),
        urwid.Text(c, wrap='clip')])


After that, it worked beautifully.  Thanks!!!
 
It's the sort of thing I've been planning to add to the tutorial because many people build interfaces like this.

I'm sorry you find the documentation confusing. We are working on it though!  Detailed feedback about things you find confusing is helpful.

Actually, I think the documentation for urwid is very good.  In retrospect I think what stumped me was that the docs present urwid as a fairly full-blown windowed UI system, which is far more than I needed.  I kept looking in vain for documentation devoted to the simplest possible text-based UIs, such as the one I described in my initial message, or ones consisting of a sequence of menus of numbered choices for the user to choose from, or a pager like less(1).  I would imagine that the majority of programmers looking at the urwid docs for the first time urwid are doing so because they want to implement such very simple interfaces.

Maybe one way to look at the situation is that the current docs focus primarily on "advanced text-based interfaces with urwid".  What's missing is a cookbook-style section devoted to the *simplest* text-based widgets.

kj

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
bino oetomo | 30 Aug 2012 08:27
Favicon

Re: Looking for simple record-oriented table navigator in urwid

Dear Ian and All
I know this is an old thread
On 07/01/2012 06:14 AM, Kynn Jones wrote:
> On Sat, Jun 30, 2012 at 12:50 PM, Ian Ward<ian <at> excess.org>  wrote:
>
>> See the attached example, it should be enough get you started.

I've he same brain problem.
Yes I take a look at your example .. and it work.

Just a thought . errr no .. cry for help :
It'll be great if there is an example of simple/basic CRUD application.
That is :
1. Screen with :
++ Top part : Form Like Display
++ Midle : Table look of Array
++ Bottom : Shortcuts description
2. Functional :
a. Start : Just a blank of screen# 1
b. Keys :
=> Up/Down : Move the highlite
It will Update the Top Part display
=> 'Ins'/'Del/'Enter' : Add/Delete/Edit the row respectively
It'll pop-up a new Edit-Screen

Sincerely
-bino-
Ian Ward | 30 Aug 2012 14:11
Favicon
Gravatar

Re: Looking for simple record-oriented table navigator in urwid

On Thu, Aug 30, 2012 at 2:27 AM, bino oetomo <bino <at> indoakses-online.com> wrote:
> Dear Ian and All
> I know this is an old thread
> On 07/01/2012 06:14 AM, Kynn Jones wrote:
>> On Sat, Jun 30, 2012 at 12:50 PM, Ian Ward<ian <at> excess.org>  wrote:
>>
>>> See the attached example, it should be enough get you started.
>
> I've he same brain problem.
> Yes I take a look at your example .. and it work.
>
> Just a thought . errr no .. cry for help :
> It'll be great if there is an example of simple/basic CRUD application.

Have you seen http://9v.lt/projects/python/d0xbase/ ?

Ian
bino oetomo | 31 Aug 2012 04:12
Favicon

Re: Looking for simple record-oriented table navigator in urwid

On 08/30/2012 07:11 PM, Ian Ward wrote:
> Have you seen http://9v.lt/projects/python/d0xbase/ ?
Thankyou for your enlightment.
It's a really good things, but still too complex the be learned.
I still googling for more examples.

well, i intend to write a really really basic Point Of Sale.

sincerely
-bino-
> Ian
>
> _______________________________________________
> Urwid mailing list
> Urwid <at> lists.excess.org
> http://lists.excess.org/mailman/listinfo/urwid
>
Kynn Jones | 1 Sep 2012 02:55
Picon

Re: Looking for simple record-oriented table navigator in urwid

Very, very cool, DOxBase...  (it makes a bit nostalgic, too)

Thanks for the pointer


On Thu, Aug 30, 2012 at 8:11 AM, Ian Ward <ian <at> excess.org> wrote:
On Thu, Aug 30, 2012 at 2:27 AM, bino oetomo <bino <at> indoakses-online.com> wrote:
> Dear Ian and All
> I know this is an old thread
> On 07/01/2012 06:14 AM, Kynn Jones wrote:
>> On Sat, Jun 30, 2012 at 12:50 PM, Ian Ward<ian <at> excess.org>  wrote:
>>
>>> See the attached example, it should be enough get you started.
>
> I've he same brain problem.
> Yes I take a look at your example .. and it work.
>
> Just a thought . errr no .. cry for help :
> It'll be great if there is an example of simple/basic CRUD application.

Have you seen http://9v.lt/projects/python/d0xbase/ ?

Ian

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid

Gmane