summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/MultiCall.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/MultiCall.py')
-rw-r--r--Lib/idlelib/MultiCall.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
index b81c5ed..47f402d 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -30,9 +30,8 @@ Each function will be called at most once for each event.
"""
import sys
-import string
import re
-import Tkinter
+import tkinter
from idlelib import macosxSupport
# the event type constants, which define the meaning of mc_type
@@ -258,19 +257,16 @@ def _parse_sequence(sequence):
"""
if not sequence or sequence[0] != '<' or sequence[-1] != '>':
return None
- words = string.split(sequence[1:-1], '-')
-
+ words = sequence[1:-1].split('-')
modifiers = 0
while words and words[0] in _modifier_names:
modifiers |= 1 << _modifier_names[words[0]]
del words[0]
-
if words and words[0] in _type_names:
type = _type_names[words[0]]
del words[0]
else:
return None
-
if _binder_classes[type] is _SimpleBinder:
if modifiers or words:
return None
@@ -309,7 +305,7 @@ def MultiCallCreator(widget):
return _multicall_dict[widget]
class MultiCall (widget):
- assert issubclass(widget, Tkinter.Misc)
+ assert issubclass(widget, tkinter.Misc)
def __init__(self, *args, **kwargs):
widget.__init__(self, *args, **kwargs)
@@ -321,7 +317,8 @@ def MultiCallCreator(widget):
for i in range(len(_types))]
def bind(self, sequence=None, func=None, add=None):
- #print "bind(%s, %s, %s) called." % (sequence, func, add)
+ #print("bind(%s, %s, %s)" % (sequence, func, add),
+ # file=sys.__stderr__)
if type(sequence) is str and len(sequence) > 2 and \
sequence[:2] == "<<" and sequence[-2:] == ">>":
if sequence in self.__eventinfo:
@@ -349,7 +346,8 @@ def MultiCallCreator(widget):
return widget.unbind(self, sequence, funcid)
def event_add(self, virtual, *sequences):
- #print "event_add(%s,%s) was called"%(repr(virtual),repr(sequences))
+ #print("event_add(%s, %s)" % (repr(virtual), repr(sequences)),
+ # file=sys.__stderr__)
if virtual not in self.__eventinfo:
self.__eventinfo[virtual] = [None, []]
@@ -357,7 +355,7 @@ def MultiCallCreator(widget):
for seq in sequences:
triplet = _parse_sequence(seq)
if triplet is None:
- #print >> sys.stderr, "Seq. %s was added by Tkinter."%seq
+ #print("Tkinter event_add(%s)" % seq, file=sys.__stderr__)
widget.event_add(self, virtual, seq)
else:
if func is not None:
@@ -371,7 +369,7 @@ def MultiCallCreator(widget):
for seq in sequences:
triplet = _parse_sequence(seq)
if triplet is None:
- #print >> sys.stderr, "Seq. %s was deleted by Tkinter."%seq
+ #print("Tkinter event_delete: %s" % seq, file=sys.__stderr__)
widget.event_delete(self, virtual, seq)
else:
if func is not None:
@@ -399,12 +397,12 @@ def MultiCallCreator(widget):
if __name__ == "__main__":
# Test
- root = Tkinter.Tk()
- text = MultiCallCreator(Tkinter.Text)(root)
+ root = tkinter.Tk()
+ text = MultiCallCreator(tkinter.Text)(root)
text.pack()
def bindseq(seq, n=[0]):
def handler(event):
- print seq
+ print(seq)
text.bind("<<handler%d>>"%n[0], handler)
text.event_add("<<handler%d>>"%n[0], seq)
n[0] += 1