comparison browser_side/dialog.py @ 216:9827cda1a6b0

browser_side: added key listener to login and register panels - pressing enter set the focus to the next field or validate the form fix bug 29
author souliane <souliane@mailoo.org>
date Sun, 08 Sep 2013 13:40:01 +0200
parents a05e16f4a343
children f3898fbb00c3
comparison
equal deleted inserted replaced
215:e830a0c60d32 216:9827cda1a6b0
193 TextBox.__init__(self, *args, **kwargs) 193 TextBox.__init__(self, *args, **kwargs)
194 self.addKeyboardListener(self) 194 self.addKeyboardListener(self)
195 195
196 def onKeyUp(self, sender, keycode, modifiers): 196 def onKeyUp(self, sender, keycode, modifiers):
197 pass 197 pass
198 198
199 def onKeyDown(self, sender, keycode, modifiers): 199 def onKeyDown(self, sender, keycode, modifiers):
200 pass 200 pass
201 201
202 def onKeyPress(self, sender, keycode, modifiers): 202 def onKeyPress(self, sender, keycode, modifiers):
203 if self.enter_cb and keycode == KEY_ENTER: 203 if self.enter_cb and keycode == KEY_ENTER:
204 self.enter_cb(self) 204 self.enter_cb(self)
205 205
206 class GroupSelector(DialogBox): 206 class GroupSelector(DialogBox):
207 207
208 def __init__(self, top_widgets, initial_groups, selected_groups, 208 def __init__(self, top_widgets, initial_groups, selected_groups,
209 ok_title, ok_cb = None, cancel_cb = None): 209 ok_title, ok_cb = None, cancel_cb = None):
210 DialogBox.__init__(self, centered = True) 210 DialogBox.__init__(self, centered = True)
211 main_panel = VerticalPanel() 211 main_panel = VerticalPanel()
212 self.ok_cb = ok_cb 212 self.ok_cb = ok_cb
213 self.cancel_cb = cancel_cb 213 self.cancel_cb = cancel_cb
214 214
215 for wid in top_widgets: 215 for wid in top_widgets:
216 main_panel.add(wid) 216 main_panel.add(wid)
217 217
218 main_panel.add(Label('Select in which groups your contact is:')) 218 main_panel.add(Label('Select in which groups your contact is:'))
219 self.list_box = ListBox() 219 self.list_box = ListBox()
220 self.list_box.setMultipleSelect(True) 220 self.list_box.setMultipleSelect(True)
221 self.list_box.setVisibleItemCount(5) 221 self.list_box.setVisibleItemCount(5)
222 self.setAvailableGroups(initial_groups) 222 self.setAvailableGroups(initial_groups)
223 self.setGroupsSelected(selected_groups) 223 self.setGroupsSelected(selected_groups)
224 main_panel.add(self.list_box) 224 main_panel.add(self.list_box)
225 225
226 add_group_panel = HorizontalPanel() 226 add_group_panel = HorizontalPanel()
227 add_group_lb = Label('Add group:') 227 add_group_lb = Label('Add group:')
228 add_group_tb = ExtTextBox(enter_cb = self.onGroupInput) 228 add_group_tb = ExtTextBox(enter_cb = self.onGroupInput)
229 add_group_bt = Button("add", lambda sender: self.onGroupInput(add_group_tb)) 229 add_group_bt = Button("add", lambda sender: self.onGroupInput(add_group_tb))
230 add_group_panel.add(add_group_lb) 230 add_group_panel.add(add_group_lb)
231 add_group_panel.add(add_group_tb) 231 add_group_panel.add(add_group_tb)
232 add_group_panel.add(add_group_bt) 232 add_group_panel.add(add_group_bt)
233 main_panel.add(add_group_panel) 233 main_panel.add(add_group_panel)
234 234
235 button_panel = HorizontalPanel() 235 button_panel = HorizontalPanel()
236 button_panel.add(Button(ok_title, self.onOK)) 236 button_panel.add(Button(ok_title, self.onOK))
237 button_panel.add(Button("Cancel", self.onCancel)) 237 button_panel.add(Button("Cancel", self.onCancel))
238 main_panel.add(button_panel) 238 main_panel.add(button_panel)
239 239
240 self.setWidget(main_panel) 240 self.setWidget(main_panel)
241 241
242 def getSelectedGroups(self): 242 def getSelectedGroups(self):
243 """Return a list of selected groups""" 243 """Return a list of selected groups"""
244 return self.list_box.getSelectedValues() 244 return self.list_box.getSelectedValues()