Changeset 391 for python/trunk/Lib/lib-tk
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 9 edited
- 15 copied
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/lib-tk/FileDialog.py
r2 r391 108 108 109 109 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: 111 111 self.directory, pattern = dialogstates[key] 112 112 else: -
python/trunk/Lib/lib-tk/FixTk.py
r2 r391 20 20 else: 21 21 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") 24 24 hdir = ctypes.windll.kernel32.\ 25 CreateFileW( s, 0x80,# FILE_READ_ATTRIBUTES25 CreateFileW(udir, 0x80, # FILE_READ_ATTRIBUTES 26 26 1, # FILE_SHARE_READ 27 27 None, 3, # OPEN_EXISTING … … 39 39 # Conversion failed (e.g. network location) 40 40 return s 41 s = buf[:res] 41 s = buf[:res].encode("mbcs") 42 42 # Ignore leading \\?\ 43 if s.startswith( u"\\\\?\\"):43 if s.startswith("\\\\?\\"): 44 44 s = s[4:] 45 if s.startswith("UNC"): 46 s = "\\" + s[3:] 45 47 return s 46 48 … … 53 55 if os.path.exists(prefix): 54 56 prefix = convert_path(prefix) 55 if not os.environ.has_key("TCL_LIBRARY"):57 if "TCL_LIBRARY" not in os.environ: 56 58 for name in os.listdir(prefix): 57 59 if name.startswith("tcl"): … … 63 65 import _tkinter 64 66 ver = str(_tkinter.TCL_VERSION) 65 if not os.environ.has_key("TK_LIBRARY"):67 if "TK_LIBRARY" not in os.environ: 66 68 v = os.path.join(prefix, 'tk'+ver) 67 69 if os.path.exists(os.path.join(v, "tclIndex")): … … 69 71 # We don't know the Tix version, so we must search the entire 70 72 # directory 71 if not os.environ.has_key("TIX_LIBRARY"):73 if "TIX_LIBRARY" not in os.environ: 72 74 for name in os.listdir(prefix): 73 75 if name.startswith("tix"): -
python/trunk/Lib/lib-tk/ScrolledText.py
r2 r391 28 28 self.vbar['command'] = self.yview 29 29 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() 31 33 methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() 34 methods = set(methods).difference(text_meths) 32 35 33 36 for m in methods: -
python/trunk/Lib/lib-tk/Tix.py
r2 r391 1 1 # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*- 2 2 # 3 # $Id : Tix.py 72279 2009-05-04 16:06:12Z walter.doerwald$3 # $Id$ 4 4 # 5 5 # Tix.py -- Tix widget wrappers. … … 46 46 AUTO = 'auto' 47 47 ACROSSTOP = 'acrosstop' 48 49 # A few useful constants for the Grid widget 50 ASCII = 'ascii' 51 CELL = 'cell' 52 COLUMN = 'column' 53 DECREASING = 'decreasing' 54 INCREASING = 'increasing' 55 INTEGER = 'integer' 56 MAIN = 'main' 57 MAX = 'max' 58 REAL = 'real' 59 ROW = 'row' 60 S_REGION = 's-region' 61 X_REGION = 'x-region' 62 Y_REGION = 'y-region' 48 63 49 64 # Some constants used by Tkinter dooneevent() … … 149 164 depth of the X display: xbm images are chosen on monochrome 150 165 displays and color images are chosen on color displays. By using 151 tix_ getimage, you can a dvoid hard coding the pathnames of the166 tix_ getimage, you can avoid hard coding the pathnames of the 152 167 image files in your application. When successful, this command 153 168 returns the name of the newly created image, which can be used to … … 157 172 158 173 def tix_option_get(self, name): 159 """Gets the options ma nitained by the Tix174 """Gets the options maintained by the Tix 160 175 scheme mechanism. Available options include: 161 176 … … 322 337 # Button class if you go through the proper constructors 323 338 def __getattr__(self, name): 324 if self.subwidget_list.has_key(name):339 if name in self.subwidget_list: 325 340 return self.subwidget_list[name] 326 341 raise AttributeError, name … … 391 406 options = () 392 407 for k, v in cnf.items(): 393 if callable(v):408 if hasattr(v, '__call__'): 394 409 v = self._register(v) 395 410 options = options + ('-'+k, v) … … 450 465 # in Tkinter when it finally calls Tcl to destroy the NoteBook 451 466 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: 453 468 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: 455 470 del self.master.subwidget_list[self._name] 456 471 if self.destroy_physically: … … 474 489 def __init__(self, itemtype, cnf={}, **kw): 475 490 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'] 478 493 elif not master: raise RuntimeError, "Too early to create display style: no root window" 479 494 self.tk = master.tk … … 557 572 558 573 def invoke(self, name): 559 if self.subwidget_list.has_key(name):574 if name in self.subwidget_list: 560 575 self.tk.call(self._w, 'invoke', name) 561 576 562 577 class ComboBox(TixWidget): 563 578 """ComboBox - an Entry field with a dropdown menu. The user can select a 564 choice by either typing in the entry subw dget or selecting from the579 choice by either typing in the entry subwidget or selecting from the 565 580 listbox subwidget. 566 581 … … 851 866 pass 852 867 853 class HList(TixWidget ):868 class HList(TixWidget, XView, YView): 854 869 """HList - Hierarchy display widget can be used to display any data 855 870 that have a hierarchical structure, for example, file system directory 856 871 trees. The list entries are indented and connected by branch lines 857 according to their places in the hiera chy.872 according to their places in the hierarchy. 858 873 859 874 Subwidgets - None""" … … 962 977 return self.tk.call(self._w, 'info', 'anchor') 963 978 979 def info_bbox(self, entry): 980 return self._getints( 981 self.tk.call(self._w, 'info', 'bbox', entry)) or None 982 964 983 def info_children(self, entry=None): 965 984 c = self.tk.call(self._w, 'info', 'children', entry) … … 968 987 def info_data(self, entry): 969 988 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') 970 995 971 996 def info_exists(self, entry): … … 1038 1063 return self.tk.call(self._w, 'show', 'entry', entry) 1039 1064 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 1046 1065 class InputOnly(TixWidget): 1047 1066 """InputOnly - Invisible widget. Unix only. … … 1183 1202 1184 1203 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) 1186 1206 self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton') 1187 1207 self.subwidget_list['menu'] = _dummyMenu(self, 'menu') … … 1242 1262 1243 1263 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] 1249 1266 1250 1267 class PopupMenu(TixWidget): … … 1417 1434 1418 1435 def invoke(self, name): 1419 if self.subwidget_list.has_key(name):1436 if name in self.subwidget_list: 1420 1437 self.tk.call(self._w, 'invoke', name) 1421 1438 1422 class TList(TixWidget ):1439 class TList(TixWidget, XView, YView): 1423 1440 """TList - Hierarchy display widget which can be 1424 1441 used to display data in a tabular format. The list entries of a TList … … 1503 1520 self.tk.call(self._w, 'selection', 'set', first, last) 1504 1521 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 1511 1522 class Tree(TixWidget): 1512 """Tree - The tixTree widget can be used to display hiera chical1523 """Tree - The tixTree widget can be used to display hierarchical 1513 1524 data in a tree form. The user can adjust 1514 1525 the view of the tree by opening or closing parts of the tree.""" … … 1564 1575 def __init__(self, master=None, cnf={}, **kw): 1565 1576 TixWidget.__init__(self, master, 'tixCheckList', 1566 ['options' ], cnf, kw)1577 ['options', 'radio'], cnf, kw) 1567 1578 self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') 1568 1579 self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') … … 1778 1789 1779 1790 1780 class Grid(TixWidget ):1791 class Grid(TixWidget, XView, YView): 1781 1792 '''The Tix Grid command creates a new window and makes it into a 1782 1793 tixGrid widget. Additional options, may be specified on the command … … 1802 1813 1803 1814 # 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 1808 1822 def anchor_get(self): 1809 1823 "Get the (x,y) coordinate of the current anchor cell" 1810 1824 return self._getints(self.tk.call(self, 'anchor', 'get')) 1811 1825 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 1814 1830 def delete_row(self, from_, to=None): 1815 1831 """Delete rows between from_ and to inclusive. … … 1819 1835 else: 1820 1836 self.tk.call(self, 'delete', 'row', from_, to) 1837 1821 1838 def delete_column(self, from_, to=None): 1822 1839 """Delete columns between from_ and to inclusive. … … 1826 1843 else: 1827 1844 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) 1830 1855 1831 1856 def entrycget(self, x, y, option): 1832 1857 "Get the option value for cell at (x,y)" 1858 if option and option[0] != '-': 1859 option = '-' + option 1833 1860 return self.tk.call(self, 'entrycget', x, y, option) 1834 1861 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 1837 1865 # def format 1838 1866 # def index … … 1840 1868 def info_exists(self, x, y): 1841 1869 "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)) 1843 1871 1844 1872 def info_bbox(self, x, y): 1845 1873 # This seems to always return '', at least for 'text' displayitems 1846 1874 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) 1847 1887 1848 1888 def nearest(self, x, y): … … 1855 1895 # def selection set 1856 1896 # def selection toggle 1857 # def move dim from to offset1858 1897 1859 1898 def set(self, x, y, itemtype=None, **kw): … … 1863 1902 self.tk.call(self, 'set', x, y, *args) 1864 1903 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 1883 1959 1884 1960 class ScrolledGrid(Grid): -
python/trunk/Lib/lib-tk/Tkinter.py
r2 r391 31 31 """ 32 32 33 __version__ = "$Revision: 73770$"33 __version__ = "$Revision: 81008 $" 34 34 35 35 import sys … … 42 42 from types import * 43 43 from Tkconstants import * 44 import re 44 45 45 46 wantobjects = 1 … … 58 59 except AttributeError: _tkinter.deletefilehandler = None 59 60 61 62 _magic_re = re.compile(r'([\\{}])') 63 _space_re = re.compile(r'([\s])') 64 65 def _join(value): 66 """Internal function.""" 67 return ' '.join(map(_stringify, value)) 68 69 def _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 60 92 61 93 def _flatten(tuple): … … 155 187 pass 156 188 157 def _exit(code='0'): 158 """Internal function. Calling it will throw the exception SystemExit.""" 189 def _exit(code=0): 190 """Internal function. Calling it will raise the exception SystemExit.""" 191 try: 192 code = int(code) 193 except ValueError: 194 pass 159 195 raise SystemExit, code 160 196 … … 535 571 The type keyword specifies the form in which the data is 536 572 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. 538 575 539 576 This command is equivalent to: … … 541 578 selection_get(CLIPBOARD) 542 579 """ 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'] 543 586 return self.tk.call(('clipboard', 'get') + self._options(kw)) 544 587 … … 548 591 A widget specified for the optional displayof keyword 549 592 argument specifies the target display.""" 550 if not kw.has_key('displayof'): kw['displayof'] = self._w593 if 'displayof' not in kw: kw['displayof'] = self._w 551 594 self.tk.call(('clipboard', 'clear') + self._options(kw)) 552 595 def clipboard_append(self, string, **kw): … … 556 599 argument specifies the target display. The clipboard 557 600 can be retrieved with selection_get.""" 558 if not kw.has_key('displayof'): kw['displayof'] = self._w601 if 'displayof' not in kw: kw['displayof'] = self._w 559 602 self.tk.call(('clipboard', 'append') + self._options(kw) 560 603 + ('--', string)) … … 614 657 def selection_clear(self, **kw): 615 658 """Clear the current X selection.""" 616 if not kw.has_key('displayof'): kw['displayof'] = self._w659 if 'displayof' not in kw: kw['displayof'] = self._w 617 660 self.tk.call(('selection', 'clear') + self._options(kw)) 618 661 def selection_get(self, **kw): … … 622 665 the selection and defaults to PRIMARY. A keyword 623 666 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'] 626 677 return self.tk.call(('selection', 'get') + self._options(kw)) 627 678 def selection_handle(self, command, **kw): … … 654 705 selection - name of the selection (default PRIMARY), 655 706 type - type of the selection (e.g. STRING, FILE_NAME).""" 656 if not kw.has_key('displayof'): kw['displayof'] = self._w707 if 'displayof' not in kw: kw['displayof'] = self._w 657 708 name = self.tk.call(('selection', 'own') + self._options(kw)) 658 709 if not name: return None … … 1038 1089 return ('-displayof', self._w) 1039 1090 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 1040 1100 def _options(self, cnf, kw = None): 1041 1101 """Internal function.""" … … 1048 1108 if v is not None: 1049 1109 if k[-1] == '_': k = k[:-1] 1050 if callable(v):1110 if hasattr(v, '__call__'): 1051 1111 v = self._register(v) 1052 1112 elif isinstance(v, (tuple, list)): … … 1059 1119 else: 1060 1120 # 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)) 1062 1122 else: 1063 1123 v = ' '.join(nv) … … 1288 1348 if not value: 1289 1349 value = None 1290 elif '.' in value:1350 elif '.' in str(value): 1291 1351 value = getdouble(value) 1292 1352 else: … … 1413 1473 except: 1414 1474 self.widget._report_exception() 1475 1476 1477 class 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 1498 class 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) 1415 1517 1416 1518 … … 1619 1721 class Tk(Misc, Wm): 1620 1722 """Toplevel widget of Tk which represents mostly the main window 1621 of an appli ation. It has an associated Tcl interpreter."""1723 of an application. It has an associated Tcl interpreter.""" 1622 1724 _w = '.' 1623 1725 def __init__(self, screenName=None, baseName=None, className='Tk', … … 1635 1737 self.tk = None 1636 1738 if baseName is None: 1637 import sys,os1739 import os 1638 1740 baseName = os.path.basename(sys.argv[0]) 1639 1741 baseName, ext = os.path.splitext(baseName) … … 1644 1746 if useTk: 1645 1747 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) 1647 1751 def loadtk(self): 1648 1752 if not self._tkloaded: … … 1694 1798 such a file exists in the home directory.""" 1695 1799 import os 1696 if os.environ.has_key('HOME'): home = os.environ['HOME']1800 if 'HOME' in os.environ: home = os.environ['HOME'] 1697 1801 else: home = os.curdir 1698 1802 class_tcl = os.path.join(home, '.%s.tcl' % className) … … 1777 1881 key = words[i][1:] 1778 1882 value = words[i+1] 1779 if value[:1] == '.':1883 if str(value)[:1] == '.': 1780 1884 value = self._nametowidget(value) 1781 1885 dict[key] = value … … 1828 1932 key = words[i][1:] 1829 1933 value = words[i+1] 1830 if value[:1] == '.':1934 if str(value)[:1] == '.': 1831 1935 value = self._nametowidget(value) 1832 1936 dict[key] = value … … 1877 1981 key = words[i][1:] 1878 1982 value = words[i+1] 1879 if value[:1] == '.':1983 if str(value)[:1] == '.': 1880 1984 value = self._nametowidget(value) 1881 1985 dict[key] = value … … 1901 2005 self.tk = master.tk 1902 2006 name = None 1903 if cnf.has_key('name'):2007 if 'name' in cnf: 1904 2008 name = cnf['name'] 1905 2009 del cnf['name'] … … 1912 2016 self._w = master._w + '.' + name 1913 2017 self.children = {} 1914 if self. master.children.has_key(self._name):2018 if self._name in self.master.children: 1915 2019 self.master.children[self._name].destroy() 1916 2020 self.master.children[self._name] = self … … 1937 2041 for c in self.children.values(): c.destroy() 1938 2042 self.tk.call('destroy', self._w) 1939 if self. master.children.has_key(self._name):2043 if self._name in self.master.children: 1940 2044 del self.master.children[self._name] 1941 2045 Misc.destroy(self) … … 1965 2069 for wmkey in ['screen', 'class_', 'class', 'visual', 1966 2070 'colormap']: 1967 if cnf.has_key(wmkey):2071 if wmkey in cnf: 1968 2072 val = cnf[wmkey] 1969 2073 # TBD: a hack needed because some keys … … 2058 2162 return '@%r,%r' % (x, y) 2059 2163 2060 class Canvas(Widget ):2164 class Canvas(Widget, XView, YView): 2061 2165 """Canvas widget to display graphical elements like lines or text.""" 2062 2166 def __init__(self, master=None, cnf={}, **kw): … … 2298 2402 """Return the type of the item TAGORID.""" 2299 2403 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 the2307 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 the2319 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)2324 2404 2325 2405 class Checkbutton(Widget): … … 2352 2432 self.tk.call(self._w, 'toggle') 2353 2433 2354 class Entry(Widget ):2434 class Entry(Widget, XView): 2355 2435 """Entry widget which allows to display simple text.""" 2356 2436 def __init__(self, master=None, cnf={}, **kw): … … 2403 2483 select_from = selection_from 2404 2484 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.""" 2406 2487 return self.tk.getboolean( 2407 2488 self.tk.call(self._w, 'selection', 'present')) … … 2415 2496 self.tk.call(self._w, 'selection', 'to', index) 2416 2497 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 the2422 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)2427 2498 2428 2499 class Frame(Widget): … … 2436 2507 cnf = _cnfmerge((cnf, kw)) 2437 2508 extra = () 2438 if cnf.has_key('class_'):2509 if 'class_' in cnf: 2439 2510 extra = ('-class', cnf['class_']) 2440 2511 del cnf['class_'] 2441 elif cnf.has_key('class'):2512 elif 'class' in cnf: 2442 2513 extra = ('-class', cnf['class']) 2443 2514 del cnf['class'] … … 2466 2537 Widget.__init__(self, master, 'label', cnf, kw) 2467 2538 2468 class Listbox(Widget ):2539 class Listbox(Widget, XView, YView): 2469 2540 """Listbox widget which can display a list of strings.""" 2470 2541 def __init__(self, master=None, cnf={}, **kw): … … 2545 2616 """Return the number of elements in the listbox.""" 2546 2617 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 the2554 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 the2566 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)2571 2618 def itemcget(self, index, option): 2572 2619 """Return the resource value for an ITEM and an OPTION.""" … … 2815 2862 2816 2863 2817 class Text(Widget ):2864 class Text(Widget, XView, YView): 2818 2865 """Text widget which can display text in various forms.""" 2819 2866 def __init__(self, master=None, cnf={}, **kw): … … 3137 3184 return self.tk.splitlist( 3138 3185 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 the3146 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 measured3150 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 the3159 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 measured3163 in "units" or "pages" (WHAT)."""3164 self.tk.call(self._w, 'yview', 'scroll', number, what)3165 3186 def yview_pickplace(self, *what): 3166 3187 """Obsolete function, use see.""" … … 3195 3216 # 'command' is the only supported keyword 3196 3217 callback = kwargs.get('command') 3197 if kwargs.has_key('command'):3218 if 'command' in kwargs: 3198 3219 del kwargs['command'] 3199 3220 if kwargs: … … 3236 3257 options = () 3237 3258 for k, v in cnf.items(): 3238 if callable(v):3259 if hasattr(v, '__call__'): 3239 3260 v = self._register(v) 3240 3261 options = options + ('-'+k, v) … … 3259 3280 if v is not None: 3260 3281 if k[-1] == '_': k = k[:-1] 3261 if callable(v):3282 if hasattr(v, '__call__'): 3262 3283 v = self._register(v) 3263 3284 res = res + ('-'+k, v) … … 3348 3369 3349 3370 3350 class Spinbox(Widget ):3371 class Spinbox(Widget, XView): 3351 3372 """spinbox widget.""" 3352 3373 def __init__(self, master=None, cnf={}, **kw): … … 3551 3572 The child argument is the name of the child widget 3552 3573 followed by pairs of arguments that specify how to 3553 manage the windows. Options may have any of thevalues3554 a ccepted by the configure subcommand.3574 manage the windows. The possible options and values 3575 are the ones accepted by the paneconfigure method. 3555 3576 """ 3556 3577 self.tk.call((self._w, 'add', child) + self._options(kw)) -
python/trunk/Lib/lib-tk/tkMessageBox.py
r2 r391 71 71 if message: options["message"] = message 72 72 res = Message(**options).show() 73 # In some Tcl installations, Tcl converts yes/no into a boolean73 # In some Tcl installations, yes/no is converted into a boolean. 74 74 if isinstance(res, bool): 75 if res: return YES 75 if res: 76 return YES 76 77 return NO 77 return res 78 # In others we get a Tcl_Obj. 79 return str(res) 78 80 79 81 def showinfo(title=None, message=None, **options): -
python/trunk/Lib/lib-tk/tkSimpleDialog.py
r2 r391 47 47 Toplevel.__init__(self, parent) 48 48 49 self.withdraw() # remain invisible for now 49 50 # If the master is not viewable, don't 50 51 # make the child transient, or else it … … 66 67 self.buttonbox() 67 68 68 self.wait_visibility() # window needs to be visible for the grab69 self.grab_set()70 69 71 70 if not self.initial_focus: … … 78 77 parent.winfo_rooty()+50)) 79 78 79 self.deiconify() # become visibile now 80 80 81 self.initial_focus.focus_set() 81 82 83 # wait for window to appear on screen before calling grab_set 84 self.wait_visibility() 85 self.grab_set() 82 86 self.wait_window(self) 83 87 … … 197 201 self.entry.grid(row=1, padx=5, sticky=W+E) 198 202 199 if self.initialvalue :203 if self.initialvalue is not None: 200 204 self.entry.insert(0, self.initialvalue) 201 205 self.entry.select_range(0, END) … … 280 284 class _QueryString(_QueryDialog): 281 285 def __init__(self, *args, **kw): 282 if kw.has_key("show"):286 if "show" in kw: 283 287 self.__show = kw["show"] 284 288 del kw["show"] -
python/trunk/Lib/lib-tk/turtle.py
r2 r391 3 3 # Version 1.0.1 - 24. 9. 2009 4 4 # 5 # Copyright (C) 2006 - 20 09Gregor Lingl5 # Copyright (C) 2006 - 2010 Gregor Lingl 6 6 # email: glingl@aon.at 7 7 # … … 28 28 by Wally Feurzig and Seymour Papert in 1966. 29 29 30 Imagine a robotic turtle starting at (0, 0) in the x-y plane. Give it30 Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it 31 31 the command turtle.forward(15), and it moves (on-screen!) 15 pixels in 32 32 the 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.33 command turtle.right(25), and it rotates in-place 25 degrees clockwise. 34 34 35 35 By combining together these and similar commands, intricate shapes and … … 97 97 98 98 Behind the scenes there are some features included with possible 99 extensions in inmind. These will be commented and documented elsewhere.99 extensions in mind. These will be commented and documented elsewhere. 100 100 101 101 """ … … 336 336 del _dict[ex] 337 337 for ex in exclude: 338 if _dict.has_key(ex):338 if ex in _dict: 339 339 del _dict[ex] 340 340 for ex in __methods(fromClass): 341 if _dict.has_key(ex):341 if ex in _dict: 342 342 del _dict[ex] 343 343 … … 784 784 if not isinstance(self.cv, ScrolledCanvas): 785 785 return self.canvwidth, self.canvheight 786 if canvwidth is None and canvheight is None andbg is None:786 if canvwidth is canvheight is bg is None: 787 787 return self.cv.canvwidth, self.cv.canvheight 788 788 if canvwidth is not None: … … 812 812 """Will be raised in TurtleScreen.update, if _RUNNING becomes False. 813 813 814 Th us stops execution of turtle graphics script. Main purpose: use in815 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. 816 816 """ 817 817 pass … … 860 860 >>> s = Shape("compound") 861 861 >>> s.addcomponent(poly, "red", "blue") 862 ### .. add more components and then use register_shape()862 >>> # .. add more components and then use register_shape() 863 863 """ 864 864 if self._type != "compound": … … 959 959 960 960 Example (for a TurtleScreen instance named screen): 961 screen.clear()961 >>> screen.clear() 962 962 963 963 Note: this method is not available as function. … … 1000 1000 'logo' 1001 1001 """ 1002 if mode ==None:1002 if mode is None: 1003 1003 return self._mode 1004 1004 mode = mode.lower() … … 1031 1031 >>> screen.setworldcoordinates(-10,-0.5,50,1.5) 1032 1032 >>> for _ in range(36): 1033 1034 1033 ... left(10) 1034 ... forward(0.5) 1035 1035 """ 1036 1036 if self.mode() != "world": … … 1137 1137 1.0 1138 1138 >>> screen.colormode(255) 1139 >>> turtle.pencolor(240,160,80)1139 >>> pencolor(240,160,80) 1140 1140 """ 1141 1141 if cmode is None: … … 1205 1205 >>> dist = 2 1206 1206 >>> for i in range(200): 1207 1208 1209 1207 ... fd(dist) 1208 ... rt(90) 1209 ... dist += 2 1210 1210 """ 1211 1211 if n is None: … … 1234 1234 1235 1235 def _incrementudc(self): 1236 " Increment upadate counter."""1236 """Increment update counter.""" 1237 1237 if not TurtleScreen._RUNNING: 1238 1238 TurtleScreen._RUNNNING = True … … 1305 1305 and a Turtle instance named turtle): 1306 1306 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. 1311 1310 >>> screen.onclick(None) 1312 1313 ### event-binding will be removed1314 1311 """ 1315 1312 self._onscreenclick(fun, btn, add) … … 1325 1322 must have focus. (See method listen.) 1326 1323 1327 Example (for a TurtleScreen instance named screen 1328 and a Turtle instance named turtle): 1324 Example (for a TurtleScreen instance named screen): 1329 1325 1330 1326 >>> def f(): 1331 fd(50) 1332 lt(60) 1333 1334 1327 ... fd(50) 1328 ... lt(60) 1329 ... 1335 1330 >>> screen.onkey(f, "Up") 1336 1331 >>> screen.listen() 1337 1332 1338 ### Subsequently the turtle can be moved by1339 ### 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: 1343 1338 if key in self._keys: 1344 1339 self._keys.remove(key) … … 1370 1365 >>> running = True 1371 1366 >>> def f(): 1372 1373 1374 1375 1376 1377 >>> f() # ##makes the turtle marching around1367 ... if running: 1368 ... fd(50) 1369 ... lt(60) 1370 ... screen.ontimer(f, 250) 1371 ... 1372 >>> f() # makes the turtle marching around 1378 1373 >>> running = False 1379 1374 """ … … 1386 1381 picname -- a string, name of a gif-file or "nopic". 1387 1382 1388 If picname is a filename, set the correspon ing image as background.1383 If picname is a filename, set the corresponding image as background. 1389 1384 If picname is "nopic", delete backgroundimage, if present. 1390 1385 If picname is None, return the filename of the current backgroundimage. … … 1410 1405 canvwidth -- positive integer, new width of canvas in pixels 1411 1406 canvheight -- positive integer, new height of canvas in pixels 1412 bg -- colorstring or color-tup el, new backgroundcolor1407 bg -- colorstring or color-tuple, new backgroundcolor 1413 1408 If no arguments are given, return current (canvaswidth, canvasheight) 1414 1409 … … 1419 1414 Example (for a Turtle instance named turtle): 1420 1415 >>> turtle.screensize(2000,1500) 1421 ### e. g. to search for an erroneously escaped turtle ;-)1416 >>> # e. g. to search for an erroneously escaped turtle ;-) 1422 1417 """ 1423 1418 return self._resize(canvwidth, canvheight, bg) … … 1461 1456 """Set turtle-mode to 'standard', 'world' or 'logo'. 1462 1457 """ 1463 if mode ==None:1458 if mode is None: 1464 1459 return self._mode 1465 1460 if mode not in ["standard", "logo", "world"]: … … 1496 1491 >>> turtle.heading() 1497 1492 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) 1499 1497 >>> turtle.heading() 1500 1498 100 … … 2002 2000 >>> turtle.pensize() 2003 2001 1 2004 turtle.pensize(10) # from here on lines of width 10 are drawn2002 >>> turtle.pensize(10) # from here on lines of width 10 are drawn 2005 2003 """ 2006 2004 if width is None: … … 2442 2440 RawTurtle.screens.append(self.screen) 2443 2441 else: 2444 raise TurtleGraphicsError("bad ca vas argument %s" % canvas)2442 raise TurtleGraphicsError("bad canvas argument %s" % canvas) 2445 2443 2446 2444 screen = self.screen … … 2514 2512 Example (for a Turtle instance named turtle): 2515 2513 >>> while undobufferentries(): 2516 2514 ... undo() 2517 2515 """ 2518 2516 if self.undobuffer is None: … … 2590 2588 >>> dist = 2 2591 2589 >>> for i in range(200): 2592 2593 2594 2590 ... turtle.fd(dist) 2591 ... turtle.rt(90) 2592 ... dist += 2 2595 2593 """ 2596 2594 return self.screen.tracer(flag, delay) … … 2687 2685 """Set/return turtle's stretchfactors/outline. Set resizemode to "user". 2688 2686 2689 Opti nonal arguments:2687 Optional arguments: 2690 2688 stretch_wid : positive number 2691 2689 stretch_len : positive number … … 2705 2703 >>> turtle.shapesize(outline=8) 2706 2704 """ 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: 2708 2706 stretch_wid, stretch_len = self._stretchfactor 2709 2707 return stretch_wid, stretch_len, self._outlinewidth … … 2761 2759 >>> turtle.tilt(45) 2762 2760 >>> turtle.tiltangle() 2763 >>>2764 2761 """ 2765 2762 tilt = -self._tilt * (180.0/math.pi) * self._angleOrient … … 2961 2958 Example (for a Turtle instance named turtle): 2962 2959 >>> for i in range(8): 2963 2960 ... turtle.stamp(); turtle.fd(30) 2964 2961 ... 2965 2962 >>> turtle.clearstamps(2) … … 2979 2976 def _goto(self, end): 2980 2977 """Move the pen to the point end, thereby drawing a line 2981 if pen is down. All other method es for turtle movement depend2978 if pen is down. All other methods for turtle movement depend 2982 2979 on this one. 2983 2980 """ … … 3077 3074 # Turtle now at position old, 3078 3075 self._position = old 3079 ## if undo is done during cr ating a polygon, the last vertex3080 ## will be deleted. if the polygon is entirel deleted,3081 ## creati gPoly 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. 3082 3079 ## Polygons created before the last one will not be affected by undo() 3083 3080 if self._creatingPoly: … … 3219 3216 """Draw a dot with diameter size, using color. 3220 3217 3221 Optional argument S:3218 Optional arguments: 3222 3219 size -- an integer >= 1 (if given) 3223 3220 color -- a colorstring or a numeric color tuple … … 3428 3425 3429 3426 >>> def turn(x, y): 3430 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. 3433 3430 >>> onclick(None) # event-binding will be removed 3434 3431 """ … … 3446 3443 Example (for a MyTurtle instance named joe): 3447 3444 >>> class MyTurtle(Turtle): 3448 3449 3450 3451 3452 3445 ... def glow(self,x,y): 3446 ... self.fillcolor("red") 3447 ... def unglow(self,x,y): 3448 ... self.fillcolor("") 3449 ... 3453 3450 >>> joe = MyTurtle() 3454 3451 >>> joe.onclick(joe.glow) 3455 3452 >>> 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. 3458 3456 """ 3459 3457 self.screen._onrelease(self.turtle._item, fun, btn, add) … … 3474 3472 >>> turtle.ondrag(turtle.goto) 3475 3473 3476 ### Subsequently clicking and dragging a Turtle will3477 ### move it across the screen thereby producing handdrawings3478 ### (if pen isdown).3474 Subsequently clicking and dragging a Turtle will move it 3475 across the screen thereby producing handdrawings (if pen is 3476 down). 3479 3477 """ 3480 3478 self.screen._ondrag(self.turtle._item, fun, btn, add) … … 3523 3521 Example (for a Turtle instance named turtle): 3524 3522 >>> for i in range(4): 3525 3526 3523 ... turtle.fd(50); turtle.lt(80) 3524 ... 3527 3525 >>> for i in range(8): 3528 turtle.undo() 3526 ... turtle.undo() 3527 ... 3529 3528 """ 3530 3529 if self.undobuffer is None: … … 3689 3688 3690 3689 class Turtle(RawTurtle): 3691 """RawTurtle auto-cr ating (scrolled) canvas.3690 """RawTurtle auto-creating (scrolled) canvas. 3692 3691 3693 3692 When a Turtle object is created or a function derived from some … … 3729 3728 default value is turtle_docstringdict 3730 3729 3731 Has to be called explicit ely, (not used by the turtle-graphics classes)3730 Has to be called explicitly, (not used by the turtle-graphics classes) 3732 3731 The docstring dictionary will be written to the Python script <filname>.py 3733 3732 It is intended to serve as a template for translation of the docstrings
Note:
See TracChangeset
for help on using the changeset viewer.