From: <cl...@us...> - 2002-05-29 02:14:41
|
Update of /cvsroot/todo-manager/todo-manager In directory usw-pr-cvs1:/tmp/cvs-serv9231 Modified Files: Tag: dev-bronze objectlistbox.py Log Message: Support for class.configure() and class[setting] = value Index: objectlistbox.py =================================================================== RCS file: /cvsroot/todo-manager/todo-manager/Attic/objectlistbox.py,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -d -r1.1.2.16 -r1.1.2.17 --- objectlistbox.py 26 May 2002 22:58:10 -0000 1.1.2.16 +++ objectlistbox.py 29 May 2002 02:14:35 -0000 1.1.2.17 @@ -344,3 +344,59 @@ index = index + 1 self.scrollrange_set() + + def configure(self, *args, **kw): + # Handle __setitem__ command passes + if args and not kw: + kw = args[0] + + for key, value in kw.items(): + # Check for canvas specific options + if key in ("width", "height", "background", "bg"): + self._canvas.configure({key: value}) + del kw[key] # Remove this key so it doesn't get passed to Frame + + # Check for task color options + else: + if key == "foreground" or key == "fg": + self.__foreground = value + del kw[key] + if key == "itemcolor": + self.__item_color = value + del kw[key] + if key == "selectioncolor": + self.__selection_color = value + del kw[key] + if key == "font": + self.__font = value + del kw[key] + + # Send the left over options to the frame + Frame.configure(self, kw) + + # Alias config to configure since some people don't like to type a lot + config = configure + + def update(self): + """Update the entire widget""" + Frame.update(self) + self._canvas.update() + self.draw() + + def __setitem__(self, key, value): + self.configure({key: value}) + + def __getitem__(self, key): + # Check for setting that apply to the canvas + if key in ("width", "height", "background", "bg"): + return self._canvas[key] + + # Custom values + elif key == "foreground" or key == "fg": return self.__foreground + elif key == "itemcolor": return self.__item_color + elif key == "selectioncolor": return self.__selection_color + elif key == "font": return self.__font + + # If the setting isn't directly supported here, pass it to the Frame + else: + return Frame.__getitem__(self, key) |