[Urwid][Fwd: Find focused Edit]

cantabile cantabile.03 at wanadoo.fr
Sat Jul 30 11:13:50 EDT 2005

Ian Ward a écrit :

> Ian Ward wrote:
> Let me know if my message is difficult to understand.. I can post some 
> code if you like.
> Ian
Hi again,
Well, I followed the second method :

class It(urwid.Padding):
     def __init__(self, titre, valeur):
       self.widget = urwid.Edit(('editcp', titre + " : "), valeur)
                              , ('fixed left',3), ('fixed right',1), 
   def get(self):
       return self

   def getval(self):
       return self.widget.get_edit_text()

   # code cut ...

Then, in my run loop, I'm drilling down like this :

                       w, pos = self.listbox.get_focus()
                       while hasattr(w, 'get_focus'):
                           w = w.get_focus()
                           if w.__class__.__name__ == 'It':

And I get the help of the former It widget, I mean the one I just left, 
not the current one...
For example, with two piled Edits named 'hostname' and 'IP', I get the 
hostname help when in IP and IP help when back to hostname.
To get the good one, I have to play with the keyboard inside the Edit 
(like right, or left keys). How come ? Can I create the keyboard input 
myself, in the program, so that the correct get_focus() event will be  
triggered ?

Sorry to bother you with that :(


More information about the Urwid mailing list