summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-10 08:34:21 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-04-10 08:34:21 (GMT)
commitb04dee935c0f6d3104e43f25251968c665e6e3dd (patch)
tree78d1c7900429109b47ca779b26971e127ee40434
parent84a98e07f5e754f14c07f46ed9bfd3bbc8769ee2 (diff)
downloadcpython-b04dee935c0f6d3104e43f25251968c665e6e3dd.zip
cpython-b04dee935c0f6d3104e43f25251968c665e6e3dd.tar.gz
cpython-b04dee935c0f6d3104e43f25251968c665e6e3dd.tar.bz2
Patch #1462222: Fix Tix.Grid. Closes #1036406.
-rw-r--r--Demo/tix/grid.py28
-rwxr-xr-xLib/lib-tk/Tix.py98
-rw-r--r--Misc/NEWS2
3 files changed, 117 insertions, 11 deletions
diff --git a/Demo/tix/grid.py b/Demo/tix/grid.py
new file mode 100644
index 0000000..07ca87f
--- /dev/null
+++ b/Demo/tix/grid.py
@@ -0,0 +1,28 @@
+###
+import Tix as tk
+from pprint import pprint
+
+r= tk.Tk()
+r.title("test")
+
+l=tk.Label(r, name="a_label")
+l.pack()
+
+class MyGrid(tk.Grid):
+ def __init__(self, *args, **kwargs):
+ kwargs['editnotify']= self.editnotify
+ tk.Grid.__init__(self, *args, **kwargs)
+ def editnotify(self, x, y):
+ return True
+
+g = MyGrid(r, name="a_grid",
+selectunit="cell")
+g.pack(fill=tk.BOTH)
+for x in xrange(5):
+ for y in xrange(5):
+ g.set(x,y,text=str((x,y)))
+
+c = tk.Button(r, text="Close", command=r.destroy)
+c.pack()
+
+tk.mainloop()
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 2fb1307..ba9d06f 100755
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/lib-tk/Tix.py
@@ -1541,8 +1541,8 @@ class Tree(TixWidget):
'''This command is used to indicate whether the entry given by
entryPath has children entries and whether the children are visible. mode
must be one of open, close or none. If mode is set to open, a (+)
- indicator is drawn next to the entry. If mode is set to close, a (-)
- indicator is drawn next to the entry. If mode is set to none, no
+ indicator is drawn next the the entry. If mode is set to close, a (-)
+ indicator is drawn next the the entry. If mode is set to none, no
indicators will be drawn for this entry. The default mode is none. The
open mode indicates the entry has hidden children and this entry can be
opened by the user. The close mode indicates that all the children of the
@@ -1773,6 +1773,7 @@ class CObjView(TixWidget):
# FIXME: It should inherit -superclass tixScrolledWidget
pass
+
class Grid(TixWidget):
'''The Tix Grid command creates a new window and makes it into a
tixGrid widget. Additional options, may be specified on the command
@@ -1787,26 +1788,101 @@ class Grid(TixWidget):
border.
Subwidgets - None'''
- pass
-
+ # valid specific resources as of Tk 8.4
+ # editdonecmd, editnotifycmd, floatingcols, floatingrows, formatcmd,
+ # highlightbackground, highlightcolor, leftmargin, itemtype, selectmode,
+ # selectunit, topmargin,
+ def __init__(self, master=None, cnf={}, **kw):
+ static= []
+ self.cnf= cnf
+ TixWidget.__init__(self, master, 'tixGrid', static, cnf, kw)
+
+ # valid options as of Tk 8.4
+ # anchor, bdtype, cget, configure, delete, dragsite, dropsite, entrycget, edit
+ # entryconfigure, format, geometryinfo, info, index, move, nearest, selection
+ # set, size, unset, xview, yview
# def anchor option ?args ...?
+ def anchor_get(self):
+ "Get the (x,y) coordinate of the current anchor cell"
+ return self._getints(self.tk.call(self, 'anchor', 'get'))
+
# def bdtype
# def delete dim from ?to?
+ def delete_row(self, from_, to=None):
+ """Delete rows between from_ and to inclusive.
+ If to is not provided, delete only row at from_"""
+ if to is None:
+ self.tk.call(self, 'delete', 'row', from_)
+ else:
+ self.tk.call(self, 'delete', 'row', from_, to)
+ def delete_column(self, from_, to=None):
+ """Delete columns between from_ and to inclusive.
+ If to is not provided, delete only column at from_"""
+ if to is None:
+ self.tk.call(self, 'delete', 'column', from_)
+ else:
+ self.tk.call(self, 'delete', 'column', from_, to)
# def edit apply
# def edit set x y
- # def entrycget x y option
- # def entryconfigure x y ?option? ?value option value ...?
+
+ def entrycget(self, x, y, option):
+ "Get the option value for cell at (x,y)"
+ return self.tk.call(self, 'entrycget', x, y, option)
+
+ def entryconfigure(self, x, y, **kw):
+ return self.tk.call(self, 'entryconfigure', x, y, *self._options(None, kw))
# def format
# def index
+
+ def info_exists(self, x, y):
+ "Return True if display item exists at (x,y)"
+ return bool(int(self.tk.call(self, 'info', 'exists', x, y)))
+
+ def info_bbox(self, x, y):
+ # This seems to always return '', at least for 'text' displayitems
+ return self.tk.call(self, 'info', 'bbox', x, y)
+
+ def nearest(self, x, y):
+ "Return coordinate of cell nearest pixel coordinate (x,y)"
+ return self._getints(self.tk.call(self, 'nearest', x, y))
+
+ # def selection adjust
+ # def selection clear
+ # def selection includes
+ # def selection set
+ # def selection toggle
# def move dim from to offset
- # def set x y ?-itemtype type? ?option value...?
+
+ def set(self, x, y, itemtype=None, **kw):
+ args= self._options(self.cnf, kw)
+ if itemtype is not None:
+ args= ('-itemtype', itemtype) + args
+ self.tk.call(self, 'set', x, y, *args)
+
# def size dim index ?option value ...?
# def unset x y
- # def xview
- # def yview
-class ScrolledGrid(TixWidget):
+ def xview(self):
+ return self._getdoubles(self.tk.call(self, 'xview'))
+ def xview_moveto(self, fraction):
+ self.tk.call(self,'xview', 'moveto', fraction)
+ def xview_scroll(self, count, what="units"):
+ "Scroll right (count>0) or left <count> of units|pages"
+ self.tk.call(self, 'xview', 'scroll', count, what)
+
+ def yview(self):
+ return self._getdoubles(self.tk.call(self, 'yview'))
+ def yview_moveto(self, fraction):
+ self.tk.call(self,'ysview', 'moveto', fraction)
+ def yview_scroll(self, count, what="units"):
+ "Scroll down (count>0) or up <count> of units|pages"
+ self.tk.call(self, 'yview', 'scroll', count, what)
+
+class ScrolledGrid(Grid):
'''Scrolled Grid widgets'''
# FIXME: It should inherit -superclass tixScrolledWidget
- pass
+ def __init__(self, master=None, cnf={}, **kw):
+ static= []
+ self.cnf= cnf
+ TixWidget.__init__(self, master, 'tixScrolledGrid', static, cnf, kw)
diff --git a/Misc/NEWS b/Misc/NEWS
index 363ad52..1ee39f1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -26,6 +26,8 @@ Extension Modules
Library
-------
+- Patch #1462222: Fix Tix.Grid.
+
- Fix exception when doing glob.glob('anything*/')
Build