Ian Ward | 1 Apr 17:09 2011

Re: Dynamic widget creating

Florian Kanngiesser wrote on 2011-03-31 08:05:
> Hi,
> I'm trying to write an application which creats widgets based on a 
> config file on the fly. The basic idea was to put a button into a 
> listbox and change the content of the listbox in an on click event (like 
> expanding a part of the application to display "hidden" objects), my 
> problem right now is that I dont know how to bind a button to a callback 
> function (I simply cant find anything understandable in the recourses) 
> and then adding the new content to the listbox and redrawing it.
> Right now I'm able to create the Listbox with the widgets I want, I just 
> dont know how to do it on a button click event, or better to say I dont 
> know how I can change a widget (the listbox) at runtime.
> 
> Can somebody help me with this problem?
> Many thanks in advance.

Hi Florian,

I believe your question was answered in IRC.  For the benefit of those
not on:

>> that should be covered in the Button reference and in at least a
>> couple examples like tour.py, graph.py ..

Ian
W. Cole Davis | 5 Apr 23:24 2011

How to use raw_display.Screen from within rerouted pipe

Hi all, been playing with urwid for a few days and from what I see it 
will really suit my needs for a terminal interface to a prototype 
project I'm working on. We are writing an application using mpi4py to 
distribute some significant calculations to a cluster. The only node 
displaying the interface is the head-node and this is already setup and 
working. The problem is that when executing under mpi it seems to use a 
non-default descriptor as it reroutes piped communications to a separate 
buffer on the head-node (from all children too) and this screws up 
urwid. I've been over and over the reference and examples I could find 
but none seem to show anyone dealing with this type of issue.

I looked at the source for the raw_display class and it assumes the fd 
is '0' for default sys.stdin I'm guessing? Is there a way that I can 
specify the terminal/buffer using core urwid functionality? It seemed 
like, since when using MainLoop you can set a specific "Screen" object 
but I cannot figure out how to create a custom one.

Any help would be much appreciated. The actual (and vague) error I'm 
seeing is:

File
"/usr/lib64/python2.4/site-packages/urwid-0.9.9.1-py2.4-linux-x86_64.egg/urwid/main_loop.py",
line 170, in run

     self.screen.run_wrapper(self._run)

   File
"/usr/lib64/python2.4/site-packages/urwid-0.9.9.1-py2.4-linux-x86_64.egg/urwid/raw_display.py",
line 233, in run_wrapper

(Continue reading)

Ian Ward | 6 Apr 15:24 2011

Re: How to use raw_display.Screen from within rerouted pipe

W. Cole Davis wrote on 2011-04-05 17:24:
> Hi all, been playing with urwid for a few days and from what I see it 
> will really suit my needs for a terminal interface to a prototype 
> project I'm working on. We are writing an application using mpi4py to 
> distribute some significant calculations to a cluster. The only node 
> displaying the interface is the head-node and this is already setup and 
> working. The problem is that when executing under mpi it seems to use a 
> non-default descriptor as it reroutes piped communications to a separate 
> buffer on the head-node (from all children too) and this screws up 
> urwid. I've been over and over the reference and examples I could find 
> but none seem to show anyone dealing with this type of issue.
> 
> I looked at the source for the raw_display class and it assumes the fd 
> is '0' for default sys.stdin I'm guessing? Is there a way that I can 
> specify the terminal/buffer using core urwid functionality? It seemed 
> like, since when using MainLoop you can set a specific "Screen" object 
> but I cannot figure out how to create a custom one.
> 
> Any help would be much appreciated. The actual (and vague) error I'm 
> seeing is:
> 
> File
"/usr/lib64/python2.4/site-packages/urwid-0.9.9.1-py2.4-linux-x86_64.egg/urwid/main_loop.py",
line 170, in run
> 
>      self.screen.run_wrapper(self._run)
> 
>    File
"/usr/lib64/python2.4/site-packages/urwid-0.9.9.1-py2.4-linux-x86_64.egg/urwid/raw_display.py",
line 233, in run_wrapper
(Continue reading)

W. Cole Davis | 8 Apr 21:52 2011

Re: Urwid Digest, Vol 67, Issue 2

On 4/6/11 12:00 PM, urwid-request <at> lists.excess.org wrote:
> Send Urwid mailing list submissions to
> 	urwid <at> lists.excess.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.excess.org/mailman/listinfo/urwid
> or, via email, send a message with subject or body 'help' to
> 	urwid-request <at> lists.excess.org
>
> You can reach the person managing the list at
> 	urwid-owner <at> lists.excess.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Urwid digest..."
>
>
> Today's Topics:
>
>     1. How to use raw_display.Screen from within rerouted pipe
>        (W. Cole Davis)
>     2. Re: How to use raw_display.Screen from within rerouted pipe
>        (Ian Ward)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 5 Apr 2011 17:24:22 -0400
> From: "W. Cole Davis"<wdavis <at> cs.odu.edu>
> Subject: [Urwid] How to use raw_display.Screen from within rerouted
(Continue reading)

Mag Gam | 9 Apr 02:15 2011
Picon

example to show some data

Hello,

Newbie to urwid

I am trying to display 2 text files ( /proc/meminfo and /proc/vmstat)
side by side.  I would like to update the screen every 2 seconds to
get this accomplished. What is the best way to do this?

A code example would be extremely helpful.
Ian Ward | 9 Apr 03:04 2011

Re: Urwid Digest, Vol 67, Issue 2

W. Cole Davis wrote on 2011-04-08 15:52:
> I apologize for the delayed response to your quick one. Unfortunately 
> the change to sys.stdin.fileno() does not change the problem because it 
> returns the same value. I think there might be a flaw in my approach to 
> attempting to use urwid here in a non-conventional way so let me explain 
> further.
> 
> I have a Python project that is originally executed by mpi using the 
> SPMD model. So the application is run on multiple processes across 
> multiple nodes. The application determines what type of node it is on 
> and executes the application path appropriate for its type. In fact the 
> only node that acts differently from the rest is on the head-node. The 
> head-node is the only node to import and execute urwid, but mpi routes 
> all of the application output (stdout, stdin, stderr...) back to the 
> head-node (which is great) but it also pipes the head-nodes output to a 
> separate output buffer. I believe this is what causes the problem. Is 
> there was a way for me to interface with the raw_display.Screen object 
> to create one with the correct fd (which I would determine) prior to it 
> running its own start? Seems improbable considering its built into its 
> constructor.

You should be able to make a raw_display.Screen subclass that sets
changes the values of self._term_output_file and self._term_input_file.
 Or you could set sys.stdin and sys.stdout to different files before
initializing the screen.

The tcgetattr/tcsetattr calls in start and stop should be fixed to use
the fd from self._term_input_file instead of the present hard-coded
value of 0 as well.  (I'll accept a patch)

(Continue reading)

ft2010 | 9 Apr 18:53 2011
Picon

Is there a way to get widget size

Hi, I'm new to Urwid (and Python too). I started a python-urwid program to 
essentially display items in two listBox objects as the body in an 
urwid.Frame (the layout is similar to most of IDEs). To have more control in 
listboxes I created a control to display a multicolumn listbox with an 
optional column's header (and in the future with optional horizontal and 
vertical scrollbars).

The new listbox is a urwid.Filler that wrap a simple urwid.ListBox with 
urwid.SimpleListWalker with items implemented as urwid.Text widgets, so the 
listbox is really a simple urwid listbox. If the option 'header_visible' is 
true the widget will be a urwid.Filler that wrap a urwid.Pile with an 
urwid.Text for listbox header in the first row and the previos widgets on 
the second row.

Now, to calculate column widths (configurable) I need to know the width of 
the whole implemented widget (Filler) or at least the width of the contained 
ListBox. This will help in calculating the horizontal scrollbar (if I will 
implement it). For the vertical scrollbar I will need the height of the 
Filler.

thanks
Ian Ward | 10 Apr 02:37 2011

Re: Is there a way to get widget size

Hello!

ft2010 wrote on 2011-04-09 12:53:
> Hi, I'm new to Urwid (and Python too). I started a python-urwid program to 
> essentially display items in two listBox objects as the body in an 
> urwid.Frame (the layout is similar to most of IDEs). To have more control in 
> listboxes I created a control to display a multicolumn listbox with an 
> optional column's header (and in the future with optional horizontal and 
> vertical scrollbars).
> 
> The new listbox is a urwid.Filler that wrap a simple urwid.ListBox with 
> urwid.SimpleListWalker with items implemented as urwid.Text widgets, so the 
> listbox is really a simple urwid listbox. If the option 'header_visible' is 
> true the widget will be a urwid.Filler that wrap a urwid.Pile with an 
> urwid.Text for listbox header in the first row and the previos widgets on 
> the second row.
> 
> Now, to calculate column widths (configurable) I need to know the width of 
> the whole implemented widget (Filler) or at least the width of the contained 
> ListBox. This will help in calculating the horizontal scrollbar (if I will 
> implement it). For the vertical scrollbar I will need the height of the 
> Filler.

Have you read the "widgets in Urwid typically have no size" part of the
manual?

http://excess.org/urwid/wiki/WidgetMethods#WidgetMethods

You know the size of a widget only when it's being rendered or handling
a keyboard or mouse event.  Does that not work in your case?
(Continue reading)

ft2010 | 10 Apr 10:00 2011
Picon

Re: Is there a way to get widget size


"Ian Ward" <ian <at> excess.org> ha scritto nel messaggio 
news:4DA0FBCF.4000908 <at> excess.org...
> Hello!
>
> ft2010 wrote on 2011-04-09 12:53:
>> Hi, I'm new to Urwid (and Python too). I started a python-urwid program 
>> to
>> essentially display items in two listBox objects as the body in an
>> urwid.Frame (the layout is similar to most of IDEs). To have more control 
>> in
>> listboxes I created a control to display a multicolumn listbox with an
>> optional column's header (and in the future with optional horizontal and
>> vertical scrollbars).
>>
>> The new listbox is a urwid.Filler that wrap a simple urwid.ListBox with
>> urwid.SimpleListWalker with items implemented as urwid.Text widgets, so 
>> the
>> listbox is really a simple urwid listbox. If the option 'header_visible' 
>> is
>> true the widget will be a urwid.Filler that wrap a urwid.Pile with an
>> urwid.Text for listbox header in the first row and the previos widgets on
>> the second row.
>>
>> Now, to calculate column widths (configurable) I need to know the width 
>> of
>> the whole implemented widget (Filler) or at least the width of the 
>> contained
>> ListBox. This will help in calculating the horizontal scrollbar (if I 
>> will
(Continue reading)

Ian Ward | 10 Apr 20:54 2011

Re: Is there a way to get widget size

ft2010 wrote on 2011-04-10 04:00:
> 
> "Ian Ward" <ian <at> excess.org> ha scritto nel messaggio 
> news:4DA0FBCF.4000908 <at> excess.org...
>> You know the size of a widget only when it's being rendered or handling
>> a keyboard or mouse event.  Does that not work in your case?
>>
>> I've had a plan for an Urwid-way to implement scrollbars for a number of
>> years, but I haven't wanted scroll bars enough to actually implement
>> them yet.  You could have a look at what I was planning here:
>>
>> http://excess.org/urwid/wiki/MoreWidgets
>>
>> Ian
> 
> Probably my approach to this library is wrong, I have to understand the 
> internals to know if I can use it like other libraries (TVision in C++, to 
> mention one or a low level ncurses wrap). Urwid is good if used for web 
> browser like display, it has a very good unicode support and color 
> management.
> Perhaps there is a way to use it to develop an UI to manage widgets 
> (controls), like in a GUI, by re-implementing all high level widgets as box 
> widgets (they should have a method to ask their size), I will try this path, 
> if it works I will tell you my progress.

You might mean fixed widgets (widgets that know their own size).

You're free to implement all your own widgets in Urwid and ignore the
ones it comes with (then you get the nice Unicode, colour handling etc.)

(Continue reading)


Gmane