Onur Küçük | 1 Jul 19:24 2010
Picon

gpm_mev still gives trouble


 Hello,

 On a system where gpm_mev is installed but gpm is not running, I am
still getting exception on startup of any example where TERM=linux
(raw console for example) with version 0.9.9.1.

 Attached patch fixes the problem for me.

Traceback (most recent call last):
  File "calc.py", line 819, in <module>
    main()
  File "calc.py", line 816, in main
    CalcDisplay().main()
  File "calc.py", line 578, in main
    self.loop.run()
  File "/usr/lib/python2.6/site-packages/urwid/main_loop.py", line 170,
in run self.screen.run_wrapper(self._run)
  File "/usr/lib/python2.6/site-packages/urwid/raw_display.py", line
234, in run_wrapper return fn()
  File "/usr/lib/python2.6/site-packages/urwid/main_loop.py", line 188,
in _run self.event_loop.run()
  File "/usr/lib/python2.6/site-packages/urwid/main_loop.py", line 498,
in run self._loop()
  File "/usr/lib/python2.6/site-packages/urwid/main_loop.py", line 515,
in _loop ready, w, err = select.select(fds, [], fds)
select.error: (9, 'Bad file descriptor')

 regards,
--

-- 
(Continue reading)

Ian Ward | 2 Jul 02:32 2010

Re: gpm_mev still gives trouble

Onur Küçük wrote on 2010-07-01 13:24:
> 
>  Hello,
> 
>  On a system where gpm_mev is installed but gpm is not running, I am
> still getting exception on startup of any example where TERM=linux
> (raw console for example) with version 0.9.9.1.
> 
>  Attached patch fixes the problem for me.

Yes, that was reported earlier.  It's an old bug that returned in a new
way with python 2.6.

Your patch looks good Onur, thank you!  I will include it in 0.9.9.2.

Ian

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Onur Küçük | 2 Jul 08:41 2010
Picon

Re: gpm_mev still gives trouble

On 02 Temmuz 2010 Cuma 03:32:52 Ian Ward wrote:
> Onur Küçük wrote on 2010-07-01 13:24:
> >  Hello,
> >  
> >  On a system where gpm_mev is installed but gpm is not running, I am
> > 
> > still getting exception on startup of any example where TERM=linux
> > (raw console for example) with version 0.9.9.1.
> > 
> >  Attached patch fixes the problem for me.
> 
> Yes, that was reported earlier.  It's an old bug that returned in a new
> way with python 2.6.
> 
> Your patch looks good Onur, thank you!  I will include it in 0.9.9.2.

 nice, thank you :)

--

-- 
 Onur Küçük                                      Knowledge speaks,
 <onur.--.-.pardus.org.tr>                       but wisdom listens

_______________________________________________
Urwid mailing list
Urwid <at> lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
Jacob | 2 Jul 22:58 2010

Pile failing to render all items after widget_list.append()

Hi,

I've come across an odd problem while subclassing Pile.
The widget list [which is the MonitoredList created by Pile::__init__] holds the 
correct content when appended to, but nothing new is rendered.

In the example below, I would expect all three Text widgets to be displayed, but 
only the 'Me first!' widget appears.

Looking through Pile::render and doing a bit of debugging, it appears that the 
problem is on line 819 of container.py in the Pile class:
"for (f, height), w in  zip(self.item_types, self.widget_list):"
item_types is only one, and zip truncates the results to one tuple.

I had assumed that appending to the MonitoredList widget_list would 
automatically take care of these sorts of things.
My question is, what is the best way to get around this?

Thanks a ton!

[For reference, this is with Urwid 0.9.9.1 and Python 2.5.2.]
#!/usr/bin/python
import urwid
from sys import argv, exit

class MyPile(urwid.Pile):
    def __init__(self, widget_list):
        super(MyPile, self).__init__((urwid.Text('Me first!'),))
        for w in widget_list:
            self.widget_list.append(w)
(Continue reading)

Ian Ward | 3 Jul 01:54 2010

Re: Pile failing to render all items after widget_list.append()

Jacob wrote on 2010-07-02 16:58:
> Hi,
> 
> I've come across an odd problem while subclassing Pile.
> The widget list [which is the MonitoredList created by Pile::__init__] holds the 
> correct content when appended to, but nothing new is rendered.
> 
> In the example below, I would expect all three Text widgets to be displayed, but 
> only the 'Me first!' widget appears.
> 
> Looking through Pile::render and doing a bit of debugging, it appears that the 
> problem is on line 819 of container.py in the Pile class:
> "for (f, height), w in  zip(self.item_types, self.widget_list):"
> item_types is only one, and zip truncates the results to one tuple.
> 
> I had assumed that appending to the MonitoredList widget_list would 
> automatically take care of these sorts of things.
> My question is, what is the best way to get around this?

A workaround for now is to insert (or append) similarly to item_types,
but I agree, that's not how it should be.  MonitoredList is invalidating
the widget when you change the list so it may be redrawn, but a fancier
MonitoredList that can keep the item_list in sync would be better.  Once
that is done there's still a problem of choosing a default item_type for
new items that appear in the list.

At one point someone on the list or in IRC suggested adding another
widget decoration that would communicate to the Pile/ListBox how the
contained widget should be displayed.  That might be a good solution for
adding new items.
(Continue reading)

Sitti Amarittapark | 7 Jul 19:44 2010

ListBoxError - focus_canvas.rows() != focus_rows

Hi all,

I got the following exception in urwid. I found that I can avoid the
problem by resizing the ssh window. However I don't have that option
when running the code in the 80 columns x 24 lines console. Is there
anything I can do to avoid the problem? Did I do anything wrong? I am
using v 0.9.9.1.

Thanks very much,
-Sitti

Traceback (most recent call last):
  File "./console.py", line 235, in <module>
    main()
  File "./console.py", line 230, in main
    gSystem.run('welcome')
  File "/d2/sm/console/pic/manage.py", line 92, in run
    self.runOne(viewId, param)
  File "/d2/sm/console/pic/manage.py", line 126, in runOne
    self.replaceView(pop, viewId, param)
  File "/d2/sm/console/pic/manage.py", line 159, in replaceView
    self.loopController.run()
  File "/d2/sm/console/pic/draw.py", line 311, in run
    self.loop.run()
  File "/usr/lib/python2.5/site-packages/urwid/main_loop.py", line 170, in run
    self.screen.run_wrapper(self._run)
  File "/usr/lib/python2.5/site-packages/urwid/raw_display.py", line
234, in run_wrapper
    return fn()
  File "/usr/lib/python2.5/site-packages/urwid/main_loop.py", line 188, in _run
(Continue reading)

Sitti Amarittapark | 8 Jul 01:54 2010

Re: ListBoxError - focus_canvas.rows() != focus_rows

I think that found the answer.

It is in decoration.py. Padding.rows() causes this exception. Looks
like the calculation doesn't include the padding margin. I made the
following change and it works. I am not sure if this enough as a
general fix. It doesn't do anything with the CLIP case yet.

thanks,
Sitti
------------------- Detail --------------------------
class Padding

OLD:
    def rows(self, size, focus=False):
        """Return the rows needed for self.original_widget."""
        if self._width_type == PACK:
            pcols, prows = self._original_widget.pack(size, focus)
            return prows
        if self._width_type == CLIP:
            fcols, frows = self._original_widget.pack((), focus)
            return frows
        (maxcol,) = size
        left, right = self.padding_values(size, focus)
        return self._original_widget.rows((maxcol-left-right,), focus=focus)

NEW:
    def rows(self, size, focus=False):
        """Return the rows needed for self.original_widget."""
        (maxcol,) = size
        left, right = self.padding_values(size, focus)
(Continue reading)

Ian Ward | 8 Jul 02:27 2010

Re: ListBoxError - focus_canvas.rows() != focus_rows

Sitti Amarittapark wrote on 2010-07-07 13:44:
> Hi all,
> 
> I got the following exception in urwid. I found that I can avoid the
> problem by resizing the ssh window. However I don't have that option
> when running the code in the 80 columns x 24 lines console. Is there
> anything I can do to avoid the problem? Did I do anything wrong? I am
> using v 0.9.9.1.

Certainly a bug.  I believe it's related to the new default value for
width in the padding constructor.  The 'pack' code is not fully
completed, and it shouldn't have been made the default.  A work-around
would be:

Padding(w, width=('relative', 100), left=1, right=1)

Ian
Ian Ward | 8 Jul 02:32 2010

Re: ListBoxError - focus_canvas.rows() != focus_rows

Sitti Amarittapark wrote on 2010-07-07 19:54:
> I think that found the answer.
> 
> It is in decoration.py. Padding.rows() causes this exception. Looks
> like the calculation doesn't include the padding margin. I made the
> following change and it works. I am not sure if this enough as a
> general fix. It doesn't do anything with the CLIP case yet.

Your fix looks good.  I will apply it (though next time a diff -u or
hg/git diff would be preferred)

CLIP should be fine.  That case is only for fixed widgets whose size
can't be affected.

Thanks!

Ian
Muhammad Ammar | 12 Jul 15:52 2010
Picon

Fixed Size LineBox

Hi All,


I am new to urwid and getting problems to draw a fixed size linebox around a widget. Currently, when i draw a linebox around a listbox, the linebox is shown like following figure-1:


but, what i need linebox like the following figure-2



following is the source code

#!/usr/bin/env python

import urwid


#create palette
palette = [('header', 'black', 'light gray'),
           ('bg', 'black', 'light gray')]


#create header(title message)
txt_title = urwid.Text("\n\nSimple Database\n\n", 'center')               #is there any other way to place empty lines below and above the text instead of this
head = urwid.AttrMap(txt_title, 'header')

#create body
txt_open = urwid.Text("Add Record ", 'center')
txt_save = urwid.Text("Search Record", 'center')
txt_exit = urwid.Text("Exit", 'center')


menuList = urwid.SimpleListWalker([
                                  txt_open
                                  urwid.Divider(" "),
                                  txt_save,
                                  urwid.Divider(" "),
                                  txt_exit
                                ])

body = urwid.LineBox(urwid.ListBox(menuList))

#create frame
top = urwid.Frame(body, head)
top = urwid.AttrMap(top, 'bg')

def exit_on_cr(input):
    if input == 'enter':
        raise urwid.ExitMainLoop()
   
loop = urwid.MainLoop(top, palette, unhandled_input=exit_on_cr)
loop.run()


Can anyone help me to draw the linebox as in figure-2?

second, i want to add multiple flow widgets in the footer area of Frame, IS THIS POSSIBLE? if yes/no, can any one kindly guide me to right direction?

Regards,

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

Gmane