Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/lib-tk/Tix.py

    r2 r391  
    11# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
    22#
    3 # $Id: Tix.py 72279 2009-05-04 16:06:12Z walter.doerwald $
     3# $Id$
    44#
    55# Tix.py -- Tix widget wrappers.
     
    4646AUTO = 'auto'
    4747ACROSSTOP = 'acrosstop'
     48
     49# A few useful constants for the Grid widget
     50ASCII = 'ascii'
     51CELL = 'cell'
     52COLUMN = 'column'
     53DECREASING = 'decreasing'
     54INCREASING = 'increasing'
     55INTEGER = 'integer'
     56MAIN = 'main'
     57MAX = 'max'
     58REAL = 'real'
     59ROW = 'row'
     60S_REGION = 's-region'
     61X_REGION = 'x-region'
     62Y_REGION = 'y-region'
    4863
    4964# Some constants used by Tkinter dooneevent()
     
    149164        depth of the X display: xbm images are chosen on monochrome
    150165        displays and color images are chosen on color displays. By using
    151         tix_ getimage, you can advoid hard coding the pathnames of the
     166        tix_ getimage, you can avoid hard coding the pathnames of the
    152167        image files in your application. When successful, this command
    153168        returns the name of the newly created image, which can be used to
     
    157172
    158173    def tix_option_get(self, name):
    159         """Gets  the options  manitained  by  the  Tix
     174        """Gets  the options  maintained  by  the  Tix
    160175        scheme mechanism. Available options include:
    161176
     
    322337    # Button class if you go through the proper constructors
    323338    def __getattr__(self, name):
    324         if self.subwidget_list.has_key(name):
     339        if name in self.subwidget_list:
    325340            return self.subwidget_list[name]
    326341        raise AttributeError, name
     
    391406        options = ()
    392407        for k, v in cnf.items():
    393             if callable(v):
     408            if hasattr(v, '__call__'):
    394409                v = self._register(v)
    395410            options = options + ('-'+k, v)
     
    450465        # in Tkinter when it finally calls Tcl to destroy the NoteBook
    451466        for c in self.children.values(): c.destroy()
    452         if self.master.children.has_key(self._name):
     467        if self._name in self.master.children:
    453468            del self.master.children[self._name]
    454         if self.master.subwidget_list.has_key(self._name):
     469        if self._name in self.master.subwidget_list:
    455470            del self.master.subwidget_list[self._name]
    456471        if self.destroy_physically:
     
    474489    def __init__(self, itemtype, cnf={}, **kw):
    475490        master = _default_root              # global from Tkinter
    476         if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
    477         elif not master and kw.has_key('refwindow'):  master= kw['refwindow']
     491        if not master and 'refwindow' in cnf: master=cnf['refwindow']
     492        elif not master and 'refwindow' in kw:  master= kw['refwindow']
    478493        elif not master: raise RuntimeError, "Too early to create display style: no root window"
    479494        self.tk = master.tk
     
    557572
    558573    def invoke(self, name):
    559         if self.subwidget_list.has_key(name):
     574        if name in self.subwidget_list:
    560575            self.tk.call(self._w, 'invoke', name)
    561576
    562577class ComboBox(TixWidget):
    563578    """ComboBox - an Entry field with a dropdown menu. The user can select a
    564     choice by either typing in the entry subwdget or selecting from the
     579    choice by either typing in the entry subwidget or selecting from the
    565580    listbox subwidget.
    566581
     
    851866        pass
    852867
    853 class HList(TixWidget):
     868class HList(TixWidget, XView, YView):
    854869    """HList - Hierarchy display  widget can be used to display any data
    855870    that have a hierarchical structure, for example, file system directory
    856871    trees. The list entries are indented and connected by branch lines
    857     according to their places in the hierachy.
     872    according to their places in the hierarchy.
    858873
    859874    Subwidgets - None"""
     
    962977        return self.tk.call(self._w, 'info', 'anchor')
    963978
     979    def info_bbox(self, entry):
     980        return self._getints(
     981                self.tk.call(self._w, 'info', 'bbox', entry)) or None
     982
    964983    def info_children(self, entry=None):
    965984        c = self.tk.call(self._w, 'info', 'children', entry)
     
    968987    def info_data(self, entry):
    969988        return self.tk.call(self._w, 'info', 'data', entry)
     989
     990    def info_dragsite(self):
     991        return self.tk.call(self._w, 'info', 'dragsite')
     992
     993    def info_dropsite(self):
     994        return self.tk.call(self._w, 'info', 'dropsite')
    970995
    971996    def info_exists(self, entry):
     
    10381063        return self.tk.call(self._w, 'show', 'entry', entry)
    10391064
    1040     def xview(self, *args):
    1041         self.tk.call(self._w, 'xview', *args)
    1042 
    1043     def yview(self, *args):
    1044         self.tk.call(self._w, 'yview', *args)
    1045 
    10461065class InputOnly(TixWidget):
    10471066    """InputOnly - Invisible widget. Unix only.
     
    11831202
    11841203    def __init__(self, master, cnf={}, **kw):
    1185         TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
     1204        TixWidget.__init__(self, master, 'tixOptionMenu',
     1205                ['labelside', 'options'], cnf, kw)
    11861206        self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
    11871207        self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
     
    12421262
    12431263    def panes(self):
    1244         names = self.tk.call(self._w, 'panes')
    1245         ret = []
    1246         for x in names:
    1247             ret.append(self.subwidget(x))
    1248         return ret
     1264        names = self.tk.splitlist(self.tk.call(self._w, 'panes'))
     1265        return [self.subwidget(x) for x in names]
    12491266
    12501267class PopupMenu(TixWidget):
     
    14171434
    14181435    def invoke(self, name):
    1419         if self.subwidget_list.has_key(name):
     1436        if name in self.subwidget_list:
    14201437            self.tk.call(self._w, 'invoke', name)
    14211438
    1422 class TList(TixWidget):
     1439class TList(TixWidget, XView, YView):
    14231440    """TList - Hierarchy display widget which can be
    14241441    used to display data in a tabular format. The list entries of a TList
     
    15031520        self.tk.call(self._w, 'selection', 'set', first, last)
    15041521
    1505     def xview(self, *args):
    1506         self.tk.call(self._w, 'xview', *args)
    1507 
    1508     def yview(self, *args):
    1509         self.tk.call(self._w, 'yview', *args)
    1510 
    15111522class Tree(TixWidget):
    1512     """Tree - The tixTree widget can be used to display hierachical
     1523    """Tree - The tixTree widget can be used to display hierarchical
    15131524    data in a tree form. The user can adjust
    15141525    the view of the tree by opening or closing parts of the tree."""
     
    15641575    def __init__(self, master=None, cnf={}, **kw):
    15651576        TixWidget.__init__(self, master, 'tixCheckList',
    1566                            ['options'], cnf, kw)
     1577                           ['options', 'radio'], cnf, kw)
    15671578        self.subwidget_list['hlist'] = _dummyHList(self, 'hlist')
    15681579        self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb')
     
    17781789
    17791790
    1780 class Grid(TixWidget):
     1791class Grid(TixWidget, XView, YView):
    17811792    '''The Tix Grid command creates a new window  and makes it into a
    17821793    tixGrid widget. Additional options, may be specified on the command
     
    18021813
    18031814    # valid options as of Tk 8.4
    1804     # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, edit
    1805     # entryconfigure, format, geometryinfo, info, index, move, nearest, selection
    1806     # set, size, unset, xview, yview
    1807     # def anchor option ?args ...?
     1815    # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget,
     1816    # edit, entryconfigure, format, geometryinfo, info, index, move, nearest,
     1817    # selection, set, size, unset, xview, yview
     1818    def anchor_clear(self):
     1819        """Removes the selection anchor."""
     1820        self.tk.call(self, 'anchor', 'clear')
     1821
    18081822    def anchor_get(self):
    18091823        "Get the (x,y) coordinate of the current anchor cell"
    18101824        return self._getints(self.tk.call(self, 'anchor', 'get'))
    18111825
    1812     # def bdtype
    1813     # def delete dim from ?to?
     1826    def anchor_set(self, x, y):
     1827        """Set the selection anchor to the cell at (x, y)."""
     1828        self.tk.call(self, 'anchor', 'set', x, y)
     1829
    18141830    def delete_row(self, from_, to=None):
    18151831        """Delete rows between from_ and to inclusive.
     
    18191835        else:
    18201836            self.tk.call(self, 'delete', 'row', from_, to)
     1837
    18211838    def delete_column(self, from_, to=None):
    18221839        """Delete columns between from_ and to inclusive.
     
    18261843        else:
    18271844            self.tk.call(self, 'delete', 'column', from_, to)
    1828     # def edit apply
    1829     # def edit set x y
     1845
     1846    def edit_apply(self):
     1847        """If any cell is being edited, de-highlight the cell  and  applies
     1848        the changes."""
     1849        self.tk.call(self, 'edit', 'apply')
     1850
     1851    def edit_set(self, x, y):
     1852        """Highlights  the  cell  at  (x, y) for editing, if the -editnotify
     1853        command returns True for this cell."""
     1854        self.tk.call(self, 'edit', 'set', x, y)
    18301855
    18311856    def entrycget(self, x, y, option):
    18321857        "Get the option value for cell at (x,y)"
     1858        if option and option[0] != '-':
     1859            option = '-' + option
    18331860        return self.tk.call(self, 'entrycget', x, y, option)
    18341861
    1835     def entryconfigure(self, x, y, **kw):
    1836         return self.tk.call(self, 'entryconfigure', x, y, *self._options(None, kw))
     1862    def entryconfigure(self, x, y, cnf=None, **kw):
     1863        return self._configure(('entryconfigure', x, y), cnf, kw)
     1864
    18371865    # def format
    18381866    # def index
     
    18401868    def info_exists(self, x, y):
    18411869        "Return True if display item exists at (x,y)"
    1842         return bool(int(self.tk.call(self, 'info', 'exists', x, y)))
     1870        return self._getboolean(self.tk.call(self, 'info', 'exists', x, y))
    18431871
    18441872    def info_bbox(self, x, y):
    18451873        # This seems to always return '', at least for 'text' displayitems
    18461874        return self.tk.call(self, 'info', 'bbox', x, y)
     1875
     1876    def move_column(self, from_, to, offset):
     1877        """Moves the range of columns from position FROM through TO by
     1878        the distance indicated by OFFSET. For example, move_column(2, 4, 1)
     1879        moves the columns 2,3,4 to columns 3,4,5."""
     1880        self.tk.call(self, 'move', 'column', from_, to, offset)
     1881
     1882    def move_row(self, from_, to, offset):
     1883        """Moves the range of rows from position FROM through TO by
     1884        the distance indicated by OFFSET.
     1885        For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5."""
     1886        self.tk.call(self, 'move', 'row', from_, to, offset)
    18471887
    18481888    def nearest(self, x, y):
     
    18551895    # def selection set
    18561896    # def selection toggle
    1857     # def move dim from to offset
    18581897
    18591898    def set(self, x, y, itemtype=None, **kw):
     
    18631902        self.tk.call(self, 'set', x, y, *args)
    18641903
    1865     # def size dim index ?option value ...?
    1866     # def unset x y
    1867 
    1868     def xview(self):
    1869         return self._getdoubles(self.tk.call(self, 'xview'))
    1870     def xview_moveto(self, fraction):
    1871         self.tk.call(self,'xview', 'moveto', fraction)
    1872     def xview_scroll(self, count, what="units"):
    1873         "Scroll right (count>0) or left <count> of units|pages"
    1874         self.tk.call(self, 'xview', 'scroll', count, what)
    1875 
    1876     def yview(self):
    1877         return self._getdoubles(self.tk.call(self, 'yview'))
    1878     def yview_moveto(self, fraction):
    1879         self.tk.call(self,'ysview', 'moveto', fraction)
    1880     def yview_scroll(self, count, what="units"):
    1881         "Scroll down (count>0) or up <count> of units|pages"
    1882         self.tk.call(self, 'yview', 'scroll', count, what)
     1904    def size_column(self, index, **kw):
     1905        """Queries or sets the size of the column given by
     1906        INDEX.  INDEX may be any non-negative
     1907        integer that gives the position of a given column.
     1908        INDEX can also be the string "default"; in this case, this command
     1909        queries or sets the default size of all columns.
     1910        When no option-value pair is given, this command returns a tuple
     1911        containing the current size setting of the given column.  When
     1912        option-value pairs are given, the corresponding options of the
     1913        size setting of the given column are changed. Options may be one
     1914        of the follwing:
     1915              pad0 pixels
     1916                     Specifies the paddings to the left of a column.
     1917              pad1 pixels
     1918                     Specifies the paddings to the right of a column.
     1919              size val
     1920                     Specifies the width of a column.  Val may be:
     1921                     "auto" -- the width of the column is set to the
     1922                     width of the widest cell in the column;
     1923                     a valid Tk screen distance unit;
     1924                     or a real number following by the word chars
     1925                     (e.g. 3.4chars) that sets the width of the column to the
     1926                     given number of characters."""
     1927        return self.tk.split(self.tk.call(self._w, 'size', 'column', index,
     1928                             *self._options({}, kw)))
     1929
     1930    def size_row(self, index, **kw):
     1931        """Queries or sets the size of the row given by
     1932        INDEX. INDEX may be any non-negative
     1933        integer that gives the position of a given row .
     1934        INDEX can also be the string "default"; in this case, this command
     1935        queries or sets the default size of all rows.
     1936        When no option-value pair is given, this command returns a list con-
     1937        taining the current size setting of the given row . When option-value
     1938        pairs are given, the corresponding options of the size setting of the
     1939        given row are changed. Options may be one of the follwing:
     1940              pad0 pixels
     1941                     Specifies the paddings to the top of a row.
     1942              pad1 pixels
     1943                     Specifies the paddings to the bottom of a row.
     1944              size val
     1945                     Specifies the height of a row.  Val may be:
     1946                     "auto" -- the height of the row is set to the
     1947                     height of the highest cell in the row;
     1948                     a valid Tk screen distance unit;
     1949                     or a real number following by the word chars
     1950                     (e.g. 3.4chars) that sets the height of the row to the
     1951                     given number of characters."""
     1952        return self.tk.split(self.tk.call(
     1953                    self, 'size', 'row', index, *self._options({}, kw)))
     1954
     1955    def unset(self, x, y):
     1956        """Clears the cell at (x, y) by removing its display item."""
     1957        self.tk.call(self._w, 'unset', x, y)
     1958
    18831959
    18841960class ScrolledGrid(Grid):
Note: See TracChangeset for help on using the changeset viewer.