Linux premium71.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
LiteSpeed
Server IP : 198.187.29.8 & Your IP : 3.149.24.115
Domains :
Cant Read [ /etc/named.conf ]
User : cleahvkv
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
lib64 /
python2.7 /
idlelib /
Delete
Unzip
Name
Size
Permission
Date
Action
Icons
[ DIR ]
drwxr-xr-x
2024-06-13 10:37
idle_test
[ DIR ]
drwxr-xr-x
2024-06-13 10:37
AutoComplete.py
8.75
KB
-rw-r--r--
2024-04-10 04:58
AutoComplete.pyc
7.82
KB
-rw-r--r--
2024-04-10 04:58
AutoComplete.pyo
7.82
KB
-rw-r--r--
2024-04-10 04:58
AutoCompleteWindow.py
16.91
KB
-rw-r--r--
2024-04-10 04:58
AutoCompleteWindow.pyc
12.19
KB
-rw-r--r--
2024-04-10 04:58
AutoCompleteWindow.pyo
12.13
KB
-rw-r--r--
2024-04-10 04:58
AutoExpand.py
3.32
KB
-rw-r--r--
2024-04-10 04:58
AutoExpand.pyc
3.42
KB
-rw-r--r--
2024-04-10 04:58
AutoExpand.pyo
3.42
KB
-rw-r--r--
2024-04-10 04:58
Bindings.py
2.91
KB
-rw-r--r--
2024-04-10 04:58
Bindings.pyc
4.58
KB
-rw-r--r--
2024-04-10 04:58
Bindings.pyo
4.58
KB
-rw-r--r--
2024-04-10 04:58
CREDITS.txt
1.82
KB
-rw-r--r--
2024-04-10 04:58
CallTipWindow.py
5.92
KB
-rw-r--r--
2024-04-10 04:58
CallTipWindow.pyc
5.99
KB
-rw-r--r--
2024-04-10 04:58
CallTipWindow.pyo
5.99
KB
-rw-r--r--
2024-04-10 04:58
CallTips.py
7.56
KB
-rw-r--r--
2024-04-10 04:58
CallTips.pyc
7.94
KB
-rw-r--r--
2024-04-10 04:58
CallTips.pyo
7.94
KB
-rw-r--r--
2024-04-10 04:58
ChangeLog
55.07
KB
-rw-r--r--
2024-04-10 04:58
ClassBrowser.py
6.83
KB
-rw-r--r--
2024-04-10 04:58
ClassBrowser.pyc
9.28
KB
-rw-r--r--
2024-04-10 04:58
ClassBrowser.pyo
9.28
KB
-rw-r--r--
2024-04-10 04:58
CodeContext.py
8.15
KB
-rw-r--r--
2024-04-10 04:58
CodeContext.pyc
6.5
KB
-rw-r--r--
2024-04-10 04:58
CodeContext.pyo
6.46
KB
-rw-r--r--
2024-04-10 04:58
ColorDelegator.py
9.53
KB
-rw-r--r--
2024-04-10 04:58
ColorDelegator.pyc
8.69
KB
-rw-r--r--
2024-04-10 04:58
ColorDelegator.pyo
8.69
KB
-rw-r--r--
2024-04-10 04:58
Debugger.py
17.81
KB
-rw-r--r--
2024-04-10 04:58
Debugger.pyc
17.13
KB
-rw-r--r--
2024-04-10 04:58
Debugger.pyo
17.13
KB
-rw-r--r--
2024-04-10 04:58
Delegator.py
665
B
-rw-r--r--
2024-04-10 04:58
Delegator.pyc
1.24
KB
-rw-r--r--
2024-04-10 04:58
Delegator.pyo
1.24
KB
-rw-r--r--
2024-04-10 04:58
EditorWindow.py
63.96
KB
-rw-r--r--
2024-04-10 04:58
EditorWindow.pyc
55.53
KB
-rw-r--r--
2024-04-10 04:58
EditorWindow.pyo
55.43
KB
-rw-r--r--
2024-04-10 04:58
FileList.py
3.63
KB
-rw-r--r--
2024-04-10 04:58
FileList.pyc
3.93
KB
-rw-r--r--
2024-04-10 04:58
FileList.pyo
3.9
KB
-rw-r--r--
2024-04-10 04:58
FormatParagraph.py
7.12
KB
-rw-r--r--
2024-04-10 04:58
FormatParagraph.pyc
6.97
KB
-rw-r--r--
2024-04-10 04:58
FormatParagraph.pyo
6.97
KB
-rw-r--r--
2024-04-10 04:58
GrepDialog.py
5.02
KB
-rw-r--r--
2024-04-10 04:58
GrepDialog.pyc
6.27
KB
-rw-r--r--
2024-04-10 04:58
GrepDialog.pyo
6.27
KB
-rw-r--r--
2024-04-10 04:58
HISTORY.txt
10.08
KB
-rw-r--r--
2024-04-10 04:58
HyperParser.py
10.25
KB
-rw-r--r--
2024-04-10 04:58
HyperParser.pyc
6.52
KB
-rw-r--r--
2024-04-10 04:58
HyperParser.pyo
6.52
KB
-rw-r--r--
2024-04-10 04:58
IOBinding.py
21.4
KB
-rw-r--r--
2024-04-10 04:58
IOBinding.pyc
18.1
KB
-rw-r--r--
2024-04-10 04:58
IOBinding.pyo
18.1
KB
-rw-r--r--
2024-04-10 04:58
IdleHistory.py
3.96
KB
-rw-r--r--
2024-04-10 04:58
IdleHistory.pyc
3.96
KB
-rw-r--r--
2024-04-10 04:58
IdleHistory.pyo
3.96
KB
-rw-r--r--
2024-04-10 04:58
MultiCall.py
17.29
KB
-rw-r--r--
2024-04-10 04:58
MultiCall.pyc
15.97
KB
-rw-r--r--
2024-04-10 04:58
MultiCall.pyo
15.9
KB
-rw-r--r--
2024-04-10 04:58
MultiStatusBar.py
1.32
KB
-rw-r--r--
2024-04-10 04:58
MultiStatusBar.pyc
2.23
KB
-rw-r--r--
2024-04-10 04:58
MultiStatusBar.pyo
2.23
KB
-rw-r--r--
2024-04-10 04:58
NEWS.txt
46.14
KB
-rw-r--r--
2024-04-10 04:58
ObjectBrowser.py
4.27
KB
-rw-r--r--
2024-04-10 04:58
ObjectBrowser.pyc
6.9
KB
-rw-r--r--
2024-04-10 04:58
ObjectBrowser.pyo
6.9
KB
-rw-r--r--
2024-04-10 04:58
OutputWindow.py
4.47
KB
-rw-r--r--
2024-04-10 04:58
OutputWindow.pyc
5.11
KB
-rw-r--r--
2024-04-10 04:58
OutputWindow.pyo
5.11
KB
-rw-r--r--
2024-04-10 04:58
ParenMatch.py
6.56
KB
-rw-r--r--
2024-04-10 04:58
ParenMatch.pyc
6.96
KB
-rw-r--r--
2024-04-10 04:58
ParenMatch.pyo
6.96
KB
-rw-r--r--
2024-04-10 04:58
PathBrowser.py
2.94
KB
-rw-r--r--
2024-04-10 04:58
PathBrowser.pyc
4.38
KB
-rw-r--r--
2024-04-10 04:58
PathBrowser.pyo
4.38
KB
-rw-r--r--
2024-04-10 04:58
Percolator.py
3.15
KB
-rw-r--r--
2024-04-10 04:58
Percolator.pyc
4.5
KB
-rw-r--r--
2024-04-10 04:58
Percolator.pyo
4.32
KB
-rw-r--r--
2024-04-10 04:58
PyParse.py
19.05
KB
-rw-r--r--
2024-04-10 04:58
PyParse.pyc
9.77
KB
-rw-r--r--
2024-04-10 04:58
PyParse.pyo
9.34
KB
-rw-r--r--
2024-04-10 04:58
PyShell.py
57.48
KB
-rwxr-xr-x
2024-04-10 04:58
PyShell.pyc
51.59
KB
-rw-r--r--
2024-04-10 04:58
PyShell.pyo
51.49
KB
-rw-r--r--
2024-04-10 04:58
README.txt
7.71
KB
-rw-r--r--
2024-04-10 04:58
RemoteDebugger.py
11.36
KB
-rw-r--r--
2024-04-10 04:58
RemoteDebugger.pyc
15.94
KB
-rw-r--r--
2024-04-10 04:58
RemoteDebugger.pyo
15.79
KB
-rw-r--r--
2024-04-10 04:58
RemoteObjectBrowser.py
942
B
-rw-r--r--
2024-04-10 04:58
RemoteObjectBrowser.pyc
2.1
KB
-rw-r--r--
2024-04-10 04:58
RemoteObjectBrowser.pyo
2.1
KB
-rw-r--r--
2024-04-10 04:58
ReplaceDialog.py
6.48
KB
-rw-r--r--
2024-04-10 04:58
ReplaceDialog.pyc
7.57
KB
-rw-r--r--
2024-04-10 04:58
ReplaceDialog.pyo
7.57
KB
-rw-r--r--
2024-04-10 04:58
RstripExtension.py
1.03
KB
-rw-r--r--
2024-04-10 04:58
RstripExtension.pyc
1.58
KB
-rw-r--r--
2024-04-10 04:58
RstripExtension.pyo
1.58
KB
-rw-r--r--
2024-04-10 04:58
ScriptBinding.py
8.26
KB
-rw-r--r--
2024-04-10 04:58
ScriptBinding.pyc
8.01
KB
-rw-r--r--
2024-04-10 04:58
ScriptBinding.pyo
8.01
KB
-rw-r--r--
2024-04-10 04:58
ScrolledList.py
4.27
KB
-rw-r--r--
2024-04-10 04:58
ScrolledList.pyc
6.33
KB
-rw-r--r--
2024-04-10 04:58
ScrolledList.pyo
6.33
KB
-rw-r--r--
2024-04-10 04:58
SearchDialog.py
2.57
KB
-rw-r--r--
2024-04-10 04:58
SearchDialog.pyc
3.89
KB
-rw-r--r--
2024-04-10 04:58
SearchDialog.pyo
3.89
KB
-rw-r--r--
2024-04-10 04:58
SearchDialogBase.py
6.93
KB
-rw-r--r--
2024-04-10 04:58
SearchDialogBase.pyc
8.26
KB
-rw-r--r--
2024-04-10 04:58
SearchDialogBase.pyo
8.26
KB
-rw-r--r--
2024-04-10 04:58
SearchEngine.py
7.29
KB
-rw-r--r--
2024-04-10 04:58
SearchEngine.pyc
8.11
KB
-rw-r--r--
2024-04-10 04:58
SearchEngine.pyo
8.11
KB
-rw-r--r--
2024-04-10 04:58
StackViewer.py
4.33
KB
-rw-r--r--
2024-04-10 04:58
StackViewer.pyc
6.25
KB
-rw-r--r--
2024-04-10 04:58
StackViewer.pyo
6.25
KB
-rw-r--r--
2024-04-10 04:58
TODO.txt
8.28
KB
-rw-r--r--
2024-04-10 04:58
ToolTip.py
3.1
KB
-rw-r--r--
2024-04-10 04:58
ToolTip.pyc
4.56
KB
-rw-r--r--
2024-04-10 04:58
ToolTip.pyo
4.56
KB
-rw-r--r--
2024-04-10 04:58
TreeWidget.py
14.68
KB
-rw-r--r--
2024-04-10 04:58
TreeWidget.pyc
17.28
KB
-rw-r--r--
2024-04-10 04:58
TreeWidget.pyo
17.28
KB
-rw-r--r--
2024-04-10 04:58
UndoDelegator.py
10.53
KB
-rw-r--r--
2024-04-10 04:58
UndoDelegator.pyc
13.24
KB
-rw-r--r--
2024-04-10 04:58
UndoDelegator.pyo
13.24
KB
-rw-r--r--
2024-04-10 04:58
WidgetRedirector.py
6.74
KB
-rw-r--r--
2024-04-10 04:58
WidgetRedirector.pyc
7.59
KB
-rw-r--r--
2024-04-10 04:58
WidgetRedirector.pyo
7.59
KB
-rw-r--r--
2024-04-10 04:58
WindowList.py
2.42
KB
-rw-r--r--
2024-04-10 04:58
WindowList.pyc
3.55
KB
-rw-r--r--
2024-04-10 04:58
WindowList.pyo
3.55
KB
-rw-r--r--
2024-04-10 04:58
ZoomHeight.py
1.27
KB
-rw-r--r--
2024-04-10 04:58
ZoomHeight.pyc
1.61
KB
-rw-r--r--
2024-04-10 04:58
ZoomHeight.pyo
1.61
KB
-rw-r--r--
2024-04-10 04:58
__init__.py
288
B
-rw-r--r--
2024-04-10 04:58
__init__.pyc
431
B
-rw-r--r--
2024-04-10 04:58
__init__.pyo
431
B
-rw-r--r--
2024-04-10 04:58
aboutDialog.py
6.85
KB
-rw-r--r--
2024-04-10 04:58
aboutDialog.pyc
6.69
KB
-rw-r--r--
2024-04-10 04:58
aboutDialog.pyo
6.69
KB
-rw-r--r--
2024-04-10 04:58
config-extensions.def
2.9
KB
-rw-r--r--
2024-04-10 04:58
config-highlight.def
2.46
KB
-rw-r--r--
2024-04-10 04:58
config-keys.def
7.59
KB
-rw-r--r--
2024-04-10 04:58
config-main.def
2.5
KB
-rw-r--r--
2024-04-10 04:58
configDialog.py
64.41
KB
-rw-r--r--
2024-04-10 04:58
configDialog.pyc
52.04
KB
-rw-r--r--
2024-04-10 04:58
configDialog.pyo
52.04
KB
-rw-r--r--
2024-04-10 04:58
configHandler.py
31.72
KB
-rw-r--r--
2024-04-10 04:58
configHandler.pyc
28.67
KB
-rw-r--r--
2024-04-10 04:58
configHandler.pyo
28.67
KB
-rw-r--r--
2024-04-10 04:58
configHelpSourceEdit.py
6.53
KB
-rw-r--r--
2024-04-10 04:58
configHelpSourceEdit.pyc
6.44
KB
-rw-r--r--
2024-04-10 04:58
configHelpSourceEdit.pyo
6.44
KB
-rw-r--r--
2024-04-10 04:58
configSectionNameDialog.py
3.95
KB
-rw-r--r--
2024-04-10 04:58
configSectionNameDialog.pyc
4.32
KB
-rw-r--r--
2024-04-10 04:58
configSectionNameDialog.pyo
4.32
KB
-rw-r--r--
2024-04-10 04:58
dynOptionMenuWidget.py
1.94
KB
-rw-r--r--
2024-04-10 04:58
dynOptionMenuWidget.pyc
2.72
KB
-rw-r--r--
2024-04-10 04:58
dynOptionMenuWidget.pyo
2.72
KB
-rw-r--r--
2024-04-10 04:58
extend.txt
3.56
KB
-rw-r--r--
2024-04-10 04:58
help.html
41.42
KB
-rw-r--r--
2024-04-10 04:58
help.py
10.78
KB
-rw-r--r--
2024-04-10 04:58
help.pyc
11.98
KB
-rw-r--r--
2024-04-10 04:58
help.pyo
11.98
KB
-rw-r--r--
2024-04-10 04:58
help.txt
11.86
KB
-rw-r--r--
2024-04-10 04:58
idle.py
453
B
-rw-r--r--
2024-04-10 04:58
idle.pyc
410
B
-rw-r--r--
2024-04-10 04:58
idle.pyo
410
B
-rw-r--r--
2024-04-10 04:58
idle.pyw
563
B
-rw-r--r--
2024-04-10 04:58
idlever.py
415
B
-rw-r--r--
2024-04-10 04:58
idlever.pyc
578
B
-rw-r--r--
2024-04-10 04:58
idlever.pyo
578
B
-rw-r--r--
2024-04-10 04:58
keybindingDialog.py
12.18
KB
-rw-r--r--
2024-04-10 04:58
keybindingDialog.pyc
11.89
KB
-rw-r--r--
2024-04-10 04:58
keybindingDialog.pyo
11.89
KB
-rw-r--r--
2024-04-10 04:58
macosxSupport.py
8.24
KB
-rw-r--r--
2024-04-10 04:58
macosxSupport.pyc
8.16
KB
-rw-r--r--
2024-04-10 04:58
macosxSupport.pyo
8.02
KB
-rw-r--r--
2024-04-10 04:58
rpc.py
19.68
KB
-rw-r--r--
2024-04-10 04:58
rpc.pyc
21.22
KB
-rw-r--r--
2024-04-10 04:58
rpc.pyo
21.12
KB
-rw-r--r--
2024-04-10 04:58
run.py
12.61
KB
-rw-r--r--
2024-04-10 04:58
run.pyc
13.1
KB
-rw-r--r--
2024-04-10 04:58
run.pyo
13.05
KB
-rw-r--r--
2024-04-10 04:58
tabbedpages.py
18.01
KB
-rw-r--r--
2024-04-10 04:58
tabbedpages.pyc
18.13
KB
-rw-r--r--
2024-04-10 04:58
tabbedpages.pyo
18.13
KB
-rw-r--r--
2024-04-10 04:58
textView.py
3.44
KB
-rw-r--r--
2024-04-10 04:58
textView.pyc
3.93
KB
-rw-r--r--
2024-04-10 04:58
textView.pyo
3.93
KB
-rw-r--r--
2024-04-10 04:58
Save
Rename
""" MultiCall - a class which inherits its methods from a Tkinter widget (Text, for example), but enables multiple calls of functions per virtual event - all matching events will be called, not only the most specific one. This is done by wrapping the event functions - event_add, event_delete and event_info. MultiCall recognizes only a subset of legal event sequences. Sequences which are not recognized are treated by the original Tk handling mechanism. A more-specific event will be called before a less-specific event. The recognized sequences are complete one-event sequences (no emacs-style Ctrl-X Ctrl-C, no shortcuts like <3>), for all types of events. Key/Button Press/Release events can have modifiers. The recognized modifiers are Shift, Control, Option and Command for Mac, and Control, Alt, Shift, Meta/M for other platforms. For all events which were handled by MultiCall, a new member is added to the event instance passed to the binded functions - mc_type. This is one of the event type constants defined in this module (such as MC_KEYPRESS). For Key/Button events (which are handled by MultiCall and may receive modifiers), another member is added - mc_state. This member gives the state of the recognized modifiers, as a combination of the modifier constants also defined in this module (for example, MC_SHIFT). Using these members is absolutely portable. The order by which events are called is defined by these rules: 1. A more-specific event will be called before a less-specific event. 2. A recently-binded event will be called before a previously-binded event, unless this conflicts with the first rule. Each function will be called at most once for each event. """ import sys import string import re import Tkinter # the event type constants, which define the meaning of mc_type MC_KEYPRESS=0; MC_KEYRELEASE=1; MC_BUTTONPRESS=2; MC_BUTTONRELEASE=3; MC_ACTIVATE=4; MC_CIRCULATE=5; MC_COLORMAP=6; MC_CONFIGURE=7; MC_DEACTIVATE=8; MC_DESTROY=9; MC_ENTER=10; MC_EXPOSE=11; MC_FOCUSIN=12; MC_FOCUSOUT=13; MC_GRAVITY=14; MC_LEAVE=15; MC_MAP=16; MC_MOTION=17; MC_MOUSEWHEEL=18; MC_PROPERTY=19; MC_REPARENT=20; MC_UNMAP=21; MC_VISIBILITY=22; # the modifier state constants, which define the meaning of mc_state MC_SHIFT = 1<<0; MC_CONTROL = 1<<2; MC_ALT = 1<<3; MC_META = 1<<5 MC_OPTION = 1<<6; MC_COMMAND = 1<<7 # define the list of modifiers, to be used in complex event types. if sys.platform == "darwin": _modifiers = (("Shift",), ("Control",), ("Option",), ("Command",)) _modifier_masks = (MC_SHIFT, MC_CONTROL, MC_OPTION, MC_COMMAND) else: _modifiers = (("Control",), ("Alt",), ("Shift",), ("Meta", "M")) _modifier_masks = (MC_CONTROL, MC_ALT, MC_SHIFT, MC_META) # a dictionary to map a modifier name into its number _modifier_names = dict([(name, number) for number in range(len(_modifiers)) for name in _modifiers[number]]) # A binder is a class which binds functions to one type of event. It has two # methods: bind and unbind, which get a function and a parsed sequence, as # returned by _parse_sequence(). There are two types of binders: # _SimpleBinder handles event types with no modifiers and no detail. # No Python functions are called when no events are binded. # _ComplexBinder handles event types with modifiers and a detail. # A Python function is called each time an event is generated. class _SimpleBinder: def __init__(self, type, widget, widgetinst): self.type = type self.sequence = '<'+_types[type][0]+'>' self.widget = widget self.widgetinst = widgetinst self.bindedfuncs = [] self.handlerid = None def bind(self, triplet, func): if not self.handlerid: def handler(event, l = self.bindedfuncs, mc_type = self.type): event.mc_type = mc_type wascalled = {} for i in range(len(l)-1, -1, -1): func = l[i] if func not in wascalled: wascalled[func] = True r = func(event) if r: return r self.handlerid = self.widget.bind(self.widgetinst, self.sequence, handler) self.bindedfuncs.append(func) def unbind(self, triplet, func): self.bindedfuncs.remove(func) if not self.bindedfuncs: self.widget.unbind(self.widgetinst, self.sequence, self.handlerid) self.handlerid = None def __del__(self): if self.handlerid: self.widget.unbind(self.widgetinst, self.sequence, self.handlerid) # An int in range(1 << len(_modifiers)) represents a combination of modifiers # (if the least significant bit is on, _modifiers[0] is on, and so on). # _state_subsets gives for each combination of modifiers, or *state*, # a list of the states which are a subset of it. This list is ordered by the # number of modifiers is the state - the most specific state comes first. _states = range(1 << len(_modifiers)) _state_names = [''.join(m[0]+'-' for i, m in enumerate(_modifiers) if (1 << i) & s) for s in _states] def expand_substates(states): '''For each item of states return a list containing all combinations of that item with individual bits reset, sorted by the number of set bits. ''' def nbits(n): "number of bits set in n base 2" nb = 0 while n: n, rem = divmod(n, 2) nb += rem return nb statelist = [] for state in states: substates = list(set(state & x for x in states)) substates.sort(key=nbits, reverse=True) statelist.append(substates) return statelist _state_subsets = expand_substates(_states) # _state_codes gives for each state, the portable code to be passed as mc_state _state_codes = [] for s in _states: r = 0 for i in range(len(_modifiers)): if (1 << i) & s: r |= _modifier_masks[i] _state_codes.append(r) class _ComplexBinder: # This class binds many functions, and only unbinds them when it is deleted. # self.handlerids is the list of seqs and ids of binded handler functions. # The binded functions sit in a dictionary of lists of lists, which maps # a detail (or None) and a state into a list of functions. # When a new detail is discovered, handlers for all the possible states # are binded. def __create_handler(self, lists, mc_type, mc_state): def handler(event, lists = lists, mc_type = mc_type, mc_state = mc_state, ishandlerrunning = self.ishandlerrunning, doafterhandler = self.doafterhandler): ishandlerrunning[:] = [True] event.mc_type = mc_type event.mc_state = mc_state wascalled = {} r = None for l in lists: for i in range(len(l)-1, -1, -1): func = l[i] if func not in wascalled: wascalled[func] = True r = l[i](event) if r: break if r: break ishandlerrunning[:] = [] # Call all functions in doafterhandler and remove them from list for f in doafterhandler: f() doafterhandler[:] = [] if r: return r return handler def __init__(self, type, widget, widgetinst): self.type = type self.typename = _types[type][0] self.widget = widget self.widgetinst = widgetinst self.bindedfuncs = {None: [[] for s in _states]} self.handlerids = [] # we don't want to change the lists of functions while a handler is # running - it will mess up the loop and anyway, we usually want the # change to happen from the next event. So we have a list of functions # for the handler to run after it finishes calling the binded functions. # It calls them only once. # ishandlerrunning is a list. An empty one means no, otherwise - yes. # this is done so that it would be mutable. self.ishandlerrunning = [] self.doafterhandler = [] for s in _states: lists = [self.bindedfuncs[None][i] for i in _state_subsets[s]] handler = self.__create_handler(lists, type, _state_codes[s]) seq = '<'+_state_names[s]+self.typename+'>' self.handlerids.append((seq, self.widget.bind(self.widgetinst, seq, handler))) def bind(self, triplet, func): if triplet[2] not in self.bindedfuncs: self.bindedfuncs[triplet[2]] = [[] for s in _states] for s in _states: lists = [ self.bindedfuncs[detail][i] for detail in (triplet[2], None) for i in _state_subsets[s] ] handler = self.__create_handler(lists, self.type, _state_codes[s]) seq = "<%s%s-%s>"% (_state_names[s], self.typename, triplet[2]) self.handlerids.append((seq, self.widget.bind(self.widgetinst, seq, handler))) doit = lambda: self.bindedfuncs[triplet[2]][triplet[0]].append(func) if not self.ishandlerrunning: doit() else: self.doafterhandler.append(doit) def unbind(self, triplet, func): doit = lambda: self.bindedfuncs[triplet[2]][triplet[0]].remove(func) if not self.ishandlerrunning: doit() else: self.doafterhandler.append(doit) def __del__(self): for seq, id in self.handlerids: self.widget.unbind(self.widgetinst, seq, id) # define the list of event types to be handled by MultiEvent. the order is # compatible with the definition of event type constants. _types = ( ("KeyPress", "Key"), ("KeyRelease",), ("ButtonPress", "Button"), ("ButtonRelease",), ("Activate",), ("Circulate",), ("Colormap",), ("Configure",), ("Deactivate",), ("Destroy",), ("Enter",), ("Expose",), ("FocusIn",), ("FocusOut",), ("Gravity",), ("Leave",), ("Map",), ("Motion",), ("MouseWheel",), ("Property",), ("Reparent",), ("Unmap",), ("Visibility",), ) # which binder should be used for every event type? _binder_classes = (_ComplexBinder,) * 4 + (_SimpleBinder,) * (len(_types)-4) # A dictionary to map a type name into its number _type_names = dict([(name, number) for number in range(len(_types)) for name in _types[number]]) _keysym_re = re.compile(r"^\w+$") _button_re = re.compile(r"^[1-5]$") def _parse_sequence(sequence): """Get a string which should describe an event sequence. If it is successfully parsed as one, return a tuple containing the state (as an int), the event type (as an index of _types), and the detail - None if none, or a string if there is one. If the parsing is unsuccessful, return None. """ if not sequence or sequence[0] != '<' or sequence[-1] != '>': return None words = string.split(sequence[1:-1], '-') 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 else: detail = None else: # _ComplexBinder if type in [_type_names[s] for s in ("KeyPress", "KeyRelease")]: type_re = _keysym_re else: type_re = _button_re if not words: detail = None elif len(words) == 1 and type_re.match(words[0]): detail = words[0] else: return None return modifiers, type, detail def _triplet_to_sequence(triplet): if triplet[2]: return '<'+_state_names[triplet[0]]+_types[triplet[1]][0]+'-'+ \ triplet[2]+'>' else: return '<'+_state_names[triplet[0]]+_types[triplet[1]][0]+'>' _multicall_dict = {} def MultiCallCreator(widget): """Return a MultiCall class which inherits its methods from the given widget class (for example, Tkinter.Text). This is used instead of a templating mechanism. """ if widget in _multicall_dict: return _multicall_dict[widget] class MultiCall (widget): assert issubclass(widget, Tkinter.Misc) def __init__(self, *args, **kwargs): widget.__init__(self, *args, **kwargs) # a dictionary which maps a virtual event to a tuple with: # 0. the function binded # 1. a list of triplets - the sequences it is binded to self.__eventinfo = {} self.__binders = [_binder_classes[i](i, widget, self) for i in range(len(_types))] def bind(self, sequence=None, func=None, add=None): #print "bind(%s, %s, %s) called." % (sequence, func, add) if type(sequence) is str and len(sequence) > 2 and \ sequence[:2] == "<<" and sequence[-2:] == ">>": if sequence in self.__eventinfo: ei = self.__eventinfo[sequence] if ei[0] is not None: for triplet in ei[1]: self.__binders[triplet[1]].unbind(triplet, ei[0]) ei[0] = func if ei[0] is not None: for triplet in ei[1]: self.__binders[triplet[1]].bind(triplet, func) else: self.__eventinfo[sequence] = [func, []] return widget.bind(self, sequence, func, add) def unbind(self, sequence, funcid=None): if type(sequence) is str and len(sequence) > 2 and \ sequence[:2] == "<<" and sequence[-2:] == ">>" and \ sequence in self.__eventinfo: func, triplets = self.__eventinfo[sequence] if func is not None: for triplet in triplets: self.__binders[triplet[1]].unbind(triplet, func) self.__eventinfo[sequence][0] = None return widget.unbind(self, sequence, funcid) def event_add(self, virtual, *sequences): #print "event_add(%s,%s) was called"%(repr(virtual),repr(sequences)) if virtual not in self.__eventinfo: self.__eventinfo[virtual] = [None, []] func, triplets = self.__eventinfo[virtual] for seq in sequences: triplet = _parse_sequence(seq) if triplet is None: #print >> sys.stderr, "Seq. %s was added by Tkinter."%seq widget.event_add(self, virtual, seq) else: if func is not None: self.__binders[triplet[1]].bind(triplet, func) triplets.append(triplet) def event_delete(self, virtual, *sequences): if virtual not in self.__eventinfo: return func, triplets = self.__eventinfo[virtual] for seq in sequences: triplet = _parse_sequence(seq) if triplet is None: #print >> sys.stderr, "Seq. %s was deleted by Tkinter."%seq widget.event_delete(self, virtual, seq) else: if func is not None: self.__binders[triplet[1]].unbind(triplet, func) triplets.remove(triplet) def event_info(self, virtual=None): if virtual is None or virtual not in self.__eventinfo: return widget.event_info(self, virtual) else: return tuple(map(_triplet_to_sequence, self.__eventinfo[virtual][1])) + \ widget.event_info(self, virtual) def __del__(self): for virtual in self.__eventinfo: func, triplets = self.__eventinfo[virtual] if func: for triplet in triplets: self.__binders[triplet[1]].unbind(triplet, func) _multicall_dict[widget] = MultiCall return MultiCall def _multi_call(parent): root = Tkinter.Tk() root.title("Test MultiCall") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) text = MultiCallCreator(Tkinter.Text)(root) text.pack() def bindseq(seq, n=[0]): def handler(event): print seq text.bind("<<handler%d>>"%n[0], handler) text.event_add("<<handler%d>>"%n[0], seq) n[0] += 1 bindseq("<Key>") bindseq("<Control-Key>") bindseq("<Alt-Key-a>") bindseq("<Control-Key-a>") bindseq("<Alt-Control-Key-a>") bindseq("<Key-b>") bindseq("<Control-Button-1>") bindseq("<Button-2>") bindseq("<Alt-Button-1>") bindseq("<FocusOut>") bindseq("<Enter>") bindseq("<Leave>") root.mainloop() if __name__ == "__main__": from idlelib.idle_test.htest import run run(_multi_call)