Rupp, Lawrence E | 12 Apr 2012 23:52
Picon
Favicon

Problem with Text and Listbox Widgets

Hi,

I am a complete newbie to both Python and Urwid, and I have a question regarding widget behavior.

I am building a status gui composed of Text widgets in a Listbox, traversed by a SimpleListWalker.

The problem I'm having is that when I update one of the Text widgets with 'varname.set_text("example"),
the text string "example" appears in the appropriate Text widget, but it also appears to add a carriage
return, meaning the entire display below the updated Text widget shifts down one line.  How do I prevent
this from happening?  How can I simply overwrite what was in the Text widget in the first place without a new
line showing up?

BTW, I am using Urwid1.0.1 and Python 2.4.

Thanks,

Larry
Ian Ward | 13 Apr 2012 00:36
Favicon
Gravatar

Re: Problem with Text and Listbox Widgets

On Thu, Apr 12, 2012 at 5:52 PM, Rupp, Lawrence E
<lawrence.e.rupp <at> boeing.com> wrote:
> The problem I'm having is that when I update one of the Text widgets with 'varname.set_text("example"),
the text string "example" appears in the appropriate Text widget, but it also appears to add a carriage
return, meaning the entire display below the updated Text widget shifts down one line.  How do I prevent
this from happening?  How can I simply overwrite what was in the Text widget in the first place without a
new line showing up?

That shouldn't happen.  Can you post some code that demonstrates the
problem you're having?  Are you sure the text you're inserting doesn't
have a trailing newline?
Rupp, Lawrence E | 13 Apr 2012 00:43
Picon
Favicon

Re: Problem with Text and Listbox Widgets

Ian,

Darn, now that you mention it, it just might.  The text that I am inserting is coming from a 'print' statement
in a subprocess through a pipe.  It may well have a 'newline' automatically appended.  I didn't consider
that because some of the text that is passed is converted to integers in the main process, and the newline
problem doesn't appear with ints.

Is there some other way to pass data back through a pipe than with a print statement?  Maybe a function
'return' or something? 

Thanks for the quick response, Ian, and thanks for the 2nd point of view.  I'll check the return through the
pipe and let you know either way.

Larry

-----Original Message-----
From: urwid-bounces <at> lists.excess.org [mailto:urwid-bounces <at> lists.excess.org] On Behalf Of Ian Ward
Sent: Thursday, April 12, 2012 3:36 PM
To: Urwid General Discussion
Subject: Re: [Urwid] Problem with Text and Listbox Widgets

On Thu, Apr 12, 2012 at 5:52 PM, Rupp, Lawrence E <lawrence.e.rupp <at> boeing.com> wrote:
> The problem I'm having is that when I update one of the Text widgets with 'varname.set_text("example"),
the text string "example" appears in the appropriate Text widget, but it also appears to add a carriage
return, meaning the entire display below the updated Text widget shifts down one line.  How do I prevent
this from happening?  How can I simply overwrite what was in the Text widget in the first place without a
new line showing up?

That shouldn't happen.  Can you post some code that demonstrates the problem you're having?  Are you sure the
text you're inserting doesn't have a trailing newline?
(Continue reading)

Rupp, Lawrence E | 13 Apr 2012 00:50
Picon
Favicon

Re: Problem with Text and Listbox Widgets

 Ian,

It was a newline problem, just like you thought.  I searched the internet on how to strip off a newline, found
the 'rstrip()' function, applied it in my code, and VOILA!  No more line appending on my GUI.

Moochas Grass for pointing out the obvious!  May all your problems today be of a similar nature!

Larry

-----Original Message-----
From: urwid-bounces <at> lists.excess.org [mailto:urwid-bounces <at> lists.excess.org] On Behalf Of Ian Ward
Sent: Thursday, April 12, 2012 3:36 PM
To: Urwid General Discussion
Subject: Re: [Urwid] Problem with Text and Listbox Widgets

On Thu, Apr 12, 2012 at 5:52 PM, Rupp, Lawrence E <lawrence.e.rupp <at> boeing.com> wrote:
> The problem I'm having is that when I update one of the Text widgets with 'varname.set_text("example"),
the text string "example" appears in the appropriate Text widget, but it also appears to add a carriage
return, meaning the entire display below the updated Text widget shifts down one line.  How do I prevent
this from happening?  How can I simply overwrite what was in the Text widget in the first place without a
new line showing up?

That shouldn't happen.  Can you post some code that demonstrates the problem you're having?  Are you sure the
text you're inserting doesn't have a trailing newline?

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

Rupp, Lawrence E | 7 May 2012 11:46
Picon
Favicon

Re: Problem with Text and Listbox Widgets

I have a Text widget that I am updating with 'set_text' and when the update occurs, the text is inserted but is
padded on the right to the column limit with question marks.  

Any idea what is causing this?  I don't know what information to provide that will help you narrow it down, so
let me know what you need.

I am using Python 2.4.

Thanks,

larry

Lawrence Rupp
P8 Trainer Software
(253) 657-9661
lawrence.e.rupp <at> boeing.com
Ian Ward | 7 May 2012 14:41
Favicon
Gravatar

Re: Problem with Text and Listbox Widgets


On May 7, 2012 5:47 AM, "Rupp, Lawrence E" <lawrence.e.rupp <at> boeing.com> wrote:
>
> I have a Text widget that I am updating with 'set_text' and when the update occurs, the text is inserted but is padded on the right to the column limit with question marks.
>
> Any idea what is causing this?  I don't know what information to provide that will help you narrow it down, so let me know what you need.
>

A minimal example that reproduces the problem would be perfect :-)

IIRC the only thing in urwid that adds question marks is a filter on control characters being sent to the screen.  Is there a chance there are some control characters in the text you're passing?

> I am using Python 2.4.
>

Ian

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

Gmane