Ian Ward | 1 Jun 15:35 2006

The missing part of my last mail

Rebecca Breu wrote:
> Thanks very much for the explanation. (I think you
> should put that into the documentation!)

Yes. I should do that.  I've got a tutorial, reference and examples but 
a programmers' guide would be nice.  Doing the presentation on Urwid has 
forced me to organize alot of that information, so it shouldn't take me 
too long.

Ian

James Mills | 3 Jun 03:09 2006
Picon

urwid_simple.py problem

Hi,

The "urwid_simple.py" that was posted to this list a while
ago (see attached) I'm having problems with.

I know it's taken me a while :) (lack of time), however I
believe my terminal is translating keycodes for ALT or META
to something else. If I chuck a print keys I get:
['\xf0'] when I press ALT + F for instance, instead of
what urwid_simple is looking for "meta f" in keys.

Comments ?

cheers
James

--

-- 
--
-"Problems are Solved by Method"
-
- James Mills <prologic <at> shortcircuit.net.au>
- HomePage: http://shortcircuit.net.au/~prologic/
- Phone: +61732166379
- Mobile: +61404270962
- Skype: therealprologic
- MSN: prologic <at> shortcircuit.net.au
- ICQ: 98888663
- IRC: irc://shortcircuit.net.au#se

Please avoid sending me Word or PowerPoint attachments.
(Continue reading)

Ian Ward | 3 Jun 14:15 2006

urwid_simple.py problem

James Mills wrote:
> Hi,
> 
> The "urwid_simple.py" that was posted to this list a while
> ago (see attached) I'm having problems with.
> 
> I know it's taken me a while :) (lack of time), however I
> believe my terminal is translating keycodes for ALT or META
> to something else. If I chuck a print keys I get:
> ['\xf0'] when I press ALT + F for instance, instead of
> what urwid_simple is looking for "meta f" in keys.
> 
> Comments ?

Hmm. I should put this question in a FAQ.

If you're running xterm you can set "Meta Sends Escape" in the 
"CTRL+Left Click" menu. To set it permanently for your user add this 
line to your $HOME/.Xdefaults file:

XTerm*metaSendsEscape: true

Then run: "xrdb -l $HOME/.Xdefaults" to reload your xresources.

Or, see the attached message for a solution that will break input in all 
encodings that use > 7 bits, but will understand what your terminal is 
sending.

Ian
-------------- next part --------------
(Continue reading)

Rebecca Breu | 7 Jun 15:39 2006
Picon

urwid_simple.py problem

Zitat von Ian Ward <ian <at> excess.org>:

> Hmm. I should put this question in a FAQ.
>
> If you're running xterm you can set "Meta Sends Escape" in the
> "CTRL+Left Click" menu. To set it permanently for your user add this
> line to your $HOME/.Xdefaults file:
>
> XTerm*metaSendsEscape: true
>

I put your explanation in the source code of my example, along with a short
messge displayed at runtime. I also added the filter_8bit_meta(k) function so
that anyone can comment it out and use it if he so wishes.

Now have fun with the Alt key,

Rebecca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rbreu_menus.py
Type: text/x-python
Size: 11913 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20060607/f6fc488f/rbreu_menus.py

Ian Ward | 14 Jun 23:11 2006

urwid_simple.py problem

Rebecca Breu wrote:
> Zitat von Ian Ward <ian <at> excess.org>:
> 
>> Hmm. I should put this question in a FAQ.
>>
>> If you're running xterm you can set "Meta Sends Escape" in the
>> "CTRL+Left Click" menu. To set it permanently for your user add this
>> line to your $HOME/.Xdefaults file:
>>
>> XTerm*metaSendsEscape: true
>>
> 
> I put your explanation in the source code of my example, along with a short
> messge displayed at runtime. I also added the filter_8bit_meta(k) function so
> that anyone can comment it out and use it if he so wishes.
> 
> 
> Now have fun with the Alt key,
> 
> Rebecca
> 

I've updated the website with your latest version of rbreu_menus.py

Ian

Eric S. Johansson | 22 Jun 02:14 2006

multiple edit fields

I'm writing a ethernet manipulation utility for the IPCop project and 
I'm running into some problems.  Problem number one is selecting which 
ethernet card I am using.  I am using radio buttons because they kind of 
works as a user interface.  The only question is how do I detect which 
button is currently active?  I see it as a callback function and I can 
obviously use that to change the data structures holding the per network 
interface data.  My question would be which do I need to kick off 
another display update or will that happen automatically after I return 
from the callback?

the second problem is the right hand column.  Those are individual edit 
fields so I can change the IP address, network driver etc. but I'm not 
really sure how to retrieve the data so I can change the internal 
structures and save when the user hits the "not yet created" save button.

I had another problem with the list of edit boxes, when I hit page down 
key it went from the radio boxes to the last edit box.  I would have 
expected it to go to the first.

 
             ( ) Green     ( ) Orange    ( ) Blue      ( ) Red       (X) 
AltRed 

GREEN_ADDRESS                           172.20.0.10 
         GREEN_BROADCAST                         172.20.0.255 
                  GREEN_DEV                               ETH0 
                           GREEN_DISPLAYDRIVER 
NE2K-PCI                                GREEN_DRIVER 
         NE2K-PCI                                GREEN_DRIVER_OPTIONS 

(Continue reading)

Ian Ward | 22 Jun 11:55 2006

multiple edit fields

Eric S. Johansson wrote:
> I'm writing a ethernet manipulation utility for the IPCop project and 
> I'm running into some problems.  Problem number one is selecting which 
> ethernet card I am using.  I am using radio buttons because they kind of 
> works as a user interface.  The only question is how do I detect which 
> button is currently active?  I see it as a callback function and I can 
> obviously use that to change the data structures holding the per network 
> interface data.  My question would be which do I need to kick off 
> another display update or will that happen automatically after I return 
> from the callback?

I've intentionally left Urwid pretty simple with respect to updates.  If 
you want to change the contents of the screen just modify the widgets 
that you call render() on.  In your case you need to change the text in 
the edit widgets, or replace the edit widgets when the user selects a 
new radio button.

The tour example just creates a bunch of widgets and puts them in a 
ListBox.  What you need to do is create your Edit widgets first, keep a 
variable to reference them, then add them to the ListBox.  That way you 
can use your variables and set_edit_text() to change what they are 
displaying.

> the second problem is the right hand column.  Those are individual edit 
> fields so I can change the IP address, network driver etc. but I'm not 
> really sure how to retrieve the data so I can change the internal 
> structures and save when the user hits the "not yet created" save button.

If you have variables to reference each of the Edit widgets you can get 
the text that the user has entered with get_edit_text()
(Continue reading)

Eric S. Johansson | 22 Jun 14:07 2006

multiple edit fields

Ian Ward wrote:
> The tour example just creates a bunch of widgets and puts them in a 
> ListBox.  What you need to do is create your Edit widgets first, keep a 
> variable to reference them, then add them to the ListBox.  That way you 
> can use your variables and set_edit_text() to change what they are 
> displaying.

okay, displaying my cluelessness (i.e. a cut-and-paste monkey), you mean 
something like this?

def piled_data(color):
	color_dictionary = color_keys(color)
	color_list = color_dictionary.keys()
	color_list.sort()
	
	display_list =[]
	for list_element in color_list:
		data_element = color_dictionary[list_element]
		display_list.append(urwid.Padding(
			urwid.AttrWrap( urwid.Edit( data_element ), 'editbx', 'editfc'),
			('fixed left',2),
			('fixed right',0),
			20))
	print display_list
	return display_list

---------

from your description, it sounds like I should be inserting the results 
of urwid.Edit into a list so they would be available to retrieve the 
(Continue reading)

Ian Ward | 22 Jun 19:14 2006

multiple edit fields

Eric S. Johansson wrote:
> Ian Ward wrote:
>> The tour example just creates a bunch of widgets and puts them in a 
>> ListBox.  What you need to do is create your Edit widgets first, keep 
>> a variable to reference them, then add them to the ListBox.  That way 
>> you can use your variables and set_edit_text() to change what they are 
>> displaying.
> 
> okay, displaying my cluelessness (i.e. a cut-and-paste monkey), you mean 
> something like this?

A better example is section 2 "Conversation Example" in the tutorial. 
Look at how they keep a reference to the edit widget so they can operate 
on it later. 2.3 and 2.4 in the tutorial show how this is done with a 
ListBox.

> from your description, it sounds like I should be inserting the results 
> of urwid.Edit into a list so they would be available to retrieve the 
> change data from.  there's a bunch of things that I don't understand in 
> the code, I just know it works.  For example why is the AttrWrap 
> necessary?  If I skip that out, I'm told that urwid.Edit has no __call__ 
> method.

Really?  That shouldn't happen.  Can you post an example program that 
raises that exception when you remove an AttrWrap?

Ian

Rebecca Breu | 23 Jun 09:54 2006
Picon

Filler.mouse_event() --> TypeError

Hi!

I just started working with urwid's mouse support. I created this short
program:

-------------
#! /usr/bin/env python

import urwid.curses_display;
import urwid;

def run():
    ui.set_mouse_tracking();
    dim = ui.get_cols_rows();

    widget = urwid.Filler(urwid.Edit("Write something:"));

    keys = True;

    while True:
        if keys:
            ui.draw_screen(dim, widget.render(dim, True));

        keys = ui.get_input();

        if "window resize" in keys:
            dim = ui.get_cols_rows();
        for k in keys:
            if urwid.is_mouse_event(k):
                event, button, col, row = k
(Continue reading)


Gmane