mammar wrote on 2011-07-15 03:53: > Hi All, > > > I have an urwid application developed with different views. Main view > have a user menu which shows choices a user can choose from, all the > menu choices are bind with some key. Upon a valid keypress it will start > the action bind with that key. > > The problem is that, keys are working with main view but when the view > changes no key work. > > #mainloop call > self.loop = urwid.MainLoop(self.main_view, palette, > unhandled_input=self.OnKey) > > #this is how i change view > self.loop.widget = self.run_view > self.loop.draw_screen() > > How to handle the keypresses when view changes?
Once you change loop.widget all the keypresses will be sent to run_view instead of main_view. Some solutions: 1. handle the view-changing keys in all the different views that may be active 2. make a top level widget that handles the view-changing keys and changes what it displays. A Frame that changes its .body attribute would be a good choice. 3. if you plan to only ever have those three views you could use an input_filter on the MainLoop. I don't recommend this because it's the least flexible option. Ian _______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
