Pedro Jorge Caridade wrote:
> Hello again
> I'm trying to make some application that control my printer queue using 
> cups. The layout is extremely simple, a header, a footer and the main 
> window with two columns, A and B, (with 10 rows) centered vertically on 
> the screen. For the two columns, one should be selectable and the other 
> not, while the focus should always be on the selectable one. My attempts 
> and fails until now where:
> 
> 1. Create two listboxes, one with selectable text widget (OK), and the 
> other with simple text (OK). With these two, put them in a column 
> environemnt (OK). Now, fix the size of the listboxes to 10 rows 
> (failed!). First question, how can I fix the size of a ListBox? I tried 
> with BoxAdapter, but since it doesn't have rows specified, doesn't work 
> (of course). The vertical centering is made with Filler, but the problem 
> of the rows is happens again.

Would you send the part of your code that is not working?  If you use
Filler(my_widget, 'middle', 10) then my_widget should be only 10 rows
high and the rest of the space will be blank.  If you want to use that
extra space for something then the ListBox needs to behave like a flow
widget, so you could use BoxAdapter(my_widget, 10) instead.

> 2. The focus.  Ian told me how should I choose the focus of the column, 
> but if I use my keyboard arrows left and right i loose the focus. How 
> can I force to have the focus (highlight) only on column A always?

The problem here is that ListBox objects are always selectable, since
you might want to scroll through unselectable content.  If you don't
mind not being able to scroll that one ListBox you can make it
unselectable by subclassing ListBox:

class UnselectableListBox(urwid.ListBox):
        _selectable = False

> 3. Out of the scope, but maybe someone have a suggestion. Besides the 
> keyboard interaction, which will tell the printer to start the job of 
> kill it, my application is always checking for new incoming requests 
> (OK). When it arrives, it should actualize the listbox of column A. So 
> far I made some loop which contains, also the keyboard get_input, made a 
> break on the main loop if such an event occurs, and render it again. I 
> know that this is not correct, but I'm just starting with Python and 
> urwid. Does anybody have a better suggestion?

I don't see a problem with what you just described.  If you post a part
of your code maybe someone can offer a suggestion?

I'm not sure if this is related, but if you are using raw_display you
can call screen.get_input_descriptors() to get a list of file
descriptors that Urwid expects input on.  This lets you make your own
event loop that can listen for other things with a select() loop and
screen.get_input_nonblocking().

Ian


_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to