Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c7388740
Commit
c7388740
authored
May 25, 2014
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Plain Diff
Merge with 3.4
parents
0afd0ad1
a2fc99ec
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
160 additions
and
79 deletions
+160
-79
Lib/idlelib/ClassBrowser.py
Lib/idlelib/ClassBrowser.py
+1
-1
Lib/idlelib/ColorDelegator.py
Lib/idlelib/ColorDelegator.py
+2
-4
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+3
-6
Lib/idlelib/PathBrowser.py
Lib/idlelib/PathBrowser.py
+1
-1
Lib/idlelib/Percolator.py
Lib/idlelib/Percolator.py
+35
-15
Lib/idlelib/StackViewer.py
Lib/idlelib/StackViewer.py
+30
-0
Lib/idlelib/ToolTip.py
Lib/idlelib/ToolTip.py
+3
-2
Lib/idlelib/idle_test/htest.py
Lib/idlelib/idle_test/htest.py
+73
-36
Lib/idlelib/keybindingDialog.py
Lib/idlelib/keybindingDialog.py
+12
-14
No files found.
Lib/idlelib/ClassBrowser.py
View file @
c7388740
...
...
@@ -13,7 +13,6 @@ XXX TO DO:
import
os
import
sys
import
pyclbr
import
re
from
idlelib
import
PyShell
from
idlelib.WindowList
import
ListedToplevel
...
...
@@ -223,6 +222,7 @@ def _class_browser(parent): #Wrapper for htest
name
=
os
.
path
.
splitext
(
file
)[
0
]
flist
=
PyShell
.
PyShellFileList
(
parent
)
ClassBrowser
(
flist
,
name
,
[
dir
],
_htest
=
True
)
parent
.
mainloop
()
if
__name__
==
"__main__"
:
from
idlelib.idle_test.htest
import
run
...
...
Lib/idlelib/ColorDelegator.py
View file @
c7388740
...
...
@@ -259,11 +259,9 @@ def _color_delegator(parent):
root
.
title
(
"Test ColorDelegator"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
with
open
(
__file__
,
'r'
)
as
f
:
source
=
f
.
read
()
source
=
"if somename: x = 'abc' # comment
\
n
print"
text
=
Text
(
root
,
background
=
"white"
)
# insert only a sample portion
text
.
insert
(
"insert"
,
source
[:
690
])
text
.
insert
(
"insert"
,
source
)
text
.
pack
(
expand
=
1
,
fill
=
"both"
)
p
=
Percolator
(
text
)
d
=
ColorDelegator
()
...
...
Lib/idlelib/EditorWindow.py
View file @
c7388740
...
...
@@ -1705,18 +1705,15 @@ def fixwordbreaks(root):
def
_editor_window
(
parent
):
root
=
parent
fixwordbreaks
(
root
)
## root.withdraw()
if
sys
.
argv
[
1
:]:
filename
=
sys
.
argv
[
1
]
else
:
filename
=
None
macosxSupport
.
setupApp
(
root
,
None
)
edit
=
EditorWindow
(
root
=
root
,
filename
=
filename
)
## edit.set_close_hook(root.qui
t)
## edit.text.bind("<<close-all-windows>>", edit.close_event
)
edit
.
text
.
bind
(
"<<close-all-windows>>"
,
edit
.
close_even
t
)
parent
.
mainloop
(
)
if
__name__
==
'__main__'
:
from
idlelib.idle_test.htest
import
run
if
len
(
sys
.
argv
)
<=
1
:
run
(
_help_dialog
)
run
(
_editor_window
)
run
(
_help_dialog
,
_editor_window
)
Lib/idlelib/PathBrowser.py
View file @
c7388740
import
os
import
sys
import
re
import
importlib.machinery
from
idlelib.TreeWidget
import
TreeItem
...
...
@@ -97,6 +96,7 @@ class DirBrowserTreeItem(TreeItem):
def
_path_browser
(
parent
):
flist
=
PyShellFileList
(
parent
)
PathBrowser
(
flist
,
_htest
=
True
)
parent
.
mainloop
()
if
__name__
==
"__main__"
:
from
unittest
import
main
...
...
Lib/idlelib/Percolator.py
View file @
c7388740
...
...
@@ -51,8 +51,9 @@ class Percolator:
f
.
setdelegate
(
filter
.
delegate
)
filter
.
setdelegate
(
None
)
def
main
():
import
tkinter
as
Tk
def
_percolator
(
parent
):
import
tkinter
as
tk
import
re
class
Tracer
(
Delegator
):
def
__init__
(
self
,
name
):
self
.
name
=
name
...
...
@@ -63,22 +64,41 @@ def main():
def
delete
(
self
,
*
args
):
print
(
self
.
name
,
": delete"
,
args
)
self
.
delegate
.
delete
(
*
args
)
root
=
T
k
.
Tk
()
root
.
wm_protocol
(
"WM_DELETE_WINDOW"
,
root
.
quit
)
text
=
Tk
.
Text
(
)
text
.
pack
(
)
text
.
focus_set
(
)
root
=
t
k
.
Tk
()
root
.
title
(
"Test Percolator"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
()))
)
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
)
)
text
=
tk
.
Text
(
root
)
p
=
Percolator
(
text
)
t1
=
Tracer
(
"t1"
)
t2
=
Tracer
(
"t2"
)
p
.
insertfilter
(
t1
)
p
.
insertfilter
(
t2
)
root
.
mainloop
()
# click close widget to continue...
p
.
removefilter
(
t2
)
root
.
mainloop
()
p
.
insertfilter
(
t2
)
p
.
removefilter
(
t1
)
def
toggle1
():
if
var1
.
get
()
==
0
:
var1
.
set
(
1
)
p
.
insertfilter
(
t1
)
elif
var1
.
get
()
==
1
:
var1
.
set
(
0
)
p
.
removefilter
(
t1
)
def
toggle2
():
if
var2
.
get
()
==
0
:
var2
.
set
(
1
)
p
.
insertfilter
(
t2
)
elif
var2
.
get
()
==
1
:
var2
.
set
(
0
)
p
.
removefilter
(
t2
)
text
.
pack
()
var1
=
tk
.
IntVar
()
cb1
=
tk
.
Checkbutton
(
root
,
text
=
"Tracer1"
,
command
=
toggle1
,
variable
=
var1
)
cb1
.
pack
()
var2
=
tk
.
IntVar
()
cb2
=
tk
.
Checkbutton
(
root
,
text
=
"Tracer2"
,
command
=
toggle2
,
variable
=
var2
)
cb2
.
pack
()
root
.
mainloop
()
if
__name__
==
"__main__"
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_percolator
)
Lib/idlelib/StackViewer.py
View file @
c7388740
import
os
import
sys
import
linecache
import
re
import
tkinter
as
tk
from
idlelib.TreeWidget
import
TreeNode
,
TreeItem
,
ScrolledCanvas
from
idlelib.ObjectBrowser
import
ObjectTreeItem
,
make_objecttreeitem
from
idlelib.PyShell
import
PyShellFileList
def
StackBrowser
(
root
,
flist
=
None
,
tb
=
None
,
top
=
None
):
if
top
is
None
:
...
...
@@ -120,3 +123,30 @@ class VariablesTreeItem(ObjectTreeItem):
item
=
make_objecttreeitem
(
key
+
" ="
,
value
,
setfunction
)
sublist
.
append
(
item
)
return
sublist
def
_stack_viewer
(
parent
):
root
=
tk
.
Tk
()
root
.
title
(
"Test StackViewer"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
flist
=
PyShellFileList
(
root
)
try
:
# to obtain a traceback object
a
except
:
exc_type
,
exc_value
,
exc_tb
=
sys
.
exc_info
()
# inject stack trace to sys
sys
.
last_type
=
exc_type
sys
.
last_value
=
exc_value
sys
.
last_traceback
=
exc_tb
StackBrowser
(
root
,
flist
=
flist
,
top
=
root
,
tb
=
exc_tb
)
# restore sys to original state
del
sys
.
last_type
del
sys
.
last_value
del
sys
.
last_traceback
if
__name__
==
'__main__'
:
from
idlelib.idle_test.htest
import
run
run
(
_stack_viewer
)
Lib/idlelib/ToolTip.py
View file @
c7388740
...
...
@@ -87,8 +87,9 @@ def _tooltip(parent):
button2
=
Button
(
root
,
text
=
"Button 2"
)
button1
.
pack
()
button2
.
pack
()
ToolTip
(
button1
,
"This is calltip text for button1."
)
ListboxToolTip
(
button2
,
[
"This is"
,
"calltip text"
,
"for button2"
])
ToolTip
(
button1
,
"This is tooltip text for button1."
)
ListboxToolTip
(
button2
,
[
"This is"
,
"multiple line"
,
"tooltip text"
,
"for button2"
])
root
.
mainloop
()
if
__name__
==
'__main__'
:
...
...
Lib/idlelib/idle_test/htest.py
View file @
c7388740
...
...
@@ -53,8 +53,9 @@ _class_browser_spec = {
'file'
:
'ClassBrowser'
,
'kwds'
:
{},
'msg'
:
"Inspect names of module, class(with superclass if "
"applicable), methods and functions.
\
n
Toggle nested items."
"
\
n
N.S: Double click on items does not work"
,
"applicable), methods and functions.
\
n
Toggle nested items.
\
n
"
"Double clicking on items prints a traceback print a traceback "
"for an exception that is ignored."
}
_color_delegator_spec
=
{
...
...
@@ -74,11 +75,11 @@ _dyn_option_menu_spec = {
"Select one of the many options in the 'new option set'."
}
#
_editor_window_spec = {
#
'file': 'EditorWindow',
#
'kwds': {},
# 'msg': "Test editor functions of interest
"
#
}
_editor_window_spec
=
{
'file'
:
'EditorWindow'
,
'kwds'
:
{},
'msg'
:
"Test editor functions of interest.
"
}
GetCfgSectionNameDialog_spec
=
{
'file'
:
'configSectionNameDialog'
,
...
...
@@ -91,6 +92,7 @@ GetCfgSectionNameDialog_spec = {
"Close 'Get Name' with a valid entry (printed to Shell), "
"[Cancel], or [X]"
,
}
GetHelpSourceDialog_spec
=
{
'file'
:
'configHelpSourceEdit'
,
'kwds'
:
{
'title'
:
'Get helpsource'
,
...
...
@@ -103,10 +105,27 @@ GetHelpSourceDialog_spec = {
"[Cancel] will print None to shell"
,
}
# Update once issue21519 is resolved.
GetKeysDialog_spec
=
{
'file'
:
'keybindingDialog'
,
'kwds'
:
{
'title'
:
'Test keybindings'
,
'action'
:
'find-again'
,
'currentKeySequences'
:
[
''
]
,
'_htest'
:
True
,
},
'msg'
:
"Test for different key modifier sequences.
\
n
"
"<nothing> is invalid.
\
n
"
"No modifier key is invalid.
\
n
"
"Shift key with [a-z],[0-9], function key, move key, tab, space"
"is invalid.
\
n
No validitity checking if advanced key binding "
"entry is used."
}
_help_dialog_spec
=
{
'file'
:
'EditorWindow'
,
'kwds'
:
{},
'msg'
:
"If the help text displays, this works"
'msg'
:
"If the help text displays, this works.
\
n
"
"Text is selectable. Window is scrollable."
}
_io_binding_spec
=
{
...
...
@@ -115,17 +134,16 @@ _io_binding_spec = {
'msg'
:
"Test the following bindings
\
n
"
"<Control-o> to display open window from file dialog.
\
n
"
"<Control-s> to save the file
\
n
"
}
_multi_call_spec
=
{
'file'
:
'MultiCall'
,
'kwds'
:
{},
'msg'
:
"The following actions should trigger a print to console
.
\
n
"
"
Entering and leaving the text area, key entry, <Control-Key>,
\
n
"
"<
Alt-Key-a>, <Control-Key-a>, <Alt-Control-Key-a>,
\
n
"
"<
Control-Button-1>, <Alt-Button-1> and focussing out of the window
\
n
"
"are sequences to be tested."
'msg'
:
"The following actions should trigger a print to console
or IDLE
"
"
Shell.
\
n
Entering and leaving the text area, key entry,
"
"<
Control-Key>,
\
n
<Alt-Key-a>, <Control-Key-a>,
"
"<
Alt-Control-Key-a>,
\
n
<Control-Button-1>, <Alt-Button-1> and
"
"
focusing out of the window
\
n
are sequences to be tested."
}
_multistatus_bar_spec
=
{
...
...
@@ -146,18 +164,38 @@ _object_browser_spec = {
_path_browser_spec
=
{
'file'
:
'PathBrowser'
,
'kwds'
:
{},
'msg'
:
"Test for correct display of all paths in sys.path."
"
\
n
Toggle nested items upto the lowest level."
"
\
n
N.S: Double click on items does not work."
'msg'
:
"Test for correct display of all paths in sys.path.
\
n
"
"Toggle nested items upto the lowest level.
\
n
"
"Double clicking on an item prints a traceback
\
n
"
"for an exception that is ignored."
}
_percolator_spec
=
{
'file'
:
'Percolator'
,
'kwds'
:
{},
'msg'
:
"There are two tracers which can be toggled using a checkbox.
\
n
"
"Toggling a tracer 'on' by checking it should print tracer"
"output to the console or to the IDLE shell.
\
n
"
"If both the tracers are 'on', the output from the tracer which "
"was switched 'on' later, should be printed first
\
n
"
"Test for actions like text entry, and removal."
}
_scrolled_list_spec
=
{
'file'
:
'ScrolledList'
,
'kwds'
:
{},
'msg'
:
"You should see a scrollable list of items
\
n
"
"Selecting an item will print it to console.
\
n
"
"Double clicking an item will print it to console
\
n
"
"Right click on an item will display a popup."
"Selecting (clicking) or double clicking an item "
"prints the name to the console or Idle shell.
\
n
"
"Right clicking an item will display a popup."
}
_stack_viewer_spec
=
{
'file'
:
'StackViewer'
,
'kwds'
:
{},
'msg'
:
"A stacktrace for a NameError exception.
\
n
"
"Expand 'idlelib ...' and '<locals>'.
\
n
"
"Check that exc_value, exc_tb, and exc_type are correct.
\
n
"
}
_tabbed_pages_spec
=
{
...
...
@@ -189,7 +227,7 @@ _tooltip_spec = {
_tree_widget_spec
=
{
'file'
:
'TreeWidget'
,
'kwds'
:
{},
'msg'
:
"You should see two canvas
'
side-by-side.
\
n
"
'msg'
:
"You should see two canvas
es
side-by-side.
\
n
"
"The left canvas is scrollable.
\
n
"
"The right canvas is not scrollable.
\
n
"
"Click on folders upto to the lowest level."
...
...
@@ -198,29 +236,27 @@ _tree_widget_spec = {
_widget_redirector_spec
=
{
'file'
:
'WidgetRedirector'
,
'kwds'
:
{},
'msg'
:
"Every text insert should be printed to console."
'msg'
:
"Every text insert should be printed to the console."
"or the IDLE shell."
}
def
run
(
test
=
None
):
def
run
(
*
tests
):
root
=
tk
.
Tk
()
test_list
=
[]
# List of tuples of the form (spec, kwds, callable widget)
if
test
:
test_spec
=
globals
()[
test
.
__name__
+
'_spec'
]
test_spec
[
'name'
]
=
test
.
__name__
test_kwds
=
test_spec
[
'kwds'
]
test_kwds
[
'parent'
]
=
root
test_list
.
append
((
test_spec
,
test_kwds
,
test
))
test_list
=
[]
# List of tuples of the form (spec, callable widget)
if
tests
:
for
test
in
tests
:
test_spec
=
globals
()[
test
.
__name__
+
'_spec'
]
test_spec
[
'name'
]
=
test
.
__name__
test_list
.
append
((
test_spec
,
test
))
else
:
for
k
,
d
in
globals
().
items
():
if
k
.
endswith
(
'_spec'
):
test_name
=
k
[:
-
5
]
test_spec
=
d
test_spec
[
'name'
]
=
test_name
test_kwds
=
test_spec
[
'kwds'
]
test_kwds
[
'parent'
]
=
root
mod
=
import_module
(
'idlelib.'
+
test_spec
[
'file'
])
test
=
getattr
(
mod
,
test_name
)
test_list
.
append
((
test_spec
,
test
_kwds
,
test
))
test_list
.
append
((
test_spec
,
test
))
help_string
=
tk
.
StringVar
(
''
)
test_name
=
tk
.
StringVar
(
''
)
...
...
@@ -232,10 +268,11 @@ def run(test=None):
nonlocal
help_string
,
test_name
,
callable_object
,
test_kwds
if
len
(
test_list
)
==
1
:
next_button
.
pack_forget
()
test_spec
,
test_kwds
,
test
=
test_list
.
pop
()
test_spec
,
callable_object
=
test_list
.
pop
()
test_kwds
=
test_spec
[
'kwds'
]
test_kwds
[
'parent'
]
=
root
help_string
.
set
(
test_spec
[
'msg'
])
test_name
.
set
(
'test '
+
test_spec
[
'name'
])
callable_object
=
test
test_name
.
set
(
'Test '
+
test_spec
[
'name'
])
def
run_test
():
...
...
Lib/idlelib/keybindingDialog.py
View file @
c7388740
...
...
@@ -7,12 +7,13 @@ import string
import
sys
class
GetKeysDialog
(
Toplevel
):
def
__init__
(
self
,
parent
,
title
,
action
,
currentKeySequences
):
def
__init__
(
self
,
parent
,
title
,
action
,
currentKeySequences
,
_htest
=
False
):
"""
action - string, the name of the virtual event these keys will be
mapped to
currentKeys - list, a list of all key sequence lists currently mapped
to virtual events, for overlap checking
_htest - bool, change box location when running htest
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
...
...
@@ -38,11 +39,14 @@ class GetKeysDialog(Toplevel):
self
.
LoadFinalKeyList
()
self
.
withdraw
()
#hide while setting geometry
self
.
update_idletasks
()
self
.
geometry
(
"+%d+%d"
%
((
parent
.
winfo_rootx
()
+
((
parent
.
winfo_width
()
/
2
)
-
(
self
.
winfo_reqwidth
()
/
2
)),
parent
.
winfo_rooty
()
+
((
parent
.
winfo_height
()
/
2
)
-
(
self
.
winfo_reqheight
()
/
2
))
))
)
#centre dialog over parent
self
.
geometry
(
"+%d+%d"
%
(
parent
.
winfo_rootx
()
+
(
parent
.
winfo_width
()
/
2
-
self
.
winfo_reqwidth
()
/
2
),
parent
.
winfo_rooty
()
+
((
parent
.
winfo_height
()
/
2
-
self
.
winfo_reqheight
()
/
2
)
if
not
_htest
else
150
)
)
)
#centre dialog over parent (or below htest box)
self
.
deiconify
()
#geometry set, unhide
self
.
wait_window
()
...
...
@@ -258,11 +262,5 @@ class GetKeysDialog(Toplevel):
return
keysOK
if
__name__
==
'__main__'
:
#test the dialog
root
=
Tk
()
def
run
():
keySeq
=
''
dlg
=
GetKeysDialog
(
root
,
'Get Keys'
,
'find-again'
,[])
print
(
dlg
.
result
)
Button
(
root
,
text
=
'Dialog'
,
command
=
run
).
pack
()
root
.
mainloop
()
from
idlelib.idle_test.htest
import
run
run
(
GetKeysDialog
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment