comparison browser_side/dialog.py @ 210:3092f6b1710c

browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...) fix bug 15 fix bug 33
author souliane <souliane@mailoo.org>
date Fri, 06 Sep 2013 15:40:33 +0200
parents 4564c7bc06a7
children 49920d76aa6a
comparison
equal deleted inserted replaced
209:4564c7bc06a7 210:3092f6b1710c
63 self.choose_button.setEnabled(False) 63 self.choose_button.setEnabled(False)
64 button_panel.add(self.choose_button) 64 button_panel.add(self.choose_button)
65 button_panel.add(Button("Cancel", self.onCancel)) 65 button_panel.add(Button("Cancel", self.onCancel))
66 content.add(button_panel) 66 content.add(button_panel)
67 self.setHTML(text) 67 self.setHTML(text)
68 self.setWidget(content) 68 self.setWidget(content)
69 69
70 def onChange(self, sender): 70 def onChange(self, sender):
71 if self.nb_contact: 71 if self.nb_contact:
72 if len(self.contacts_list.getSelectedValues()) == self.nb_contact: 72 if len(self.contacts_list.getSelectedValues()) == self.nb_contact:
73 self.choose_button.setEnabled(True) 73 self.choose_button.setEnabled(True)
74 else: 74 else:
109 self.confirm_button = Button("OK", self.onConfirm) 109 self.confirm_button = Button("OK", self.onConfirm)
110 button_panel.add(self.confirm_button) 110 button_panel.add(self.confirm_button)
111 button_panel.add(Button("Cancel", self.onCancel)) 111 button_panel.add(Button("Cancel", self.onCancel))
112 content.add(button_panel) 112 content.add(button_panel)
113 self.setHTML(title) 113 self.setHTML(title)
114 self.setWidget(content) 114 self.setWidget(content)
115 115
116 def onConfirm(self, sender): 116 def onConfirm(self, sender):
117 self.hide() 117 self.hide()
118 self.callback(True) 118 self.callback(True)
119 119
120 def onCancel(self, sender): 120 def onCancel(self, sender):
121 self.hide() 121 self.hide()
122 self.callback(False) 122 self.callback(False)
123 123
124
124 class ConfirmDialog(GenericConfirmDialog): 125 class ConfirmDialog(GenericConfirmDialog):
125 126
126 def __init__(self, callback, text='Are you sure ?', title='Confirmation'): 127 def __init__(self, callback, text='Are you sure ?', title='Confirmation'):
127 GenericConfirmDialog.__init__(self,[HTML(text)], callback, title) 128 GenericConfirmDialog.__init__(self, [HTML(text)], callback, title)
129
128 130
129 class GenericDialog(DialogBox): 131 class GenericDialog(DialogBox):
130 """Dialog which just show a widget and a close button""" 132 """Dialog which just show a widget and a close button"""
131 133
132 def __init__(self, title, main_widget, callback = None, options = None): 134 def __init__(self, title, main_widget, callback=None, options=None):
133 """Simple notice dialog box 135 """Simple notice dialog box
134 @param title: HTML put in the header 136 @param title: HTML put in the header
135 @param main_widget: widget put in the body 137 @param main_widget: widget put in the body
136 @param callback: method to call on closing 138 @param callback: method to call on closing
137 @param options: one or more of the following options: 139 @param options: one or more of the following options:
197 if self.enter_cb and keycode == KEY_ENTER: 199 if self.enter_cb and keycode == KEY_ENTER:
198 self.enter_cb(self) 200 self.enter_cb(self)
199 201
200 class GroupSelector(DialogBox): 202 class GroupSelector(DialogBox):
201 203
202 def __init__(self, top_widgets, initial_groups, selected_groups, ok_cb = None, cancel_cb = None): 204 def __init__(self, top_widgets, initial_groups, selected_groups,
205 ok_title, ok_cb = None, cancel_cb = None):
203 DialogBox.__init__(self, centered = True) 206 DialogBox.__init__(self, centered = True)
204 main_panel = VerticalPanel() 207 main_panel = VerticalPanel()
205 self.ok_cb = ok_cb 208 self.ok_cb = ok_cb
206 self.cancel_cb = cancel_cb 209 self.cancel_cb = cancel_cb
207 210
224 add_group_panel.add(add_group_tb) 227 add_group_panel.add(add_group_tb)
225 add_group_panel.add(add_group_bt) 228 add_group_panel.add(add_group_bt)
226 main_panel.add(add_group_panel) 229 main_panel.add(add_group_panel)
227 230
228 button_panel = HorizontalPanel() 231 button_panel = HorizontalPanel()
229 button_panel.add(Button("Add", self.onOK)) 232 button_panel.add(Button(ok_title, self.onOK))
230 button_panel.add(Button("Cancel", self.onCancel)) 233 button_panel.add(Button("Cancel", self.onCancel))
231 main_panel.add(button_panel) 234 main_panel.add(button_panel)
232 235
233 self.setWidget(main_panel) 236 self.setWidget(main_panel)
234 237
259 def onGroupInput(self, sender): 262 def onGroupInput(self, sender):
260 self.list_box.addItem(sender.getText()) 263 self.list_box.addItem(sender.getText())
261 sender.setText('') 264 sender.setText('')
262 self.list_box.setItemSelected(self.list_box.getItemCount()-1, "selected") 265 self.list_box.setItemSelected(self.list_box.getItemCount()-1, "selected")
263 266
267
264 class WheelTextBox(TextBox, MouseWheelHandler): 268 class WheelTextBox(TextBox, MouseWheelHandler):
265 269
266 def __init__(self, *args, **kwargs): 270 def __init__(self, *args, **kwargs):
267 TextBox.__init__(self, *args, **kwargs) 271 TextBox.__init__(self, *args, **kwargs)
268 MouseWheelHandler.__init__(self) 272 MouseWheelHandler.__init__(self)
269
270 273
271 274
272 class IntSetter(HorizontalPanel): 275 class IntSetter(HorizontalPanel):
273 """This class show a bar with button to set an int value""" 276 """This class show a bar with button to set an int value"""
274 277