Changeset 391 for python/trunk/Lib/lib-tk/Tix.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
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/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):
Note:
See TracChangeset
for help on using the changeset viewer.