| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f290cb5 commit bcd03df
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,8 +27,11 @@ def __init__(self, master=None, **kw): | |||
| 27 | 27 | self.pack(side=LEFT, fill=BOTH, expand=True) | |
| 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: | |
| 34 | 37 | if m[0] != '_' and m != 'config' and m != 'configure': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,21 @@ | |||
| 46 | 46 | AUTO = 'auto' | |
| 47 | 47 | ACROSSTOP = 'acrosstop' | |
| 48 | 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' | ||
| 63 | + | ||
| 49 | 64 | # Some constants used by Tkinter dooneevent() | |
| 50 | 65 | TCL_DONT_WAIT = 1 << 1 | |
| 51 | 66 | TCL_WINDOW_EVENTS = 1 << 2 | |
@@ -961,13 +976,23 @@ def indicator_size(self, entry): | |||
| 961 | 976 | def info_anchor(self): | |
| 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) | |
| 966 | 985 | return self.tk.splitlist(c) | |
| 967 | 986 | ||
| 968 | 987 | def info_data(self, entry): | |
| 969 | 988 | return self.tk.call(self._w, 'info', 'data', entry) | |
| 970 | 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') | ||
| 995 | + | ||
| 971 | 996 | def info_exists(self, entry): | |
| 972 | 997 | return self.tk.call(self._w, 'info', 'exists', entry) | |
| 973 | 998 | ||
@@ -1235,11 +1260,8 @@ def paneconfigure(self, entry, cnf={}, **kw): | |||
| 1235 | 1260 | self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw)) | |
| 1236 | 1261 | ||
| 1237 | 1262 | def panes(self): | |
| 1238 | - names = self.tk.call(self._w, 'panes') | ||
| 1239 | - ret = [] | ||
| 1240 | - for x in names: | ||
| 1241 | - ret.append(self.subwidget(x)) | ||
| 1242 | - return ret | ||
| 1263 | + names = self.tk.splitlist(self.tk.call(self._w, 'panes')) | ||
| 1264 | + return [self.subwidget(x) for x in names] | ||
| 1243 | 1265 | ||
| 1244 | 1266 | class PopupMenu(TixWidget): | |
| 1245 | 1267 | """PopupMenu widget can be used as a replacement of the tk_popup command. | |
@@ -1551,7 +1573,7 @@ class CheckList(TixWidget): | |||
| 1551 | 1573 | # FIXME: It should inherit -superclass tixTree | |
| 1552 | 1574 | def __init__(self, master=None, cnf={}, **kw): | |
| 1553 | 1575 | TixWidget.__init__(self, master, 'tixCheckList', | |
| 1554 | - ['options'], cnf, kw) | ||
| 1576 | + ['options', 'radio'], cnf, kw) | ||
| 1555 | 1577 | self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') | |
| 1556 | 1578 | self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') | |
| 1557 | 1579 | self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | |
@@ -1789,50 +1811,79 @@ def __init__(self, master=None, cnf={}, **kw): | |||
| 1789 | 1811 | TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw) | |
| 1790 | 1812 | ||
| 1791 | 1813 | # valid options as of Tk 8.4 | |
| 1792 | - # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, edit | ||
| 1793 | - # entryconfigure, format, geometryinfo, info, index, move, nearest, selection | ||
| 1794 | - # set, size, unset, xview, yview | ||
| 1795 | - # def anchor option ?args ...? | ||
| 1814 | + # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, | ||
| 1815 | + # edit, entryconfigure, format, geometryinfo, info, index, move, nearest, | ||
| 1816 | + # selection, set, size, unset, xview, yview | ||
| 1817 | + def anchor_clear(self): | ||
| 1818 | + """Removes the selection anchor.""" | ||
| 1819 | + self.tk.call(self, 'anchor', 'clear') | ||
| 1820 | + | ||
| 1796 | 1821 | def anchor_get(self): | |
| 1797 | 1822 | "Get the (x,y) coordinate of the current anchor cell" | |
| 1798 | 1823 | return self._getints(self.tk.call(self, 'anchor', 'get')) | |
| 1799 | 1824 | ||
| 1800 | - # def bdtype | ||
| 1801 | - # def delete dim from ?to? | ||
| 1825 | + def anchor_set(self, x, y): | ||
| 1826 | + """Set the selection anchor to the cell at (x, y).""" | ||
| 1827 | + self.tk.call(self, 'anchor', 'set', x, y) | ||
| 1828 | + | ||
| 1802 | 1829 | def delete_row(self, from_, to=None): | |
| 1803 | 1830 | """Delete rows between from_ and to inclusive. | |
| 1804 | 1831 | If to is not provided, delete only row at from_""" | |
| 1805 | 1832 | if to is None: | |
| 1806 | 1833 | self.tk.call(self, 'delete', 'row', from_) | |
| 1807 | 1834 | else: | |
| 1808 | 1835 | self.tk.call(self, 'delete', 'row', from_, to) | |
| 1836 | + | ||
| 1809 | 1837 | def delete_column(self, from_, to=None): | |
| 1810 | 1838 | """Delete columns between from_ and to inclusive. | |
| 1811 | 1839 | If to is not provided, delete only column at from_""" | |
| 1812 | 1840 | if to is None: | |
| 1813 | 1841 | self.tk.call(self, 'delete', 'column', from_) | |
| 1814 | 1842 | else: | |
| 1815 | 1843 | self.tk.call(self, 'delete', 'column', from_, to) | |
| 1816 | - # def edit apply | ||
| 1817 | - # def edit set x y | ||
| 1844 | + | ||
| 1845 | + def edit_apply(self): | ||
| 1846 | + """If any cell is being edited, de-highlight the cell and applies | ||
| 1847 | + the changes.""" | ||
| 1848 | + self.tk.call(self, 'edit', 'apply') | ||
| 1849 | + | ||
| 1850 | + def edit_set(self, x, y): | ||
| 1851 | + """Highlights the cell at (x, y) for editing, if the -editnotify | ||
| 1852 | + command returns True for this cell.""" | ||
| 1853 | + self.tk.call(self, 'edit', 'set', x, y) | ||
| 1818 | 1854 | ||
| 1819 | 1855 | def entrycget(self, x, y, option): | |
| 1820 | 1856 | "Get the option value for cell at (x,y)" | |
| 1857 | + if option and option[0] != '-': | ||
| 1858 | + option = '-' + option | ||
| 1821 | 1859 | return self.tk.call(self, 'entrycget', x, y, option) | |
| 1822 | 1860 | ||
| 1823 | - def entryconfigure(self, x, y, **kw): | ||
| 1824 | - return self.tk.call(self, 'entryconfigure', x, y, *self._options(None, kw)) | ||
| 1861 | + def entryconfigure(self, x, y, cnf=None, **kw): | ||
| 1862 | + return self._configure(('entryconfigure', x, y), cnf, kw) | ||
| 1863 | + | ||
| 1825 | 1864 | # def format | |
| 1826 | 1865 | # def index | |
| 1827 | 1866 | ||
| 1828 | 1867 | def info_exists(self, x, y): | |
| 1829 | 1868 | "Return True if display item exists at (x,y)" | |
| 1830 | - return bool(int(self.tk.call(self, 'info', 'exists', x, y))) | ||
| 1869 | + return self._getboolean(self.tk.call(self, 'info', 'exists', x, y)) | ||
| 1831 | 1870 | ||
| 1832 | 1871 | def info_bbox(self, x, y): | |
| 1833 | 1872 | # This seems to always return '', at least for 'text' displayitems | |
| 1834 | 1873 | return self.tk.call(self, 'info', 'bbox', x, y) | |
| 1835 | 1874 | ||
| 1875 | + def move_column(self, from_, to, offset): | ||
| 1876 | + """Moves the the range of columns from position FROM through TO by | ||
| 1877 | + the distance indicated by OFFSET. For example, move_column(2, 4, 1) | ||
| 1878 | + moves the columns 2,3,4 to columns 3,4,5.""" | ||
| 1879 | + self.tk.call(self, 'move', 'column', from_, to, offset) | ||
| 1880 | + | ||
| 1881 | + def move_row(self, from_, to, offset): | ||
| 1882 | + """Moves the the range of rows from position FROM through TO by | ||
| 1883 | + the distance indicated by OFFSET. | ||
| 1884 | + For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5.""" | ||
| 1885 | + self.tk.call(self, 'move', 'row', from_, to, offset) | ||
| 1886 | + | ||
| 1836 | 1887 | def nearest(self, x, y): | |
| 1837 | 1888 | "Return coordinate of cell nearest pixel coordinate (x,y)" | |
| 1838 | 1889 | return self._getints(self.tk.call(self, 'nearest', x, y)) | |
@@ -1842,16 +1893,66 @@ def nearest(self, x, y): | |||
| 1842 | 1893 | # def selection includes | |
| 1843 | 1894 | # def selection set | |
| 1844 | 1895 | # def selection toggle | |
| 1845 | - # def move dim from to offset | ||
| 1846 | 1896 | ||
| 1847 | 1897 | def set(self, x, y, itemtype=None, **kw): | |
| 1848 | 1898 | args= self._options(self.cnf, kw) | |
| 1849 | 1899 | if itemtype is not None: | |
| 1850 | 1900 | args= ('-itemtype', itemtype) + args | |
| 1851 | 1901 | self.tk.call(self, 'set', x, y, *args) | |
| 1852 | 1902 | ||
| 1853 | - # def size dim index ?option value ...? | ||
| 1854 | - # def unset x y | ||
| 1903 | + def size_column(self, index, **kw): | ||
| 1904 | + """Queries or sets the size of the column given by | ||
| 1905 | + INDEX. INDEX may be any non-negative | ||
| 1906 | + integer that gives the position of a given column. | ||
| 1907 | + INDEX can also be the string "default"; in this case, this command | ||
| 1908 | + queries or sets the default size of all columns. | ||
| 1909 | + When no option-value pair is given, this command returns a tuple | ||
| 1910 | + containing the current size setting of the given column. When | ||
| 1911 | + option-value pairs are given, the corresponding options of the | ||
| 1912 | + size setting of the given column are changed. Options may be one | ||
| 1913 | + of the follwing: | ||
| 1914 | + pad0 pixels | ||
| 1915 | + Specifies the paddings to the left of a column. | ||
| 1916 | + pad1 pixels | ||
| 1917 | + Specifies the paddings to the right of a column. | ||
| 1918 | + size val | ||
| 1919 | + Specifies the width of a column . | ||
| 1920 | + Val may be: "auto" -- the width of the column is set the | ||
| 1921 | + the widest cell in the column; a valid Tk screen distance | ||
| 1922 | + unit; or a real number following by the word chars | ||
| 1923 | + (e.g. 3.4chars) that sets the width of the column to the | ||
| 1924 | + given number of characters.""" | ||
| 1925 | + return self.tk.split(self.tk.call(self._w, 'size', 'column', index, | ||
| 1926 | + *self._options({}, kw))) | ||
| 1927 | + | ||
| 1928 | + def size_row(self, index, **kw): | ||
| 1929 | + """Queries or sets the size of the row given by | ||
| 1930 | + INDEX. INDEX may be any non-negative | ||
| 1931 | + integer that gives the position of a given row . | ||
| 1932 | + INDEX can also be the string "default"; in this case, this command | ||
| 1933 | + queries or sets the default size of all rows. | ||
| 1934 | + When no option-value pair is given, this command returns a list con- | ||
| 1935 | + taining the current size setting of the given row . When option-value | ||
| 1936 | + pairs are given, the corresponding options of the size setting of the | ||
| 1937 | + given row are changed. Options may be one of the follwing: | ||
| 1938 | + pad0 pixels | ||
| 1939 | + Specifies the paddings to the top of a row. | ||
| 1940 | + pad1 pixels | ||
| 1941 | + Specifies the paddings to the the bottom of a row. | ||
| 1942 | + size val | ||
| 1943 | + Specifies the height of a row. | ||
| 1944 | + Val may be: "auto" -- the height of the row is set the | ||
| 1945 | + the highest cell in the row; a valid Tk screen distance | ||
| 1946 | + unit; or a real number following by the word chars | ||
| 1947 | + (e.g. 3.4chars) that sets the height of the row to the | ||
| 1948 | + given number of characters.""" | ||
| 1949 | + return self.tk.split(self.tk.call( | ||
| 1950 | + self, 'size', 'row', index, *self._options({}, kw))) | ||
| 1951 | + | ||
| 1952 | + def unset(self, x, y): | ||
| 1953 | + """Clears the cell at (x, y) by removing its display item.""" | ||
| 1954 | + self.tk.call(self._w, 'unset', x, y) | ||
| 1955 | + | ||
| 1855 | 1956 | ||
| 1856 | 1957 | class ScrolledGrid(Grid): | |
| 1857 | 1958 | '''Scrolled Grid widgets''' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,15 @@ C-API | |||
| 65 | 65 | Library | |
| 66 | 66 | ------- | |
| 67 | 67 | ||
| 68 | + - Issue #1356969: Add missing info methods in tix.HList. | ||
| 69 | + | ||
| 70 | + - Issue #1522587: New constants and methods for the tix.Grid widget. | ||
| 71 | + | ||
| 72 | + - Issue #1250469: Fix the return value of tix.PanedWindow.panes. | ||
| 73 | + | ||
| 74 | + - Issue #1119673: Do not override tkinter.Text methods when creating a | ||
| 75 | + ScrolledText. | ||
| 76 | + | ||
| 68 | 77 | - Issue #6665: Fix fnmatch to properly match filenames with newlines in them. | |
| 69 | 78 | ||
| 70 | 79 | - Issue #1135: Add the XView and YView mix-ins to avoid duplicating | |
| Back | FazBrowse Home | New Git URL |
0 commit comments