Iñigo Serna | 6 Apr 2007 17:25
Picon

problem with Pile

Hi all,

I'm experimenting with urwid in order to port an old program [1],
written using plain curses, and that nowdays is becoming a bit aged
due to the lack of flexibity of curses (no unicode, ugly UI code,
etc).

I've written a simple and quick proof of concept both to train myself
in urwid and to test the capabilities and speed of the library.

Using 0.9.8.

***test.py*** Lines 227-9. Class Panel, Method Display
I have a Frame whose body is a Columns widget with 2 elements, both identical.
Each element contains a list of Text => "content".

If this Text List is wrapped inside a
ListBox(SimpleListWalker(content), it 's rendered correctly.

But if I embed it inside a Pile(content) or Filler(Pile(content),
height=h) it fails in Text.render method (widget.py:350).

***test2.py***
I've written a small simple code to test it and it works there.

Any idea?

[1] http://inigo.katxi.org/devel/lfm/
Note that this url contains an outdated version of the program.
You can find the last - not public released - at:
(Continue reading)

Ian Ward | 6 Apr 2007 18:03
Favicon
Gravatar

Re: problem with Pile

Iñigo Serna wrote:
> Hi all,
> 
> I'm experimenting with urwid in order to port an old program [1],
> written using plain curses, and that nowdays is becoming a bit aged
> due to the lack of flexibity of curses (no unicode, ugly UI code,
> etc).
> 
> I've written a simple and quick proof of concept both to train myself
> in urwid and to test the capabilities and speed of the library.
> 
> Using 0.9.8.
> 
> ***test.py*** Lines 227-9. Class Panel, Method Display
> I have a Frame whose body is a Columns widget with 2 elements, both 
> identical.
> Each element contains a list of Text => "content".
> 
> If this Text List is wrapped inside a
> ListBox(SimpleListWalker(content), it 's rendered correctly.
> 
> But if I embed it inside a Pile(content) or Filler(Pile(content),
> height=h) it fails in Text.render method (widget.py:350).

Please try the attached patch.

Ian
Attachment (filler_trimming.diff): text/x-patch, 402 bytes
(Continue reading)

Iñigo Serna | 9 Apr 2007 15:37
Picon

run_wrapper doesn't accept arguments

Hi again,

"curses.wrapper" allows to pass arguments to the supplied function.
<code>
def wrapper(func, *args, **kwds):
  ...
  func(*args, **kwds)
  ...
</code>

Urwid doesn't accept args:
<code>
def run_wrapper(self, fn, alternate_buffer=True):
               try:
                       self.start(alternate_buffer)
                       return fn()
               finally:
                       self.stop()
</code>
That "alternate_buffer=True" eliminates the posibility to add "*args"

So I propose next solution:
<code>
def run_wrapper(fn, *args, **kwds):
  alternate_buffer = kwds.get('alternate_buffer', True)
  if 'alternate_buffer' in kwds.keys():
      del(kwds['alternate_buffer'])
  ...
  fn(*args, **kwds)
  ...
(Continue reading)

Ian Ward | 9 Apr 2007 15:53
Favicon
Gravatar

Re: run_wrapper doesn't accept arguments

Iñigo Serna wrote:
> Hi again,
> 
> "curses.wrapper" allows to pass arguments to the supplied function.
> <code>
> def wrapper(func, *args, **kwds):
>  ...
>  func(*args, **kwds)
>  ...
> </code>
> 
> Urwid doesn't accept args:
> <code>
> def run_wrapper(self, fn, alternate_buffer=True):
>               try:
>                       self.start(alternate_buffer)
>                       return fn()
>               finally:
>                       self.stop()
> </code>
> That "alternate_buffer=True" eliminates the posibility to add "*args"

Screen.start() and Screen.stop() are now official parts of the API.  If 
you need to pass arguments to your function I suggest calling those 
methods yourself.  I am planning to add at least one more parameter to 
the start() method, and I don't like the idea of mixing user parameters 
and Urwid parameters at the same level.

If you really want to be able to use the run_wrapper() method and pass 
in parameters, I could add the user parameters like this:
(Continue reading)

zeth | 11 Apr 2007 21:08

edit.py example and linebreaks

Hello everyone,

Quick disclaimer, I am completely new to the curses world. Python graphical 
toolkits have lots of friendly widgets etc, in GTK for example, you say give me 
a textbuffer widget and you have got one. So curses seems a bit low level,  I 
feel like I have moved from cooking to butchery, interesting for sure, but hard 
and messy work. So I was quite happy to find about Urwid. So excuse me if I 
sound completely ignorant, it is because I am ;-)

Okay, enough rambling and on to the question, I have been playing with edit.py 
example, (and very nice it is too). However, when you have made some text with 
line breaks, the cursor will not pass through a line break onto the next line. 
How would I extend the example to fix that?  

Best Wishes,
Zeth

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Ian Ward | 11 Apr 2007 23:49
Favicon
Gravatar

Re: edit.py example and linebreaks

zeth <at> zeth.net wrote:
> Okay, enough rambling and on to the question, I have been playing with edit.py 
> example, (and very nice it is too). However, when you have made some text with 
> line breaks, the cursor will not pass through a line break onto the next line. 
> How would I extend the example to fix that?  

Try the attached patch.

Ian
_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
zeth | 12 Apr 2007 00:32

Re: edit.py example and linebreaks

On Wed, Apr 11, 2007 at 05:49:28PM -0400, Ian Ward wrote:
> Try the attached patch.

Works great, thanks mate!
_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Iñigo Serna | 13 Apr 2007 23:05
Picon

ui.stop & ui.start don't work as expected

Hi again,

within the features I'm testing I need to exit temporary from the
urwid application to open a shell and come back after.
With curses module, this is done using "curses.endwin();
os.system('sh'); myapp_show_screen_()".
In urwid I'm trying with ui.stop & ui.start (before and after the
"os.system('bash')" call).

Problems found:
- after entering shell cursor is not shown
- after coming back to urwid app, besides a myapp_display() explicit
call, nothing is shown in screen, this only happens after an event
(f.e. key press), and then the colors (or header and footer of the
fram in my sample app) are not shown

Look at the attached file for a case example.

Environment; raw_display, urwid v0.9.8, python 2.4.5, fc6

Thanks,
Iñigo

--

-- 
Iñigo Serna
Katxijasotzaileak
Attachment (view.py): text/x-python, 4417 bytes
_______________________________________________
(Continue reading)

Ian Ward | 13 Apr 2007 23:36
Favicon
Gravatar

Re: ui.stop & ui.start don't work as expected

Iñigo Serna wrote:
> Problems found:
> - after entering shell cursor is not shown
> - after coming back to urwid app, besides a myapp_display() explicit
> call, nothing is shown in screen, this only happens after an event
> (f.e. key press), and then the colors (or header and footer of the
> fram in my sample app) are not shown

The attached patch seems to fix these problems for me.

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

Gmane