comparison src/browser/base_widget.py @ 458:1eeed8028199

browser side: rename parameter of getParent / getWidgetPanel from 'verbose' to 'expect'
author souliane <souliane@mailoo.org>
date Thu, 29 May 2014 17:49:59 +0200
parents 981ed669d3b3
children
comparison
equal deleted inserted replaced
457:b55bc50756fa 458:1eeed8028199
222 self.host.registerWidget(self) 222 self.host.registerWidget(self)
223 223
224 def getDebugName(self): 224 def getDebugName(self):
225 return "%s (%s)" % (self, self.__title.getText()) 225 return "%s (%s)" % (self, self.__title.getText())
226 226
227 def getWidgetsPanel(self, verbose=True): 227 def getWidgetsPanel(self, expect=True):
228 return self.getParent(WidgetsPanel, verbose) 228 return self.getParent(WidgetsPanel, expect)
229 229
230 def getParent(self, class_=None, verbose=True): 230 def getParent(self, class_=None, expect=True):
231 """ 231 """Return the closest ancestor of the specified class.
232
232 Note: this method overrides pyjamas.ui.Widget.getParent 233 Note: this method overrides pyjamas.ui.Widget.getParent
234
233 @param class_: class of the ancestor to look for or None to return the first parent 235 @param class_: class of the ancestor to look for or None to return the first parent
234 @param verbose: set to True to log error messages # FIXME: must be removed 236 @param expect: set to True if the parent is expected (print a message if not found)
235 @return: the parent/ancestor or None if it has not been found 237 @return: the parent/ancestor or None if it has not been found
236 """ 238 """
237 current = Widget.getParent(self) 239 current = Widget.getParent(self)
238 if class_ is None: 240 if class_ is None:
239 return current # this is the default behavior 241 return current # this is the default behavior
240 while current is not None and not isinstance(current, class_): 242 while current is not None and not isinstance(current, class_):
241 current = Widget.getParent(current) 243 current = Widget.getParent(current)
242 if current is None and verbose: 244 if current is None and expect:
243 log.debug("Can't find parent %s for %s" % (class_, self)) 245 log.debug("Can't find parent %s for %s" % (class_, self))
244 return current 246 return current
245 247
246 def onClick(self, sender): 248 def onClick(self, sender):
247 self.host.setSelected(self) 249 self.host.setSelected(self)