Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c86b7c6

Browse files
committed
Make bind variants without a sequence return a tuple of sequences
(formerly it returned a string, which wasn't very convenient). Add image commands to the Text widget (these are new in Tk 8.0).
1 parent 1645436 commit c86b7c6

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,10 @@ def _bind(self, what, sequence, func, add, needcleanup=1):
462462
_string.join(self._subst_format)))
463463
self.tk.call(what + (sequence, cmd))
464464
return funcid
465-
else:
465+
elif sequence:
466466
return self.tk.call(what + (sequence,))
467+
else:
468+
return self.tk.splitlist(self.tk.call(what))
467469
def bind(self, sequence=None, func=None, add=None):
468470
return self._bind(('bind', self._w), sequence, func, add)
469471
def unbind(self, sequence, funcid=None):
@@ -1600,6 +1602,30 @@ def dlineinfo(self, index):
16001602
return self._getints(self.tk.call(self._w, 'dlineinfo', index))
16011603
def get(self, index1, index2=None):
16021604
return self.tk.call(self._w, 'get', index1, index2)
1605+
# (Image commands are new in 8.0)
1606+
def image_cget(self, index, option):
1607+
if option[:1] != "-":
1608+
option = "-" + option
1609+
if option[-1:] == "_":
1610+
option = option[:-1]
1611+
return self.tk.call(self._w, "image", "cget", index, option)
1612+
def image_configure(self, index, cnf={}, **kw):
1613+
if not cnf and not kw:
1614+
cnf = {}
1615+
for x in self.tk.split(
1616+
self.tk.call(
1617+
self._w, "image", "configure", index)):
1618+
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
1619+
return cnf
1620+
apply(self.tk.call,
1621+
(self._w, "image", "configure", index)
1622+
+ self._options(cnf, kw))
1623+
def image_create(self, index, cnf={}, **kw):
1624+
return apply(self.tk.call,
1625+
(self._w, "image", "create", index)
1626+
+ self._options(cnf, kw))
1627+
def image_names(self):
1628+
return self.tk.call(self._w, "image", "names")
16031629
def index(self, index):
16041630
return self.tk.call(self._w, 'index', index)
16051631
def insert(self, index, chars, *args):

0 commit comments

Comments
 (0)