Pedro Jorge Caridade | 2 Aug 16:59 2007
Picon

Re: beginner help

Hi again
My learning with examples is increasing. I have a small question: If I 
have a listbox:
l = [bt, urwid.Divider(), col]
w = urwid.ListBox( l )
(from bigtext.py example) and I want to have the default focus on the 
element "col" how can I do it? In other others, in the bigtext example, 
the focus is on the edit box, but I want on the first line of the fonts 
radio buttons.
Thanks
Pedro

Pedro Jorge Caridade wrote:
> Thanks Ian
>
> Since I'm also very busy I need it kick I have done it hard way: disable 
> the left and right keys. I will improve it in the future, hopefully.
>
> I could not find any reference to blink in the reference manual. However 
> I found some patch from Derek Peschel. Have someone tried in a Linux 
> console? Is it safe to patch it to 0.9.7.2 version?
>
> Pedro
>   
Ian Ward | 4 Aug 05:31 2007

Re: beginner help

Pedro Jorge Caridade wrote:
> Hi again
> My learning with examples is increasing. I have a small question: If I 
> have a listbox:
> l = [bt, urwid.Divider(), col]
> w = urwid.ListBox( l )
> (from bigtext.py example) and I want to have the default focus on the 
> element "col" how can I do it? In other others, in the bigtext example, 
> the focus is on the edit box, but I want on the first line of the fonts 
> radio buttons.

Hi Pedro,

Did you try w.set_focus()?

Ian
Michal Vyskocil | 7 Aug 10:02 2007
Picon

LineBox with title

Hi,

I'd like to have a LineBox with text title, like this

----- urwid 0.9.8.1 -------

Hovever I'm not very familiar with this library (I've founded it yesterday 
morning :) and I cannot find anything helpfull in documentation to resolve my 
issue. So I've modified the LineBox class to produce (an optional) title in 
line box.

New __init__ is

__init__(w, title=None, align='center')

And usage

LineBox(widget, Text(urf8decode('urwid 0.9.8.1')), align='center')

But in traditional GUI there's also radio button lists with frame, which has a 
title in left align ...

then LineBox(widget, Text(urf8decode('urwid 0.9.8.1')), align='align') will 
produce

- urwid 0.9.8.1 ------------

I hope, that this path will be useful

BTW: A file line_test.py is modified Conversation object from urwid tutorial, 
(Continue reading)

Pedro Jorge Caridade | 8 Aug 20:50 2007
Picon

suggestion and guidelines

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.

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?

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?

Sorry for the long email, thanks any suggestion
(Continue reading)

Ian Ward | 9 Aug 14:31 2007

Re: suggestion and guidelines

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
(Continue reading)

Pedro Jorge Caridade | 13 Aug 20:47 2007
Picon

Re: suggestion and guidelines

Hello Ian
Thank's for your reply.
> 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.
>   
I solved this! It was a stupid error, I was trying to make a list of a 
list!!!!
> 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
>   
It work perfectly [if you did not know ;)]

The third point I also understood. But now I really need some help. As 
you can see from my attached code (sorry if it not clean, but I am 
really new on this python stuff), I create a class CUPSconsole where I 
created two empty (actually with one empty element) listboxes. I was 
expecting (again sorry if i going to say something really stupid) that 
when I call "update_readings()" function the listbox contents should be 
updated. But nothing happens. What am I doing wrong? What have I missed?

Thanks for all the trouble Ian, and for such nice package.
Pedro
(Continue reading)

Rebecca Breu | 13 Aug 22:10 2007
Picon

Re: suggestion and guidelines

Quoting Pedro Jorge Caridade <caridade <at> qta.qui.uc.pt>:

> created two empty (actually with one empty element) listboxes. I was
> expecting (again sorry if i going to say something really stupid) that
> when I call "update_readings()" function the listbox contents should be
> updated. But nothing happens. What am I doing wrong? What have I missed?

Line 94 (in update_readings) should be

self.queue_widget.w = urwid.AttrWrap(urwid.ListBox(#

instead of

self.queue_widget.body =

Just a note on your code: You are using spaces *and* tabs for indentation.
You should never mix spaces and tabs for indentation, that could lead to
misterious indentation errors. The python styleguide suggests using 4 spaces.

Yours,
Rebecca
Le Roux Bodenstein | 14 Aug 21:26 2007
Picon

ctrl keys

Hello

I'm new to urwid. I started writing a little bit of test code to try
out some things I want to use in my app and I noticed that some
control keys don't work.

Now.. I know these things have special meanings in terminal apps, but
I'm sure there must be a way to override them. Most importantly, I
would like to make ctrl-q, ctrl-s and ctrl-c do things. I've used some
other python+curses apps that handle some of these like ctrl-s for
save and ctrl-q to quit, so there has to be a way. Looks like ctrl-q
is supposed to send through the code '17'.

Any ideas? I can't find any obvious setting that needs to be changed
and I looked through some other apps' code and I can't find something
they do that urwid doesn't do.

I tried both raw_display and curses_display (after I had to comment
some things to make it run) from svn.

Le Roux

Btw, I'm running my tests in gnome-terminal under ubuntu feisty.
Le Roux Bodenstein | 14 Aug 22:33 2007
Picon

Re: ctrl keys

Nevermind. I discovered tty_signal_keys in urwid.raw_display.RealTerminal:

ui.tty_signal_keys('undefined', 'undefined', 'undefined', 'undefined',
'undefined') does the trick.

Le Roux
Pedro Jorge Caridade | 23 Aug 15:14 2007
Picon

focus on Pile

Hello
After struggling with listbox, piles, errors, and with the help of 
Rebecca and Ian finally I start to understand a little part of URWID. In 
my previous python example I only had two columns with two ListBox and 
one of them was not-selectable. To get the focus I used simply 
self.queue_widget.get_focus()[1], returning the integer inside the 
self.queue_widget listbox which has the focus. Now, I introduce an extra 
ListBox "self.printing_widget" and piled them:

        self.queue_widget = urwid.AttrWrap(urwid.BoxAdapter(urwid.ListBox(#

[urwid.AttrWrap(SelText(""), None, 'edit')]), 10),'chars')
        self.finish_widget = 
urwid.AttrWrap(urwid.BoxAdapter(UnselectableListBox(#

[urwid.AttrWrap(NotSelText(""), None, 'edit')]), 10), 'chars')
        self.printing_widget = 
urwid.AttrWrap(urwid.BoxAdapter(urwid.ListBox(#

[urwid.AttrWrap(SelText(""), None, 'edit')]), 1),'chars')
        self.QueuePile = urwid.Pile([urwid.Text("On queue", 'center'),
                                                       urwid.Text("  
ID#        User", 'left'),
                                                       self.queue_widget,

urwid.AttrWrap(urwid.Divider(top=1), 'body'),

urwid.Text("Printing", 'center'),

self.printing_widget], focus_item=2)
(Continue reading)


Gmane