summaryrefslogtreecommitdiffstats
path: root/Lib/lib-tk
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib-tk')
-rwxr-xr-xLib/lib-tk/Tix.py98
-rw-r--r--Lib/lib-tk/Tkinter.py24
-rw-r--r--Lib/lib-tk/tkFont.py4
3 files changed, 109 insertions, 17 deletions
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 2fb1307..14c3c24 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/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index d600cd7..0ba954e 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -449,18 +449,15 @@ class Misc:
# I'd rather use time.sleep(ms*0.001)
self.tk.call('after', ms)
else:
- # XXX Disgusting hack to clean up after calling func
- tmp = []
- def callit(func=func, args=args, self=self, tmp=tmp):
+ def callit():
try:
func(*args)
finally:
try:
- self.deletecommand(tmp[0])
+ self.deletecommand(name)
except TclError:
pass
name = self._register(callit)
- tmp.append(name)
return self.tk.call('after', ms, name)
def after_idle(self, func, *args):
"""Call FUNC once if the Tcl main loop has no event to
@@ -486,7 +483,24 @@ class Misc:
def bell(self, displayof=0):
"""Ring a display's bell."""
self.tk.call(('bell',) + self._displayof(displayof))
+
# Clipboard handling:
+ def clipboard_get(self, **kw):
+ """Retrieve data from the clipboard on window's display.
+
+ The window keyword defaults to the root window of the Tkinter
+ application.
+
+ The type keyword specifies the form in which the data is
+ to be returned and should be an atom name such as STRING
+ or FILE_NAME. Type defaults to STRING.
+
+ This command is equivalent to:
+
+ selection_get(CLIPBOARD)
+ """
+ return self.tk.call(('clipboard', 'get') + self._options(kw))
+
def clipboard_clear(self, **kw):
"""Clear the data in the Tk clipboard.
diff --git a/Lib/lib-tk/tkFont.py b/Lib/lib-tk/tkFont.py
index 5b5a6ba..15dea2e 100644
--- a/Lib/lib-tk/tkFont.py
+++ b/Lib/lib-tk/tkFont.py
@@ -108,7 +108,9 @@ class Font:
try:
if self.delete_font:
self._call("font", "delete", self.name)
- except (AttributeError, Tkinter.TclError):
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except Exception:
pass
def copy(self):