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:
9 edited
15 copied

Legend:

Unmodified
Added
Removed
  • python/trunk

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

    r2 r391  
    108108
    109109    def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None):
    110         if key and dialogstates.has_key(key):
     110        if key and key in dialogstates:
    111111            self.directory, pattern = dialogstates[key]
    112112        else:
  • python/trunk/Lib/lib-tk/FixTk.py

    r2 r391  
    2020else:
    2121    def convert_path(s):
    22         if isinstance(s, str):
    23             s = s.decode("mbcs")
     22        assert isinstance(s, str)   # sys.prefix contains only bytes
     23        udir = s.decode("mbcs")
    2424        hdir = ctypes.windll.kernel32.\
    25             CreateFileW(s, 0x80,    # FILE_READ_ATTRIBUTES
     25            CreateFileW(udir, 0x80, # FILE_READ_ATTRIBUTES
    2626                        1,          # FILE_SHARE_READ
    2727                        None, 3,    # OPEN_EXISTING
     
    3939            # Conversion failed (e.g. network location)
    4040            return s
    41         s = buf[:res]
     41        s = buf[:res].encode("mbcs")
    4242        # Ignore leading \\?\
    43         if s.startswith(u"\\\\?\\"):
     43        if s.startswith("\\\\?\\"):
    4444            s = s[4:]
     45        if s.startswith("UNC"):
     46            s = "\\" + s[3:]
    4547        return s
    4648
     
    5355if os.path.exists(prefix):
    5456    prefix = convert_path(prefix)
    55     if not os.environ.has_key("TCL_LIBRARY"):
     57    if "TCL_LIBRARY" not in os.environ:
    5658        for name in os.listdir(prefix):
    5759            if name.startswith("tcl"):
     
    6365    import _tkinter
    6466    ver = str(_tkinter.TCL_VERSION)
    65     if not os.environ.has_key("TK_LIBRARY"):
     67    if "TK_LIBRARY" not in os.environ:
    6668        v = os.path.join(prefix, 'tk'+ver)
    6769        if os.path.exists(os.path.join(v, "tclIndex")):
     
    6971    # We don't know the Tix version, so we must search the entire
    7072    # directory
    71     if not os.environ.has_key("TIX_LIBRARY"):
     73    if "TIX_LIBRARY" not in os.environ:
    7274        for name in os.listdir(prefix):
    7375            if name.startswith("tix"):
  • python/trunk/Lib/lib-tk/ScrolledText.py

    r2 r391  
    2828        self.vbar['command'] = self.yview
    2929
    30         # Copy geometry methods of self.frame -- hack!
     30        # Copy geometry methods of self.frame without overriding Text
     31        # methods -- hack!
     32        text_meths = vars(Text).keys()
    3133        methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
     34        methods = set(methods).difference(text_meths)
    3235
    3336        for m in methods:
  • 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):
  • python/trunk/Lib/lib-tk/Tkinter.py

    r2 r391  
    3131"""
    3232
    33 __version__ = "$Revision: 73770 $"
     33__version__ = "$Revision: 81008 $"
    3434
    3535import sys
     
    4242from types import *
    4343from Tkconstants import *
     44import re
    4445
    4546wantobjects = 1
     
    5859except AttributeError: _tkinter.deletefilehandler = None
    5960
     61
     62_magic_re = re.compile(r'([\\{}])')
     63_space_re = re.compile(r'([\s])')
     64
     65def _join(value):
     66    """Internal function."""
     67    return ' '.join(map(_stringify, value))
     68
     69def _stringify(value):
     70    """Internal function."""
     71    if isinstance(value, (list, tuple)):
     72        if len(value) == 1:
     73            value = _stringify(value[0])
     74            if value[0] == '{':
     75                value = '{%s}' % value
     76        else:
     77            value = '{%s}' % _join(value)
     78    else:
     79        if isinstance(value, basestring):
     80            value = unicode(value)
     81        else:
     82            value = str(value)
     83        if not value:
     84            value = '{}'
     85        elif _magic_re.search(value):
     86            # add '\' before special characters and spaces
     87            value = _magic_re.sub(r'\\\1', value)
     88            value = _space_re.sub(r'\\\1', value)
     89        elif value[0] == '"' or _space_re.search(value):
     90            value = '{%s}' % value
     91    return value
    6092
    6193def _flatten(tuple):
     
    155187    pass
    156188
    157 def _exit(code='0'):
    158     """Internal function. Calling it will throw the exception SystemExit."""
     189def _exit(code=0):
     190    """Internal function. Calling it will raise the exception SystemExit."""
     191    try:
     192        code = int(code)
     193    except ValueError:
     194        pass
    159195    raise SystemExit, code
    160196
     
    535571        The type keyword specifies the form in which the data is
    536572        to be returned and should be an atom name such as STRING
    537         or FILE_NAME.  Type defaults to STRING.
     573        or FILE_NAME.  Type defaults to STRING, except on X11, where the default
     574        is to try UTF8_STRING and fall back to STRING.
    538575
    539576        This command is equivalent to:
     
    541578        selection_get(CLIPBOARD)
    542579        """
     580        if 'type' not in kw and self._windowingsystem == 'x11':
     581            try:
     582                kw['type'] = 'UTF8_STRING'
     583                return self.tk.call(('clipboard', 'get') + self._options(kw))
     584            except TclError:
     585                del kw['type']
    543586        return self.tk.call(('clipboard', 'get') + self._options(kw))
    544587
     
    548591        A widget specified for the optional displayof keyword
    549592        argument specifies the target display."""
    550         if not kw.has_key('displayof'): kw['displayof'] = self._w
     593        if 'displayof' not in kw: kw['displayof'] = self._w
    551594        self.tk.call(('clipboard', 'clear') + self._options(kw))
    552595    def clipboard_append(self, string, **kw):
     
    556599        argument specifies the target display. The clipboard
    557600        can be retrieved with selection_get."""
    558         if not kw.has_key('displayof'): kw['displayof'] = self._w
     601        if 'displayof' not in kw: kw['displayof'] = self._w
    559602        self.tk.call(('clipboard', 'append') + self._options(kw)
    560603              + ('--', string))
     
    614657    def selection_clear(self, **kw):
    615658        """Clear the current X selection."""
    616         if not kw.has_key('displayof'): kw['displayof'] = self._w
     659        if 'displayof' not in kw: kw['displayof'] = self._w
    617660        self.tk.call(('selection', 'clear') + self._options(kw))
    618661    def selection_get(self, **kw):
     
    622665        the selection and defaults to PRIMARY.  A keyword
    623666        parameter displayof specifies a widget on the display
    624         to use."""
    625         if not kw.has_key('displayof'): kw['displayof'] = self._w
     667        to use. A keyword parameter type specifies the form of data to be
     668        fetched, defaulting to STRING except on X11, where UTF8_STRING is tried
     669        before STRING."""
     670        if 'displayof' not in kw: kw['displayof'] = self._w
     671        if 'type' not in kw and self._windowingsystem == 'x11':
     672            try:
     673                kw['type'] = 'UTF8_STRING'
     674                return self.tk.call(('selection', 'get') + self._options(kw))
     675            except TclError:
     676                del kw['type']
    626677        return self.tk.call(('selection', 'get') + self._options(kw))
    627678    def selection_handle(self, command, **kw):
     
    654705        selection - name of the selection (default PRIMARY),
    655706        type - type of the selection (e.g. STRING, FILE_NAME)."""
    656         if not kw.has_key('displayof'): kw['displayof'] = self._w
     707        if 'displayof' not in kw: kw['displayof'] = self._w
    657708        name = self.tk.call(('selection', 'own') + self._options(kw))
    658709        if not name: return None
     
    10381089            return ('-displayof', self._w)
    10391090        return ()
     1091    @property
     1092    def _windowingsystem(self):
     1093        """Internal function."""
     1094        try:
     1095            return self._root()._windowingsystem_cached
     1096        except AttributeError:
     1097            ws = self._root()._windowingsystem_cached = \
     1098                        self.tk.call('tk', 'windowingsystem')
     1099            return ws
    10401100    def _options(self, cnf, kw = None):
    10411101        """Internal function."""
     
    10481108            if v is not None:
    10491109                if k[-1] == '_': k = k[:-1]
    1050                 if callable(v):
     1110                if hasattr(v, '__call__'):
    10511111                    v = self._register(v)
    10521112                elif isinstance(v, (tuple, list)):
     
    10591119                        else:
    10601120                            # format it to proper Tcl code if it contains space
    1061                             nv.append(('{%s}' if ' ' in item else '%s') % item)
     1121                            nv.append(_stringify(item))
    10621122                    else:
    10631123                        v = ' '.join(nv)
     
    12881348                if not value:
    12891349                    value = None
    1290                 elif '.' in value:
     1350                elif '.' in str(value):
    12911351                    value = getdouble(value)
    12921352                else:
     
    14131473        except:
    14141474            self.widget._report_exception()
     1475
     1476
     1477class XView:
     1478    """Mix-in class for querying and changing the horizontal position
     1479    of a widget's window."""
     1480
     1481    def xview(self, *args):
     1482        """Query and change the horizontal position of the view."""
     1483        res = self.tk.call(self._w, 'xview', *args)
     1484        if not args:
     1485            return self._getdoubles(res)
     1486
     1487    def xview_moveto(self, fraction):
     1488        """Adjusts the view in the window so that FRACTION of the
     1489        total width of the canvas is off-screen to the left."""
     1490        self.tk.call(self._w, 'xview', 'moveto', fraction)
     1491
     1492    def xview_scroll(self, number, what):
     1493        """Shift the x-view according to NUMBER which is measured in "units"
     1494        or "pages" (WHAT)."""
     1495        self.tk.call(self._w, 'xview', 'scroll', number, what)
     1496
     1497
     1498class YView:
     1499    """Mix-in class for querying and changing the vertical position
     1500    of a widget's window."""
     1501
     1502    def yview(self, *args):
     1503        """Query and change the vertical position of the view."""
     1504        res = self.tk.call(self._w, 'yview', *args)
     1505        if not args:
     1506            return self._getdoubles(res)
     1507
     1508    def yview_moveto(self, fraction):
     1509        """Adjusts the view in the window so that FRACTION of the
     1510        total height of the canvas is off-screen to the top."""
     1511        self.tk.call(self._w, 'yview', 'moveto', fraction)
     1512
     1513    def yview_scroll(self, number, what):
     1514        """Shift the y-view according to NUMBER which is measured in
     1515        "units" or "pages" (WHAT)."""
     1516        self.tk.call(self._w, 'yview', 'scroll', number, what)
    14151517
    14161518
     
    16191721class Tk(Misc, Wm):
    16201722    """Toplevel widget of Tk which represents mostly the main window
    1621     of an appliation. It has an associated Tcl interpreter."""
     1723    of an application. It has an associated Tcl interpreter."""
    16221724    _w = '.'
    16231725    def __init__(self, screenName=None, baseName=None, className='Tk',
     
    16351737        self.tk = None
    16361738        if baseName is None:
    1637             import sys, os
     1739            import os
    16381740            baseName = os.path.basename(sys.argv[0])
    16391741            baseName, ext = os.path.splitext(baseName)
     
    16441746        if useTk:
    16451747            self._loadtk()
    1646         self.readprofile(baseName, className)
     1748        if not sys.flags.ignore_environment:
     1749            # Issue #16248: Honor the -E flag to avoid code injection.
     1750            self.readprofile(baseName, className)
    16471751    def loadtk(self):
    16481752        if not self._tkloaded:
     
    16941798        such a file exists in the home directory."""
    16951799        import os
    1696         if os.environ.has_key('HOME'): home = os.environ['HOME']
     1800        if 'HOME' in os.environ: home = os.environ['HOME']
    16971801        else: home = os.curdir
    16981802        class_tcl = os.path.join(home, '.%s.tcl' % className)
     
    17771881            key = words[i][1:]
    17781882            value = words[i+1]
    1779             if value[:1] == '.':
     1883            if str(value)[:1] == '.':
    17801884                value = self._nametowidget(value)
    17811885            dict[key] = value
     
    18281932            key = words[i][1:]
    18291933            value = words[i+1]
    1830             if value[:1] == '.':
     1934            if str(value)[:1] == '.':
    18311935                value = self._nametowidget(value)
    18321936            dict[key] = value
     
    18771981            key = words[i][1:]
    18781982            value = words[i+1]
    1879             if value[:1] == '.':
     1983            if str(value)[:1] == '.':
    18801984                value = self._nametowidget(value)
    18811985            dict[key] = value
     
    19012005        self.tk = master.tk
    19022006        name = None
    1903         if cnf.has_key('name'):
     2007        if 'name' in cnf:
    19042008            name = cnf['name']
    19052009            del cnf['name']
     
    19122016            self._w = master._w + '.' + name
    19132017        self.children = {}
    1914         if self.master.children.has_key(self._name):
     2018        if self._name in self.master.children:
    19152019            self.master.children[self._name].destroy()
    19162020        self.master.children[self._name] = self
     
    19372041        for c in self.children.values(): c.destroy()
    19382042        self.tk.call('destroy', self._w)
    1939         if self.master.children.has_key(self._name):
     2043        if self._name in self.master.children:
    19402044            del self.master.children[self._name]
    19412045        Misc.destroy(self)
     
    19652069        for wmkey in ['screen', 'class_', 'class', 'visual',
    19662070                  'colormap']:
    1967             if cnf.has_key(wmkey):
     2071            if wmkey in cnf:
    19682072                val = cnf[wmkey]
    19692073                # TBD: a hack needed because some keys
     
    20582162        return '@%r,%r' % (x, y)
    20592163
    2060 class Canvas(Widget):
     2164class Canvas(Widget, XView, YView):
    20612165    """Canvas widget to display graphical elements like lines or text."""
    20622166    def __init__(self, master=None, cnf={}, **kw):
     
    22982402        """Return the type of the item TAGORID."""
    22992403        return self.tk.call(self._w, 'type', tagOrId) or None
    2300     def xview(self, *args):
    2301         """Query and change horizontal position of the view."""
    2302         if not args:
    2303             return self._getdoubles(self.tk.call(self._w, 'xview'))
    2304         self.tk.call((self._w, 'xview') + args)
    2305     def xview_moveto(self, fraction):
    2306         """Adjusts the view in the window so that FRACTION of the
    2307         total width of the canvas is off-screen to the left."""
    2308         self.tk.call(self._w, 'xview', 'moveto', fraction)
    2309     def xview_scroll(self, number, what):
    2310         """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
    2311         self.tk.call(self._w, 'xview', 'scroll', number, what)
    2312     def yview(self, *args):
    2313         """Query and change vertical position of the view."""
    2314         if not args:
    2315             return self._getdoubles(self.tk.call(self._w, 'yview'))
    2316         self.tk.call((self._w, 'yview') + args)
    2317     def yview_moveto(self, fraction):
    2318         """Adjusts the view in the window so that FRACTION of the
    2319         total height of the canvas is off-screen to the top."""
    2320         self.tk.call(self._w, 'yview', 'moveto', fraction)
    2321     def yview_scroll(self, number, what):
    2322         """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
    2323         self.tk.call(self._w, 'yview', 'scroll', number, what)
    23242404
    23252405class Checkbutton(Widget):
     
    23522432        self.tk.call(self._w, 'toggle')
    23532433
    2354 class Entry(Widget):
     2434class Entry(Widget, XView):
    23552435    """Entry widget which allows to display simple text."""
    23562436    def __init__(self, master=None, cnf={}, **kw):
     
    24032483    select_from = selection_from
    24042484    def selection_present(self):
    2405         """Return whether the widget has the selection."""
     2485        """Return True if there are characters selected in the entry, False
     2486        otherwise."""
    24062487        return self.tk.getboolean(
    24072488            self.tk.call(self._w, 'selection', 'present'))
     
    24152496        self.tk.call(self._w, 'selection', 'to', index)
    24162497    select_to = selection_to
    2417     def xview(self, index):
    2418         """Query and change horizontal position of the view."""
    2419         self.tk.call(self._w, 'xview', index)
    2420     def xview_moveto(self, fraction):
    2421         """Adjust the view in the window so that FRACTION of the
    2422         total width of the entry is off-screen to the left."""
    2423         self.tk.call(self._w, 'xview', 'moveto', fraction)
    2424     def xview_scroll(self, number, what):
    2425         """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
    2426         self.tk.call(self._w, 'xview', 'scroll', number, what)
    24272498
    24282499class Frame(Widget):
     
    24362507        cnf = _cnfmerge((cnf, kw))
    24372508        extra = ()
    2438         if cnf.has_key('class_'):
     2509        if 'class_' in cnf:
    24392510            extra = ('-class', cnf['class_'])
    24402511            del cnf['class_']
    2441         elif cnf.has_key('class'):
     2512        elif 'class' in cnf:
    24422513            extra = ('-class', cnf['class'])
    24432514            del cnf['class']
     
    24662537        Widget.__init__(self, master, 'label', cnf, kw)
    24672538
    2468 class Listbox(Widget):
     2539class Listbox(Widget, XView, YView):
    24692540    """Listbox widget which can display a list of strings."""
    24702541    def __init__(self, master=None, cnf={}, **kw):
     
    25452616        """Return the number of elements in the listbox."""
    25462617        return getint(self.tk.call(self._w, 'size'))
    2547     def xview(self, *what):
    2548         """Query and change horizontal position of the view."""
    2549         if not what:
    2550             return self._getdoubles(self.tk.call(self._w, 'xview'))
    2551         self.tk.call((self._w, 'xview') + what)
    2552     def xview_moveto(self, fraction):
    2553         """Adjust the view in the window so that FRACTION of the
    2554         total width of the entry is off-screen to the left."""
    2555         self.tk.call(self._w, 'xview', 'moveto', fraction)
    2556     def xview_scroll(self, number, what):
    2557         """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
    2558         self.tk.call(self._w, 'xview', 'scroll', number, what)
    2559     def yview(self, *what):
    2560         """Query and change vertical position of the view."""
    2561         if not what:
    2562             return self._getdoubles(self.tk.call(self._w, 'yview'))
    2563         self.tk.call((self._w, 'yview') + what)
    2564     def yview_moveto(self, fraction):
    2565         """Adjust the view in the window so that FRACTION of the
    2566         total width of the entry is off-screen to the top."""
    2567         self.tk.call(self._w, 'yview', 'moveto', fraction)
    2568     def yview_scroll(self, number, what):
    2569         """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
    2570         self.tk.call(self._w, 'yview', 'scroll', number, what)
    25712618    def itemcget(self, index, option):
    25722619        """Return the resource value for an ITEM and an OPTION."""
     
    28152862
    28162863
    2817 class Text(Widget):
     2864class Text(Widget, XView, YView):
    28182865    """Text widget which can display text in various forms."""
    28192866    def __init__(self, master=None, cnf={}, **kw):
     
    31373184        return self.tk.splitlist(
    31383185            self.tk.call(self._w, 'window', 'names'))
    3139     def xview(self, *what):
    3140         """Query and change horizontal position of the view."""
    3141         if not what:
    3142             return self._getdoubles(self.tk.call(self._w, 'xview'))
    3143         self.tk.call((self._w, 'xview') + what)
    3144     def xview_moveto(self, fraction):
    3145         """Adjusts the view in the window so that FRACTION of the
    3146         total width of the canvas is off-screen to the left."""
    3147         self.tk.call(self._w, 'xview', 'moveto', fraction)
    3148     def xview_scroll(self, number, what):
    3149         """Shift the x-view according to NUMBER which is measured
    3150         in "units" or "pages" (WHAT)."""
    3151         self.tk.call(self._w, 'xview', 'scroll', number, what)
    3152     def yview(self, *what):
    3153         """Query and change vertical position of the view."""
    3154         if not what:
    3155             return self._getdoubles(self.tk.call(self._w, 'yview'))
    3156         self.tk.call((self._w, 'yview') + what)
    3157     def yview_moveto(self, fraction):
    3158         """Adjusts the view in the window so that FRACTION of the
    3159         total height of the canvas is off-screen to the top."""
    3160         self.tk.call(self._w, 'yview', 'moveto', fraction)
    3161     def yview_scroll(self, number, what):
    3162         """Shift the y-view according to NUMBER which is measured
    3163         in "units" or "pages" (WHAT)."""
    3164         self.tk.call(self._w, 'yview', 'scroll', number, what)
    31653186    def yview_pickplace(self, *what):
    31663187        """Obsolete function, use see."""
     
    31953216        # 'command' is the only supported keyword
    31963217        callback = kwargs.get('command')
    3197         if kwargs.has_key('command'):
     3218        if 'command' in kwargs:
    31983219            del kwargs['command']
    31993220        if kwargs:
     
    32363257        options = ()
    32373258        for k, v in cnf.items():
    3238             if callable(v):
     3259            if hasattr(v, '__call__'):
    32393260                v = self._register(v)
    32403261            options = options + ('-'+k, v)
     
    32593280            if v is not None:
    32603281                if k[-1] == '_': k = k[:-1]
    3261                 if callable(v):
     3282                if hasattr(v, '__call__'):
    32623283                    v = self._register(v)
    32633284                res = res + ('-'+k, v)
     
    33483369
    33493370
    3350 class Spinbox(Widget):
     3371class Spinbox(Widget, XView):
    33513372    """spinbox widget."""
    33523373    def __init__(self, master=None, cnf={}, **kw):
     
    35513572        The child argument is the name of the child widget
    35523573        followed by pairs of arguments that specify how to
    3553         manage the windows. Options may have any of the values
    3554         accepted by the configure subcommand.
     3574        manage the windows. The possible options and values
     3575        are the ones accepted by the paneconfigure method.
    35553576        """
    35563577        self.tk.call((self._w, 'add', child) + self._options(kw))
  • python/trunk/Lib/lib-tk/tkMessageBox.py

    r2 r391  
    7171    if message: options["message"] = message
    7272    res = Message(**options).show()
    73     # In some Tcl installations, Tcl converts yes/no into a boolean
     73    # In some Tcl installations, yes/no is converted into a boolean.
    7474    if isinstance(res, bool):
    75         if res: return YES
     75        if res:
     76            return YES
    7677        return NO
    77     return res
     78    # In others we get a Tcl_Obj.
     79    return str(res)
    7880
    7981def showinfo(title=None, message=None, **options):
  • python/trunk/Lib/lib-tk/tkSimpleDialog.py

    r2 r391  
    4747        Toplevel.__init__(self, parent)
    4848
     49        self.withdraw() # remain invisible for now
    4950        # If the master is not viewable, don't
    5051        # make the child transient, or else it
     
    6667        self.buttonbox()
    6768
    68         self.wait_visibility() # window needs to be visible for the grab
    69         self.grab_set()
    7069
    7170        if not self.initial_focus:
     
    7877                                      parent.winfo_rooty()+50))
    7978
     79        self.deiconify() # become visibile now
     80
    8081        self.initial_focus.focus_set()
    8182
     83        # wait for window to appear on screen before calling grab_set
     84        self.wait_visibility()
     85        self.grab_set()
    8286        self.wait_window(self)
    8387
     
    197201        self.entry.grid(row=1, padx=5, sticky=W+E)
    198202
    199         if self.initialvalue:
     203        if self.initialvalue is not None:
    200204            self.entry.insert(0, self.initialvalue)
    201205            self.entry.select_range(0, END)
     
    280284class _QueryString(_QueryDialog):
    281285    def __init__(self, *args, **kw):
    282         if kw.has_key("show"):
     286        if "show" in kw:
    283287            self.__show = kw["show"]
    284288            del kw["show"]
  • python/trunk/Lib/lib-tk/turtle.py

    r2 r391  
    33# Version 1.0.1 - 24. 9. 2009
    44#
    5 # Copyright (C) 2006 - 2009  Gregor Lingl
     5# Copyright (C) 2006 - 2010  Gregor Lingl
    66# email: glingl@aon.at
    77#
     
    2828by Wally Feurzig and Seymour Papert in 1966.
    2929
    30 Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it
     30Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
    3131the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
    3232the direction it is facing, drawing a line as it moves. Give it the
    33 command turtle.left(25), and it rotates in-place 25 degrees clockwise.
     33command turtle.right(25), and it rotates in-place 25 degrees clockwise.
    3434
    3535By combining together these and similar commands, intricate shapes and
     
    9797
    9898Behind the scenes there are some features included with possible
    99 extensions in in mind. These will be commented and documented elsewhere.
     99extensions in mind. These will be commented and documented elsewhere.
    100100
    101101"""
     
    336336            del _dict[ex]
    337337    for ex in exclude:
    338         if _dict.has_key(ex):
     338        if ex in _dict:
    339339            del _dict[ex]
    340340    for ex in __methods(fromClass):
    341         if _dict.has_key(ex):
     341        if ex in _dict:
    342342            del _dict[ex]
    343343
     
    784784        if not isinstance(self.cv, ScrolledCanvas):
    785785            return self.canvwidth, self.canvheight
    786         if canvwidth is None and canvheight is None and bg is None:
     786        if canvwidth is canvheight is bg is None:
    787787            return self.cv.canvwidth, self.cv.canvheight
    788788        if canvwidth is not None:
     
    812812    """Will be raised in TurtleScreen.update, if _RUNNING becomes False.
    813813
    814     Thus stops execution of turtle graphics script. Main purpose: use in
    815     in the Demo-Viewer turtle.Demo.py.
     814    This stops execution of a turtle graphics script.
     815    Main purpose: use in the Demo-Viewer turtle.Demo.py.
    816816    """
    817817    pass
     
    860860        >>> s = Shape("compound")
    861861        >>> s.addcomponent(poly, "red", "blue")
    862         ### .. add more components and then use register_shape()
     862        >>> # .. add more components and then use register_shape()
    863863        """
    864864        if self._type != "compound":
     
    959959
    960960        Example (for a TurtleScreen instance named screen):
    961         screen.clear()
     961        >>> screen.clear()
    962962
    963963        Note: this method is not available as function.
     
    10001000        'logo'
    10011001        """
    1002         if mode == None:
     1002        if mode is None:
    10031003            return self._mode
    10041004        mode = mode.lower()
     
    10311031        >>> screen.setworldcoordinates(-10,-0.5,50,1.5)
    10321032        >>> for _ in range(36):
    1033                 left(10)
    1034                 forward(0.5)
     1033        ...     left(10)
     1034        ...     forward(0.5)
    10351035        """
    10361036        if self.mode() != "world":
     
    11371137        1.0
    11381138        >>> screen.colormode(255)
    1139         >>> turtle.pencolor(240,160,80)
     1139        >>> pencolor(240,160,80)
    11401140        """
    11411141        if cmode is None:
     
    12051205        >>> dist = 2
    12061206        >>> for i in range(200):
    1207                 fd(dist)
    1208                 rt(90)
    1209                 dist += 2
     1207        ...     fd(dist)
     1208        ...     rt(90)
     1209        ...     dist += 2
    12101210        """
    12111211        if n is None:
     
    12341234
    12351235    def _incrementudc(self):
    1236         "Increment upadate counter."""
     1236        """Increment update counter."""
    12371237        if not TurtleScreen._RUNNING:
    12381238            TurtleScreen._RUNNNING = True
     
    13051305        and a Turtle instance named turtle):
    13061306
    1307         >>> screen.onclick(turtle.goto)
    1308 
    1309         ### Subsequently clicking into the TurtleScreen will
    1310         ### make the turtle move to the clicked point.
     1307        >>> screen.onclick(goto)
     1308        >>> # Subsequently clicking into the TurtleScreen will
     1309        >>> # make the turtle move to the clicked point.
    13111310        >>> screen.onclick(None)
    1312 
    1313         ### event-binding will be removed
    13141311        """
    13151312        self._onscreenclick(fun, btn, add)
     
    13251322        must have focus. (See method listen.)
    13261323
    1327         Example (for a TurtleScreen instance named screen
    1328         and a Turtle instance named turtle):
     1324        Example (for a TurtleScreen instance named screen):
    13291325
    13301326        >>> def f():
    1331                 fd(50)
    1332                 lt(60)
    1333 
    1334 
     1327        ...     fd(50)
     1328        ...     lt(60)
     1329        ...
    13351330        >>> screen.onkey(f, "Up")
    13361331        >>> screen.listen()
    13371332
    1338         ### Subsequently the turtle can be moved by
    1339         ### repeatedly pressing the up-arrow key,
    1340         ### consequently drawing a hexagon
    1341         """
    1342         if fun == None:
     1333        Subsequently the turtle can be moved by repeatedly pressing
     1334        the up-arrow key, consequently drawing a hexagon
     1335
     1336        """
     1337        if fun is None:
    13431338            if key in self._keys:
    13441339                self._keys.remove(key)
     
    13701365        >>> running = True
    13711366        >>> def f():
    1372                 if running:
    1373                         fd(50)
    1374                         lt(60)
    1375                         screen.ontimer(f, 250)
    1376 
    1377         >>> f()   ### makes the turtle marching around
     1367        ...     if running:
     1368        ...             fd(50)
     1369        ...             lt(60)
     1370        ...             screen.ontimer(f, 250)
     1371        ...
     1372        >>> f()   # makes the turtle marching around
    13781373        >>> running = False
    13791374        """
     
    13861381        picname -- a string, name of a gif-file or "nopic".
    13871382
    1388         If picname is a filename, set the corresponing image as background.
     1383        If picname is a filename, set the corresponding image as background.
    13891384        If picname is "nopic", delete backgroundimage, if present.
    13901385        If picname is None, return the filename of the current backgroundimage.
     
    14101405        canvwidth -- positive integer, new width of canvas in pixels
    14111406        canvheight --  positive integer, new height of canvas in pixels
    1412         bg -- colorstring or color-tupel, new backgroundcolor
     1407        bg -- colorstring or color-tuple, new backgroundcolor
    14131408        If no arguments are given, return current (canvaswidth, canvasheight)
    14141409
     
    14191414        Example (for a Turtle instance named turtle):
    14201415        >>> turtle.screensize(2000,1500)
    1421             ### e. g. to search for an erroneously escaped turtle ;-)
     1416        >>> # e. g. to search for an erroneously escaped turtle ;-)
    14221417        """
    14231418        return self._resize(canvwidth, canvheight, bg)
     
    14611456        """Set turtle-mode to 'standard', 'world' or 'logo'.
    14621457        """
    1463         if mode == None:
     1458        if mode is None:
    14641459            return self._mode
    14651460        if mode not in ["standard", "logo", "world"]:
     
    14961491        >>> turtle.heading()
    14971492        90
    1498         >>> turtle.degrees(400.0)  # angle measurement in gon
     1493
     1494        Change angle measurement unit to grad (also known as gon,
     1495        grade, or gradian and equals 1/100-th of the right angle.)
     1496        >>> turtle.degrees(400.0)
    14991497        >>> turtle.heading()
    15001498        100
     
    20022000        >>> turtle.pensize()
    20032001        1
    2004         turtle.pensize(10)   # from here on lines of width 10 are drawn
     2002        >>> turtle.pensize(10)   # from here on lines of width 10 are drawn
    20052003        """
    20062004        if width is None:
     
    24422440                RawTurtle.screens.append(self.screen)
    24432441        else:
    2444             raise TurtleGraphicsError("bad cavas argument %s" % canvas)
     2442            raise TurtleGraphicsError("bad canvas argument %s" % canvas)
    24452443
    24462444        screen = self.screen
     
    25142512        Example (for a Turtle instance named turtle):
    25152513        >>> while undobufferentries():
    2516                 undo()
     2514        ...     undo()
    25172515        """
    25182516        if self.undobuffer is None:
     
    25902588        >>> dist = 2
    25912589        >>> for i in range(200):
    2592                 turtle.fd(dist)
    2593                 turtle.rt(90)
    2594                 dist += 2
     2590        ...     turtle.fd(dist)
     2591        ...     turtle.rt(90)
     2592        ...     dist += 2
    25952593        """
    25962594        return self.screen.tracer(flag, delay)
     
    26872685        """Set/return turtle's stretchfactors/outline. Set resizemode to "user".
    26882686
    2689         Optinonal arguments:
     2687        Optional arguments:
    26902688           stretch_wid : positive number
    26912689           stretch_len : positive number
     
    27052703        >>> turtle.shapesize(outline=8)
    27062704        """
    2707         if stretch_wid is None and stretch_len is None and outline == None:
     2705        if stretch_wid is stretch_len is outline is None:
    27082706            stretch_wid, stretch_len = self._stretchfactor
    27092707            return stretch_wid, stretch_len, self._outlinewidth
     
    27612759        >>> turtle.tilt(45)
    27622760        >>> turtle.tiltangle()
    2763         >>>
    27642761        """
    27652762        tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
     
    29612958        Example (for a Turtle instance named turtle):
    29622959        >>> for i in range(8):
    2963                 turtle.stamp(); turtle.fd(30)
     2960        ...     turtle.stamp(); turtle.fd(30)
    29642961        ...
    29652962        >>> turtle.clearstamps(2)
     
    29792976    def _goto(self, end):
    29802977        """Move the pen to the point end, thereby drawing a line
    2981         if pen is down. All other methodes for turtle movement depend
     2978        if pen is down. All other methods for turtle movement depend
    29822979        on this one.
    29832980        """
     
    30773074        # Turtle now at position old,
    30783075        self._position = old
    3079         ##  if undo is done during crating a polygon, the last vertex
    3080         ##  will be deleted. if the polygon is entirel deleted,
    3081         ##  creatigPoly will be set to False.
     3076        ##  if undo is done during creating a polygon, the last vertex
     3077        ##  will be deleted. if the polygon is entirely deleted,
     3078        ##  creatingPoly will be set to False.
    30823079        ##  Polygons created before the last one will not be affected by undo()
    30833080        if self._creatingPoly:
     
    32193216        """Draw a dot with diameter size, using color.
    32203217
    3221         Optional argumentS:
     3218        Optional arguments:
    32223219        size -- an integer >= 1 (if given)
    32233220        color -- a colorstring or a numeric color tuple
     
    34283425
    34293426        >>> def turn(x, y):
    3430                 left(360)
    3431 
    3432         >>> onclick(turn) # Now clicking into the turtle will turn it.
     3427        ...     left(360)
     3428        ...
     3429        >>> onclick(turn)  # Now clicking into the turtle will turn it.
    34333430        >>> onclick(None)  # event-binding will be removed
    34343431        """
     
    34463443        Example (for a MyTurtle instance named joe):
    34473444        >>> class MyTurtle(Turtle):
    3448                 def glow(self,x,y):
    3449                         self.fillcolor("red")
    3450                 def unglow(self,x,y):
    3451                         self.fillcolor("")
    3452 
     3445        ...     def glow(self,x,y):
     3446        ...             self.fillcolor("red")
     3447        ...     def unglow(self,x,y):
     3448        ...             self.fillcolor("")
     3449        ...
    34533450        >>> joe = MyTurtle()
    34543451        >>> joe.onclick(joe.glow)
    34553452        >>> joe.onrelease(joe.unglow)
    3456         ### clicking on joe turns fillcolor red,
    3457         ### unclicking turns it to transparent.
     3453
     3454        Clicking on joe turns fillcolor red, unclicking turns it to
     3455        transparent.
    34583456        """
    34593457        self.screen._onrelease(self.turtle._item, fun, btn, add)
     
    34743472        >>> turtle.ondrag(turtle.goto)
    34753473
    3476         ### Subsequently clicking and dragging a Turtle will
    3477         ### move it across the screen thereby producing handdrawings
    3478         ### (if pen is down).
     3474        Subsequently clicking and dragging a Turtle will move it
     3475        across the screen thereby producing handdrawings (if pen is
     3476        down).
    34793477        """
    34803478        self.screen._ondrag(self.turtle._item, fun, btn, add)
     
    35233521        Example (for a Turtle instance named turtle):
    35243522        >>> for i in range(4):
    3525                 turtle.fd(50); turtle.lt(80)
    3526 
     3523        ...     turtle.fd(50); turtle.lt(80)
     3524        ...
    35273525        >>> for i in range(8):
    3528                 turtle.undo()
     3526        ...     turtle.undo()
     3527        ...
    35293528        """
    35303529        if self.undobuffer is None:
     
    36893688
    36903689class Turtle(RawTurtle):
    3691     """RawTurtle auto-crating (scrolled) canvas.
     3690    """RawTurtle auto-creating (scrolled) canvas.
    36923691
    36933692    When a Turtle object is created or a function derived from some
     
    37293728                default value is turtle_docstringdict
    37303729
    3731     Has to be called explicitely, (not used by the turtle-graphics classes)
     3730    Has to be called explicitly, (not used by the turtle-graphics classes)
    37323731    The docstring dictionary will be written to the Python script <filname>.py
    37333732    It is intended to serve as a template for translation of the docstrings
Note: See TracChangeset for help on using the changeset viewer.