Index: Lib/lib-tk/Tix.py =================================================================== --- Lib/lib-tk/Tix.py (revision 58194) +++ Lib/lib-tk/Tix.py (working copy) @@ -850,7 +850,7 @@ # FIXME: return python object pass -class HList(TixWidget): +class HList(TixWidget, XView, YView): """HList - Hierarchy display widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines @@ -1037,12 +1037,6 @@ def show_entry(self, entry): return self.tk.call(self._w, 'show', 'entry', entry) - def xview(self, *args): - self.tk.call(self._w, 'xview', *args) - - def yview(self, *args): - self.tk.call(self._w, 'yview', *args) - class InputOnly(TixWidget): """InputOnly - Invisible widget. Unix only. @@ -1419,7 +1413,7 @@ if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) -class TList(TixWidget): +class TList(TixWidget, XView, YView): """TList - Hierarchy display widget which can be used to display data in a tabular format. The list entries of a TList widget are similar to the entries in the Tk listbox widget. The main @@ -1502,12 +1496,6 @@ def selection_set(self, first, last=None): self.tk.call(self._w, 'selection', 'set', first, last) - def xview(self, *args): - self.tk.call(self._w, 'xview', *args) - - def yview(self, *args): - self.tk.call(self._w, 'yview', *args) - class Tree(TixWidget): """Tree - The tixTree widget can be used to display hierachical data in a tree form. The user can adjust @@ -1777,7 +1765,7 @@ pass -class Grid(TixWidget): +class Grid(TixWidget, XView, YView): '''The Tix Grid command creates a new window and makes it into a tixGrid widget. Additional options, may be specified on the command line or in the option database to configure aspects such as its cursor @@ -1865,22 +1853,6 @@ # def size dim index ?option value ...? # def unset x y - def xview(self): - return self._getdoubles(self.tk.call(self, 'xview')) - def xview_moveto(self, fraction): - self.tk.call(self,'xview', 'moveto', fraction) - def xview_scroll(self, count, what="units"): - "Scroll right (count>0) or left of units|pages" - self.tk.call(self, 'xview', 'scroll', count, what) - - def yview(self): - return self._getdoubles(self.tk.call(self, 'yview')) - def yview_moveto(self, fraction): - self.tk.call(self,'ysview', 'moveto', fraction) - def yview_scroll(self, count, what="units"): - "Scroll down (count>0) or up of units|pages" - self.tk.call(self, 'yview', 'scroll', count, what) - class ScrolledGrid(Grid): '''Scrolled Grid widgets''' Index: Lib/lib-tk/Tkinter.py =================================================================== --- Lib/lib-tk/Tkinter.py (revision 58194) +++ Lib/lib-tk/Tkinter.py (working copy) @@ -1948,6 +1948,36 @@ Pack, Place or Grid.""" pass +class XView: + """Internal class. Add methods xview, xview_moveto, xview_scroll.""" + def xview(self, *args): + """Query and change horizontal position of the view.""" + if not args: + return self._getdoubles(self.tk.call(self._w, 'xview')) + self.tk.call((self._w, 'xview') + args) + def xview_moveto(self, fraction): + """Adjusts the view in the window so that FRACTION of the + total width of the canvas is off-screen to the left.""" + self.tk.call(self._w, 'xview', 'moveto', fraction) + def xview_scroll(self, number, what): + """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" + self.tk.call(self._w, 'xview', 'scroll', number, what) + +class YView: + """Internal class. Add methods yview, yview_moveto, yview_scroll.""" + def yview(self, *args): + """Query and change vertical position of the view.""" + if not args: + return self._getdoubles(self.tk.call(self._w, 'yview')) + self.tk.call((self._w, 'yview') + args) + def yview_moveto(self, fraction): + """Adjusts the view in the window so that FRACTION of the + total height of the canvas is off-screen to the top.""" + self.tk.call(self._w, 'yview', 'moveto', fraction) + def yview_scroll(self, number, what): + """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" + self.tk.call(self._w, 'yview', 'scroll', number, what) + class Toplevel(BaseWidget, Wm): """Toplevel widget, e.g. for dialogs.""" def __init__(self, master=None, cnf={}, **kw): @@ -2055,7 +2085,7 @@ else: return '@%r,%r' % (x, y) -class Canvas(Widget): +class Canvas(Widget, XView, YView): """Canvas widget to display graphical elements like lines or text.""" def __init__(self, master=None, cnf={}, **kw): """Construct a canvas widget with the parent MASTER. @@ -2295,30 +2325,6 @@ def type(self, tagOrId): """Return the type of the item TAGORID.""" return self.tk.call(self._w, 'type', tagOrId) or None - def xview(self, *args): - """Query and change horizontal position of the view.""" - if not args: - return self._getdoubles(self.tk.call(self._w, 'xview')) - self.tk.call((self._w, 'xview') + args) - def xview_moveto(self, fraction): - """Adjusts the view in the window so that FRACTION of the - total width of the canvas is off-screen to the left.""" - self.tk.call(self._w, 'xview', 'moveto', fraction) - def xview_scroll(self, number, what): - """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'xview', 'scroll', number, what) - def yview(self, *args): - """Query and change vertical position of the view.""" - if not args: - return self._getdoubles(self.tk.call(self._w, 'yview')) - self.tk.call((self._w, 'yview') + args) - def yview_moveto(self, fraction): - """Adjusts the view in the window so that FRACTION of the - total height of the canvas is off-screen to the top.""" - self.tk.call(self._w, 'yview', 'moveto', fraction) - def yview_scroll(self, number, what): - """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'yview', 'scroll', number, what) class Checkbutton(Widget): """Checkbutton widget which is either in on- or off-state.""" @@ -2349,7 +2355,7 @@ """Toggle the button.""" self.tk.call(self._w, 'toggle') -class Entry(Widget): +class Entry(Widget, XView): """Entry widget which allows to display simple text.""" def __init__(self, master=None, cnf={}, **kw): """Construct an entry widget with the parent MASTER. @@ -2412,16 +2418,6 @@ """Set the variable end of a selection to INDEX.""" self.tk.call(self._w, 'selection', 'to', index) select_to = selection_to - def xview(self, index): - """Query and change horizontal position of the view.""" - self.tk.call(self._w, 'xview', index) - def xview_moveto(self, fraction): - """Adjust the view in the window so that FRACTION of the - total width of the entry is off-screen to the left.""" - self.tk.call(self._w, 'xview', 'moveto', fraction) - def xview_scroll(self, number, what): - """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'xview', 'scroll', number, what) class Frame(Widget): """Frame widget which may contain other widgets and can have a 3D border.""" @@ -2463,7 +2459,7 @@ """ Widget.__init__(self, master, 'label', cnf, kw) -class Listbox(Widget): +class Listbox(Widget, XView, YView): """Listbox widget which can display a list of strings.""" def __init__(self, master=None, cnf={}, **kw): """Construct a listbox widget with the parent MASTER. @@ -2542,30 +2538,6 @@ def size(self): """Return the number of elements in the listbox.""" return getint(self.tk.call(self._w, 'size')) - def xview(self, *what): - """Query and change horizontal position of the view.""" - if not what: - return self._getdoubles(self.tk.call(self._w, 'xview')) - self.tk.call((self._w, 'xview') + what) - def xview_moveto(self, fraction): - """Adjust the view in the window so that FRACTION of the - total width of the entry is off-screen to the left.""" - self.tk.call(self._w, 'xview', 'moveto', fraction) - def xview_scroll(self, number, what): - """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'xview', 'scroll', number, what) - def yview(self, *what): - """Query and change vertical position of the view.""" - if not what: - return self._getdoubles(self.tk.call(self._w, 'yview')) - self.tk.call((self._w, 'yview') + what) - def yview_moveto(self, fraction): - """Adjust the view in the window so that FRACTION of the - total width of the entry is off-screen to the top.""" - self.tk.call(self._w, 'yview', 'moveto', fraction) - def yview_scroll(self, number, what): - """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'yview', 'scroll', number, what) def itemcget(self, index, option): """Return the resource value for an ITEM and an OPTION.""" return self.tk.call( @@ -2800,7 +2772,7 @@ -class Text(Widget): +class Text(Widget, XView, YView): """Text widget which can display text in various forms.""" def __init__(self, master=None, cnf={}, **kw): """Construct a text widget with the parent MASTER. @@ -3122,32 +3094,6 @@ """Return all names of embedded windows in this widget.""" return self.tk.splitlist( self.tk.call(self._w, 'window', 'names')) - def xview(self, *what): - """Query and change horizontal position of the view.""" - if not what: - return self._getdoubles(self.tk.call(self._w, 'xview')) - self.tk.call((self._w, 'xview') + what) - def xview_moveto(self, fraction): - """Adjusts the view in the window so that FRACTION of the - total width of the canvas is off-screen to the left.""" - self.tk.call(self._w, 'xview', 'moveto', fraction) - def xview_scroll(self, number, what): - """Shift the x-view according to NUMBER which is measured - in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'xview', 'scroll', number, what) - def yview(self, *what): - """Query and change vertical position of the view.""" - if not what: - return self._getdoubles(self.tk.call(self._w, 'yview')) - self.tk.call((self._w, 'yview') + what) - def yview_moveto(self, fraction): - """Adjusts the view in the window so that FRACTION of the - total height of the canvas is off-screen to the top.""" - self.tk.call(self._w, 'yview', 'moveto', fraction) - def yview_scroll(self, number, what): - """Shift the y-view according to NUMBER which is measured - in "units" or "pages" (WHAT).""" - self.tk.call(self._w, 'yview', 'scroll', number, what) def yview_pickplace(self, *what): """Obsolete function, use see.""" self.tk.call((self._w, 'yview', '-pickplace') + what)