comparison src/cagou/core/xmlui.py @ 71:8c9fe2c5aacc

settings: save button is now disabled when there is nothing to save
author Goffi <goffi@goffi.org>
date Sun, 18 Dec 2016 16:31:23 +0100
parents a9c6b089070d
children a766c278b640
comparison
equal deleted inserted replaced
70:46b5f3ecf6a1 71:8c9fe2c5aacc
464 if self.close_cb is not None: 464 if self.close_cb is not None:
465 self.close_cb(self) 465 self.close_cb(self)
466 else: 466 else:
467 G.host.closeUI() 467 G.host.closeUI()
468 468
469 def onParamChange(self, ctrl):
470 super(XMLUIPanel, self).onParamChange(ctrl)
471 self.save_btn.disabled = False
472
469 def addPostTreat(self, callback): 473 def addPostTreat(self, callback):
470 self._post_treats.append(callback) 474 self._post_treats.append(callback)
471 475
472 def _postTreatCb(self): 476 def _postTreatCb(self):
473 for cb in self._post_treats: 477 for cb in self._post_treats:
474 cb() 478 cb()
475 del self._post_treats 479 del self._post_treats
480
481 def _saveButtonCb(self, button):
482 button.disabled = True
483 self.onSaveParams(button)
476 484
477 def constructUI(self, parsed_dom): 485 def constructUI(self, parsed_dom):
478 xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb) 486 xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb)
479 if self.xmlui_title: 487 if self.xmlui_title:
480 self.add_widget(Title(text=self.xmlui_title)) 488 self.add_widget(Title(text=self.xmlui_title))
486 if not 'NO_CANCEL' in self.flags: 494 if not 'NO_CANCEL' in self.flags:
487 cancel_btn = FormButton(text=_(u"Cancel")) 495 cancel_btn = FormButton(text=_(u"Cancel"))
488 cancel_btn.bind(on_press=self.onFormCancelled) 496 cancel_btn.bind(on_press=self.onFormCancelled)
489 self.add_widget(cancel_btn) 497 self.add_widget(cancel_btn)
490 elif self.type == 'param': 498 elif self.type == 'param':
491 save_btn = FormButton(text=_(u"Save")) 499 self.save_btn = FormButton(text=_(u"Save"), disabled=True)
492 save_btn.bind(on_press=self.onSaveParams) 500 self.save_btn.bind(on_press=self._saveButtonCb)
493 self.add_widget(save_btn) 501 self.add_widget(self.save_btn)
494 self.add_widget(Widget()) # to have elements on the top 502 self.add_widget(Widget()) # to have elements on the top
495 503
496 def show(self, *args, **kwargs): 504 def show(self, *args, **kwargs):
497 if not self.user_action and not kwargs.get("force", False): 505 if not self.user_action and not kwargs.get("force", False):
498 G.host.addNotifUI(self) 506 G.host.addNotifUI(self)