mirror of https://github.com/python/cpython
Issue #1522587: New constants and methods for the Tix.Grid widget.
This commit is contained in:
parent
57f9b7298a
commit
6b3c7098f3
|
@ -46,6 +46,21 @@ BALLOON = 'balloon'
|
||||||
AUTO = 'auto'
|
AUTO = 'auto'
|
||||||
ACROSSTOP = 'acrosstop'
|
ACROSSTOP = 'acrosstop'
|
||||||
|
|
||||||
|
# A few useful constants for the Grid widget
|
||||||
|
ASCII = 'ascii'
|
||||||
|
CELL = 'cell'
|
||||||
|
COLUMN = 'column'
|
||||||
|
DECREASING = 'decreasing'
|
||||||
|
INCREASING = 'increasing'
|
||||||
|
INTEGER = 'integer'
|
||||||
|
MAIN = 'main'
|
||||||
|
MAX = 'max'
|
||||||
|
REAL = 'real'
|
||||||
|
ROW = 'row'
|
||||||
|
S_REGION = 's-region'
|
||||||
|
X_REGION = 'x-region'
|
||||||
|
Y_REGION = 'y-region'
|
||||||
|
|
||||||
# Some constants used by Tkinter dooneevent()
|
# Some constants used by Tkinter dooneevent()
|
||||||
TCL_DONT_WAIT = 1 << 1
|
TCL_DONT_WAIT = 1 << 1
|
||||||
TCL_WINDOW_EVENTS = 1 << 2
|
TCL_WINDOW_EVENTS = 1 << 2
|
||||||
|
@ -1786,16 +1801,21 @@ class Grid(TixWidget, XView, YView):
|
||||||
TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw)
|
TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw)
|
||||||
|
|
||||||
# valid options as of Tk 8.4
|
# valid options as of Tk 8.4
|
||||||
# anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, edit
|
# anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget,
|
||||||
# entryconfigure, format, geometryinfo, info, index, move, nearest, selection
|
# edit, entryconfigure, format, geometryinfo, info, index, move, nearest,
|
||||||
# set, size, unset, xview, yview
|
# selection, set, size, unset, xview, yview
|
||||||
# def anchor option ?args ...?
|
def anchor_clear(self):
|
||||||
|
"""Removes the selection anchor."""
|
||||||
|
self.tk.call(self, 'anchor', 'clear')
|
||||||
|
|
||||||
def anchor_get(self):
|
def anchor_get(self):
|
||||||
"Get the (x,y) coordinate of the current anchor cell"
|
"Get the (x,y) coordinate of the current anchor cell"
|
||||||
return self._getints(self.tk.call(self, 'anchor', 'get'))
|
return self._getints(self.tk.call(self, 'anchor', 'get'))
|
||||||
|
|
||||||
# def bdtype
|
def anchor_set(self, x, y):
|
||||||
# def delete dim from ?to?
|
"""Set the selection anchor to the cell at (x, y)."""
|
||||||
|
self.tk.call(self, 'anchor', 'set', x, y)
|
||||||
|
|
||||||
def delete_row(self, from_, to=None):
|
def delete_row(self, from_, to=None):
|
||||||
"""Delete rows between from_ and to inclusive.
|
"""Delete rows between from_ and to inclusive.
|
||||||
If to is not provided, delete only row at from_"""
|
If to is not provided, delete only row at from_"""
|
||||||
|
@ -1803,6 +1823,7 @@ class Grid(TixWidget, XView, YView):
|
||||||
self.tk.call(self, 'delete', 'row', from_)
|
self.tk.call(self, 'delete', 'row', from_)
|
||||||
else:
|
else:
|
||||||
self.tk.call(self, 'delete', 'row', from_, to)
|
self.tk.call(self, 'delete', 'row', from_, to)
|
||||||
|
|
||||||
def delete_column(self, from_, to=None):
|
def delete_column(self, from_, to=None):
|
||||||
"""Delete columns between from_ and to inclusive.
|
"""Delete columns between from_ and to inclusive.
|
||||||
If to is not provided, delete only column at from_"""
|
If to is not provided, delete only column at from_"""
|
||||||
|
@ -1810,8 +1831,16 @@ class Grid(TixWidget, XView, YView):
|
||||||
self.tk.call(self, 'delete', 'column', from_)
|
self.tk.call(self, 'delete', 'column', from_)
|
||||||
else:
|
else:
|
||||||
self.tk.call(self, 'delete', 'column', from_, to)
|
self.tk.call(self, 'delete', 'column', from_, to)
|
||||||
# def edit apply
|
|
||||||
# def edit set x y
|
def edit_apply(self):
|
||||||
|
"""If any cell is being edited, de-highlight the cell and applies
|
||||||
|
the changes."""
|
||||||
|
self.tk.call(self, 'edit', 'apply')
|
||||||
|
|
||||||
|
def edit_set(self, x, y):
|
||||||
|
"""Highlights the cell at (x, y) for editing, if the -editnotify
|
||||||
|
command returns True for this cell."""
|
||||||
|
self.tk.call(self, 'edit', 'set', x, y)
|
||||||
|
|
||||||
def entrycget(self, x, y, option):
|
def entrycget(self, x, y, option):
|
||||||
"Get the option value for cell at (x,y)"
|
"Get the option value for cell at (x,y)"
|
||||||
|
@ -1830,6 +1859,18 @@ class Grid(TixWidget, XView, YView):
|
||||||
# This seems to always return '', at least for 'text' displayitems
|
# This seems to always return '', at least for 'text' displayitems
|
||||||
return self.tk.call(self, 'info', 'bbox', x, y)
|
return self.tk.call(self, 'info', 'bbox', x, y)
|
||||||
|
|
||||||
|
def move_column(self, from_, to, offset):
|
||||||
|
"""Moves the the range of columns from position FROM through TO by
|
||||||
|
the distance indicated by OFFSET. For example, move_column(2, 4, 1)
|
||||||
|
moves the columns 2,3,4 to columns 3,4,5."""
|
||||||
|
self.tk.call(self, 'move', 'column', from_, to, offset)
|
||||||
|
|
||||||
|
def move_row(self, from_, to, offset):
|
||||||
|
"""Moves the the range of rows from position FROM through TO by
|
||||||
|
the distance indicated by OFFSET.
|
||||||
|
For example, move_row(2, 4, 1) moves the rows 2,3,4 to rows 3,4,5."""
|
||||||
|
self.tk.call(self, 'move', 'row', from_, to, offset)
|
||||||
|
|
||||||
def nearest(self, x, y):
|
def nearest(self, x, y):
|
||||||
"Return coordinate of cell nearest pixel coordinate (x,y)"
|
"Return coordinate of cell nearest pixel coordinate (x,y)"
|
||||||
return self._getints(self.tk.call(self, 'nearest', x, y))
|
return self._getints(self.tk.call(self, 'nearest', x, y))
|
||||||
|
@ -1839,7 +1880,6 @@ class Grid(TixWidget, XView, YView):
|
||||||
# def selection includes
|
# def selection includes
|
||||||
# def selection set
|
# def selection set
|
||||||
# def selection toggle
|
# def selection toggle
|
||||||
# def move dim from to offset
|
|
||||||
|
|
||||||
def set(self, x, y, itemtype=None, **kw):
|
def set(self, x, y, itemtype=None, **kw):
|
||||||
args= self._options(self.cnf, kw)
|
args= self._options(self.cnf, kw)
|
||||||
|
@ -1847,8 +1887,59 @@ class Grid(TixWidget, XView, YView):
|
||||||
args= ('-itemtype', itemtype) + args
|
args= ('-itemtype', itemtype) + args
|
||||||
self.tk.call(self, 'set', x, y, *args)
|
self.tk.call(self, 'set', x, y, *args)
|
||||||
|
|
||||||
# def size dim index ?option value ...?
|
def size_column(self, index, **kw):
|
||||||
# def unset x y
|
"""Queries or sets the size of the column given by
|
||||||
|
INDEX. INDEX may be any non-negative
|
||||||
|
integer that gives the position of a given column.
|
||||||
|
INDEX can also be the string "default"; in this case, this command
|
||||||
|
queries or sets the default size of all columns.
|
||||||
|
When no option-value pair is given, this command returns a tuple
|
||||||
|
containing the current size setting of the given column. When
|
||||||
|
option-value pairs are given, the corresponding options of the
|
||||||
|
size setting of the given column are changed. Options may be one
|
||||||
|
of the follwing:
|
||||||
|
pad0 pixels
|
||||||
|
Specifies the paddings to the left of a column.
|
||||||
|
pad1 pixels
|
||||||
|
Specifies the paddings to the right of a column.
|
||||||
|
size val
|
||||||
|
Specifies the width of a column .
|
||||||
|
Val may be: "auto" -- the width of the column is set the
|
||||||
|
the widest cell in the column; a valid Tk screen distance
|
||||||
|
unit; or a real number following by the word chars
|
||||||
|
(e.g. 3.4chars) that sets the width of the column to the
|
||||||
|
given number of characters."""
|
||||||
|
return self.tk.split(self.tk.call(self._w, 'size', 'column', index,
|
||||||
|
*self._options({}, kw)))
|
||||||
|
|
||||||
|
def size_row(self, index, **kw):
|
||||||
|
"""Queries or sets the size of the row given by
|
||||||
|
INDEX. INDEX may be any non-negative
|
||||||
|
integer that gives the position of a given row .
|
||||||
|
INDEX can also be the string "default"; in this case, this command
|
||||||
|
queries or sets the default size of all rows.
|
||||||
|
When no option-value pair is given, this command returns a list con-
|
||||||
|
taining the current size setting of the given row . When option-value
|
||||||
|
pairs are given, the corresponding options of the size setting of the
|
||||||
|
given row are changed. Options may be one of the follwing:
|
||||||
|
pad0 pixels
|
||||||
|
Specifies the paddings to the top of a row.
|
||||||
|
pad1 pixels
|
||||||
|
Specifies the paddings to the the bottom of a row.
|
||||||
|
size val
|
||||||
|
Specifies the height of a row.
|
||||||
|
Val may be: "auto" -- the height of the row is set the
|
||||||
|
the highest cell in the row; a valid Tk screen distance
|
||||||
|
unit; or a real number following by the word chars
|
||||||
|
(e.g. 3.4chars) that sets the height of the row to the
|
||||||
|
given number of characters."""
|
||||||
|
return self.tk.split(self.tk.call(
|
||||||
|
self, 'size', 'row', index, *self._options({}, kw)))
|
||||||
|
|
||||||
|
def unset(self, x, y):
|
||||||
|
"""Clears the cell at (x, y) by removing its display item."""
|
||||||
|
self.tk.call(self._w, 'unset', x, y)
|
||||||
|
|
||||||
|
|
||||||
class ScrolledGrid(Grid):
|
class ScrolledGrid(Grid):
|
||||||
'''Scrolled Grid widgets'''
|
'''Scrolled Grid widgets'''
|
||||||
|
|
|
@ -359,6 +359,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #1522587: New constants and methods for the Tix.Grid widget.
|
||||||
|
|
||||||
- Issue #1250469: Fix the return value of Tix.PanedWindow.panes.
|
- Issue #1250469: Fix the return value of Tix.PanedWindow.panes.
|
||||||
|
|
||||||
- Issue #1119673: Do not override Tkinter.Text methods when creating a
|
- Issue #1119673: Do not override Tkinter.Text methods when creating a
|
||||||
|
|
Loading…
Reference in New Issue