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
62012fc7
Commit
62012fc7
authored
May 24, 2014
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21477: Idle htest: merge and modify run and runall; add many tests.
Patch by Saimadhav Heblikar
parent
d383bafa
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
415 additions
and
179 deletions
+415
-179
Lib/idlelib/CallTipWindow.py
Lib/idlelib/CallTipWindow.py
+30
-31
Lib/idlelib/ClassBrowser.py
Lib/idlelib/ClassBrowser.py
+14
-6
Lib/idlelib/ColorDelegator.py
Lib/idlelib/ColorDelegator.py
+13
-5
Lib/idlelib/IOBinding.py
Lib/idlelib/IOBinding.py
+7
-9
Lib/idlelib/MultiCall.py
Lib/idlelib/MultiCall.py
+10
-2
Lib/idlelib/MultiStatusBar.py
Lib/idlelib/MultiStatusBar.py
+24
-11
Lib/idlelib/ObjectBrowser.py
Lib/idlelib/ObjectBrowser.py
+7
-3
Lib/idlelib/PathBrowser.py
Lib/idlelib/PathBrowser.py
+14
-6
Lib/idlelib/ScrolledList.py
Lib/idlelib/ScrolledList.py
+10
-9
Lib/idlelib/ToolTip.py
Lib/idlelib/ToolTip.py
+14
-7
Lib/idlelib/TreeWidget.py
Lib/idlelib/TreeWidget.py
+15
-17
Lib/idlelib/WidgetRedirector.py
Lib/idlelib/WidgetRedirector.py
+7
-8
Lib/idlelib/aboutDialog.py
Lib/idlelib/aboutDialog.py
+8
-3
Lib/idlelib/configHelpSourceEdit.py
Lib/idlelib/configHelpSourceEdit.py
+12
-15
Lib/idlelib/dynOptionMenuWidget.py
Lib/idlelib/dynOptionMenuWidget.py
+24
-2
Lib/idlelib/idle_test/htest.py
Lib/idlelib/idle_test/htest.py
+190
-23
Lib/idlelib/tabbedpages.py
Lib/idlelib/tabbedpages.py
+9
-1
Lib/idlelib/textView.py
Lib/idlelib/textView.py
+7
-21
No files found.
Lib/idlelib/CallTipWindow.py
View file @
62012fc7
...
@@ -133,14 +133,14 @@ class CallTip:
...
@@ -133,14 +133,14 @@ class CallTip:
return
bool
(
self
.
tipwindow
)
return
bool
(
self
.
tipwindow
)
def
_calltip_window
(
parent
):
root
=
Tk
()
root
.
title
(
"Test calltips"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
###############################
class
MyEditWin
:
# comparenceptually an editor_window
#
# Test Code
#
class
container
:
# Conceptually an editor_window
def
__init__
(
self
):
def
__init__
(
self
):
root
=
Tk
()
text
=
self
.
text
=
Text
(
root
)
text
=
self
.
text
=
Text
(
root
)
text
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text
.
insert
(
"insert"
,
"string.split"
)
text
.
insert
(
"insert"
,
"string.split"
)
...
@@ -156,14 +156,13 @@ class container: # Conceptually an editor_window
...
@@ -156,14 +156,13 @@ class container: # Conceptually an editor_window
root
.
mainloop
()
root
.
mainloop
()
def
calltip_show
(
self
,
event
):
def
calltip_show
(
self
,
event
):
self
.
calltip
.
showtip
(
"Hello worl
d"
)
self
.
calltip
.
showtip
(
"Hello world"
,
"insert"
,
"en
d"
)
def
calltip_hide
(
self
,
event
):
def
calltip_hide
(
self
,
event
):
self
.
calltip
.
hidetip
()
self
.
calltip
.
hidetip
()
def
main
():
editwin
=
MyEditWin
()
# Test code
c
=
container
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_calltip_window
)
Lib/idlelib/ClassBrowser.py
View file @
62012fc7
...
@@ -13,6 +13,7 @@ XXX TO DO:
...
@@ -13,6 +13,7 @@ XXX TO DO:
import
os
import
os
import
sys
import
sys
import
pyclbr
import
pyclbr
import
re
from
idlelib
import
PyShell
from
idlelib
import
PyShell
from
idlelib.WindowList
import
ListedToplevel
from
idlelib.WindowList
import
ListedToplevel
...
@@ -21,11 +22,15 @@ from idlelib.configHandler import idleConf
...
@@ -21,11 +22,15 @@ from idlelib.configHandler import idleConf
class
ClassBrowser
:
class
ClassBrowser
:
def
__init__
(
self
,
flist
,
name
,
path
):
def
__init__
(
self
,
flist
,
name
,
path
,
_htest
=
False
):
# XXX This API should change, if the file doesn't end in ".py"
# XXX This API should change, if the file doesn't end in ".py"
# XXX the code here is bogus!
# XXX the code here is bogus!
"""
_htest - bool, change box when location running htest.
"""
self
.
name
=
name
self
.
name
=
name
self
.
file
=
os
.
path
.
join
(
path
[
0
],
self
.
name
+
".py"
)
self
.
file
=
os
.
path
.
join
(
path
[
0
],
self
.
name
+
".py"
)
self
.
_htest
=
_htest
self
.
init
(
flist
)
self
.
init
(
flist
)
def
close
(
self
,
event
=
None
):
def
close
(
self
,
event
=
None
):
...
@@ -40,6 +45,9 @@ class ClassBrowser:
...
@@ -40,6 +45,9 @@ class ClassBrowser:
self
.
top
=
top
=
ListedToplevel
(
flist
.
root
)
self
.
top
=
top
=
ListedToplevel
(
flist
.
root
)
top
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
close
)
top
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
close
)
top
.
bind
(
"<Escape>"
,
self
.
close
)
top
.
bind
(
"<Escape>"
,
self
.
close
)
if
self
.
_htest
:
# place dialog below parent if running htest
top
.
geometry
(
"+%d+%d"
%
(
flist
.
root
.
winfo_rootx
(),
flist
.
root
.
winfo_rooty
()
+
200
))
self
.
settitle
()
self
.
settitle
()
top
.
focus_set
()
top
.
focus_set
()
# create scrolled canvas
# create scrolled canvas
...
@@ -202,7 +210,7 @@ class MethodBrowserTreeItem(TreeItem):
...
@@ -202,7 +210,7 @@ class MethodBrowserTreeItem(TreeItem):
edit
=
PyShell
.
flist
.
open
(
self
.
file
)
edit
=
PyShell
.
flist
.
open
(
self
.
file
)
edit
.
gotoline
(
self
.
cl
.
methods
[
self
.
name
])
edit
.
gotoline
(
self
.
cl
.
methods
[
self
.
name
])
def
main
():
def
_class_browser
(
parent
):
#Wrapper for htest
try
:
try
:
file
=
__file__
file
=
__file__
except
NameError
:
except
NameError
:
...
@@ -213,9 +221,9 @@ def main():
...
@@ -213,9 +221,9 @@ def main():
file
=
sys
.
argv
[
0
]
file
=
sys
.
argv
[
0
]
dir
,
file
=
os
.
path
.
split
(
file
)
dir
,
file
=
os
.
path
.
split
(
file
)
name
=
os
.
path
.
splitext
(
file
)[
0
]
name
=
os
.
path
.
splitext
(
file
)[
0
]
ClassBrowser
(
PyShell
.
flist
,
name
,
[
dir
])
flist
=
PyShell
.
PyShellFileList
(
parent
)
if
sys
.
stdin
is
sys
.
__stdin__
:
ClassBrowser
(
flist
,
name
,
[
dir
],
_htest
=
True
)
mainloop
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_class_browser
)
Lib/idlelib/ColorDelegator.py
View file @
62012fc7
...
@@ -255,17 +255,25 @@ class ColorDelegator(Delegator):
...
@@ -255,17 +255,25 @@ class ColorDelegator(Delegator):
for
tag
in
self
.
tagdefs
.
keys
():
for
tag
in
self
.
tagdefs
.
keys
():
self
.
tag_remove
(
tag
,
"1.0"
,
"end"
)
self
.
tag_remove
(
tag
,
"1.0"
,
"end"
)
def
main
(
):
def
_color_delegator
(
parent
):
from
idlelib.Percolator
import
Percolator
from
idlelib.Percolator
import
Percolator
root
=
Tk
()
root
=
Tk
()
root
.
wm_protocol
(
"WM_DELETE_WINDOW"
,
root
.
quit
)
root
.
title
(
"Test ColorDelegator"
)
text
=
Text
(
background
=
"white"
)
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"
text
=
Text
(
root
,
background
=
"white"
)
# insert only a sample portion
## text.insert("insert", source[:690])
text
.
insert
(
"insert"
,
source
[:
690
])
text
.
pack
(
expand
=
1
,
fill
=
"both"
)
text
.
pack
(
expand
=
1
,
fill
=
"both"
)
text
.
focus_set
()
p
=
Percolator
(
text
)
p
=
Percolator
(
text
)
d
=
ColorDelegator
()
d
=
ColorDelegator
()
p
.
insertfilter
(
d
)
p
.
insertfilter
(
d
)
root
.
mainloop
()
root
.
mainloop
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_color_delegator
)
Lib/idlelib/IOBinding.py
View file @
62012fc7
...
@@ -565,16 +565,17 @@ class IOBinding:
...
@@ -565,16 +565,17 @@ class IOBinding:
"Update recent file list on all editor windows"
"Update recent file list on all editor windows"
self
.
editwin
.
update_recent_files_list
(
filename
)
self
.
editwin
.
update_recent_files_list
(
filename
)
def
test
(
):
def
_io_binding
(
parent
):
root
=
Tk
()
root
=
Tk
()
root
.
title
(
"Test IOBinding"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
class
MyEditWin
:
class
MyEditWin
:
def
__init__
(
self
,
text
):
def
__init__
(
self
,
text
):
self
.
text
=
text
self
.
text
=
text
self
.
flist
=
None
self
.
flist
=
None
self
.
text
.
bind
(
"<Control-o>"
,
self
.
open
)
self
.
text
.
bind
(
"<Control-o>"
,
self
.
open
)
self
.
text
.
bind
(
"<Control-s>"
,
self
.
save
)
self
.
text
.
bind
(
"<Control-s>"
,
self
.
save
)
self
.
text
.
bind
(
"<Alt-s>"
,
self
.
save_as
)
self
.
text
.
bind
(
"<Alt-z>"
,
self
.
save_a_copy
)
def
get_saved
(
self
):
return
0
def
get_saved
(
self
):
return
0
def
set_saved
(
self
,
flag
):
pass
def
set_saved
(
self
,
flag
):
pass
def
reset_undo
(
self
):
pass
def
reset_undo
(
self
):
pass
...
@@ -582,16 +583,13 @@ def test():
...
@@ -582,16 +583,13 @@ def test():
self
.
text
.
event_generate
(
"<<open-window-from-file>>"
)
self
.
text
.
event_generate
(
"<<open-window-from-file>>"
)
def
save
(
self
,
event
):
def
save
(
self
,
event
):
self
.
text
.
event_generate
(
"<<save-window>>"
)
self
.
text
.
event_generate
(
"<<save-window>>"
)
def
save_as
(
self
,
event
):
self
.
text
.
event_generate
(
"<<save-window-as-file>>"
)
def
save_a_copy
(
self
,
event
):
self
.
text
.
event_generate
(
"<<save-copy-of-window-as-file>>"
)
text
=
Text
(
root
)
text
=
Text
(
root
)
text
.
pack
()
text
.
pack
()
text
.
focus_set
()
text
.
focus_set
()
editwin
=
MyEditWin
(
text
)
editwin
=
MyEditWin
(
text
)
io
=
IOBinding
(
editwin
)
io
=
IOBinding
(
editwin
)
root
.
mainloop
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test
()
from
idlelib.idle_test.htest
import
run
run
(
_io_binding
)
Lib/idlelib/MultiCall.py
View file @
62012fc7
...
@@ -397,9 +397,12 @@ def MultiCallCreator(widget):
...
@@ -397,9 +397,12 @@ def MultiCallCreator(widget):
_multicall_dict[widget] = MultiCall
_multicall_dict[widget] = MultiCall
return MultiCall
return MultiCall
if __name__ == "
__main__
":
# Test
def _multi_call(parent):
root = Tkinter.Tk()
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 = MultiCallCreator(Tkinter.Text)(root)
text.pack()
text.pack()
def bindseq(seq, n=[0]):
def bindseq(seq, n=[0]):
...
@@ -415,8 +418,13 @@ if __name__ == "__main__":
...
@@ -415,8 +418,13 @@ if __name__ == "__main__":
bindseq("
<
Alt
-
Control
-
Key
-
a
>
")
bindseq("
<
Alt
-
Control
-
Key
-
a
>
")
bindseq("
<
Key
-
b
>
")
bindseq("
<
Key
-
b
>
")
bindseq("
<
Control
-
Button
-
1
>
")
bindseq("
<
Control
-
Button
-
1
>
")
bindseq("
<
Button
-
2
>
")
bindseq("
<
Alt
-
Button
-
1
>
")
bindseq("
<
Alt
-
Button
-
1
>
")
bindseq("
<
FocusOut
>
")
bindseq("
<
FocusOut
>
")
bindseq("
<
Enter
>
")
bindseq("
<
Enter
>
")
bindseq("
<
Leave
>
")
bindseq("
<
Leave
>
")
root.mainloop()
root.mainloop()
if __name__ == "
__main__
":
from idlelib.idle_test.htest import run
run(_multi_call)
Lib/idlelib/MultiStatusBar.py
View file @
62012fc7
...
@@ -17,16 +17,29 @@ class MultiStatusBar(Frame):
...
@@ -17,16 +17,29 @@ class MultiStatusBar(Frame):
label
=
self
.
labels
[
name
]
label
=
self
.
labels
[
name
]
label
.
config
(
text
=
text
)
label
.
config
(
text
=
text
)
def
_test
():
def
_multistatus_bar
(
parent
):
b
=
Frame
()
root
=
Tk
()
c
=
Text
(
b
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
c
.
pack
(
side
=
TOP
)
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
a
=
MultiStatusBar
(
b
)
root
.
title
(
"Test multistatus bar"
)
a
.
set_label
(
"one"
,
"hello"
)
frame
=
Frame
(
root
)
a
.
set_label
(
"two"
,
"world"
)
text
=
Text
(
frame
)
a
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
text
.
pack
()
b
.
pack
()
msb
=
MultiStatusBar
(
frame
)
b
.
mainloop
()
msb
.
set_label
(
"one"
,
"hello"
)
msb
.
set_label
(
"two"
,
"world"
)
msb
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
def
change
():
msb
.
set_label
(
"one"
,
"foo"
)
msb
.
set_label
(
"two"
,
"bar"
)
button
=
Button
(
root
,
text
=
"Update status"
,
command
=
change
)
button
.
pack
(
side
=
BOTTOM
)
frame
.
pack
()
frame
.
mainloop
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
_test
()
from
idlelib.idle_test.htest
import
run
run
(
_multistatus_bar
)
Lib/idlelib/ObjectBrowser.py
View file @
62012fc7
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
# XXX TO DO:
# XXX TO DO:
# - for classes/modules, add "open source" to object browser
# - for classes/modules, add "open source" to object browser
import
re
from
idlelib.TreeWidget
import
TreeItem
,
TreeNode
,
ScrolledCanvas
from
idlelib.TreeWidget
import
TreeItem
,
TreeNode
,
ScrolledCanvas
from
repr
import
Repr
from
repr
import
Repr
...
@@ -132,12 +134,13 @@ def make_objecttreeitem(labeltext, object, setfunction=None):
...
@@ -132,12 +134,13 @@ def make_objecttreeitem(labeltext, object, setfunction=None):
c
=
ObjectTreeItem
c
=
ObjectTreeItem
return
c
(
labeltext
,
object
,
setfunction
)
return
c
(
labeltext
,
object
,
setfunction
)
# Test script
def
_
test
(
):
def
_
object_browser
(
parent
):
import
sys
import
sys
from
Tkinter
import
Tk
from
Tkinter
import
Tk
root
=
Tk
()
root
=
Tk
()
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
100
))
root
.
configure
(
bd
=
0
,
bg
=
"yellow"
)
root
.
configure
(
bd
=
0
,
bg
=
"yellow"
)
root
.
focus_set
()
root
.
focus_set
()
sc
=
ScrolledCanvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
,
takefocus
=
1
)
sc
=
ScrolledCanvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
,
takefocus
=
1
)
...
@@ -148,4 +151,5 @@ def _test():
...
@@ -148,4 +151,5 @@ def _test():
root
.
mainloop
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
_test
()
from
idlelib.idle_test.htest
import
run
run
(
_object_browser
)
Lib/idlelib/PathBrowser.py
View file @
62012fc7
import
os
import
os
import
sys
import
sys
import
re
import
imp
import
imp
from
idlelib.TreeWidget
import
TreeItem
from
idlelib.TreeWidget
import
TreeItem
from
idlelib.ClassBrowser
import
ClassBrowser
,
ModuleBrowserTreeItem
from
idlelib.ClassBrowser
import
ClassBrowser
,
ModuleBrowserTreeItem
from
idlelib.PyShell
import
PyShellFileList
class
PathBrowser
(
ClassBrowser
):
class
PathBrowser
(
ClassBrowser
):
def
__init__
(
self
,
flist
):
def
__init__
(
self
,
flist
,
_htest
=
False
):
"""
_htest - bool, change box location when running htest
"""
self
.
_htest
=
_htest
self
.
init
(
flist
)
self
.
init
(
flist
)
def
settitle
(
self
):
def
settitle
(
self
):
...
@@ -85,12 +92,13 @@ class DirBrowserTreeItem(TreeItem):
...
@@ -85,12 +92,13 @@ class DirBrowserTreeItem(TreeItem):
sorted
.
sort
()
sorted
.
sort
()
return
sorted
return
sorted
def
main
():
def
_path_browser
(
parent
):
from
idlelib
import
PyShell
flist
=
PyShellFileList
(
parent
)
PathBrowser
(
PyShell
.
flist
)
PathBrowser
(
flist
,
_htest
=
True
)
if
sys
.
stdin
is
sys
.
__stdin__
:
mainloop
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
from
unittest
import
main
from
unittest
import
main
main
(
'idlelib.idle_test.test_pathbrowser'
,
verbosity
=
2
,
exit
=
False
)
main
(
'idlelib.idle_test.test_pathbrowser'
,
verbosity
=
2
,
exit
=
False
)
from
idlelib.idle_test.htest
import
run
run
(
_path_browser
)
Lib/idlelib/ScrolledList.py
View file @
62012fc7
...
@@ -119,21 +119,22 @@ class ScrolledList:
...
@@ -119,21 +119,22 @@ class ScrolledList:
pass
pass
def
test
(
):
def
_scrolled_list
(
parent
):
root
=
Tk
()
root
=
Tk
()
root
.
protocol
(
"WM_DELETE_WINDOW"
,
root
.
destroy
)
root
.
title
(
"Test ScrolledList"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
class
MyScrolledList
(
ScrolledList
):
class
MyScrolledList
(
ScrolledList
):
def
fill_menu
(
self
):
self
.
menu
.
add_command
(
label
=
"
pass
"
)
def
fill_menu
(
self
):
self
.
menu
.
add_command
(
label
=
"
right click
"
)
def
on_select
(
self
,
index
):
print
"select"
,
self
.
get
(
index
)
def
on_select
(
self
,
index
):
print
"select"
,
self
.
get
(
index
)
def
on_double
(
self
,
index
):
print
"double"
,
self
.
get
(
index
)
def
on_double
(
self
,
index
):
print
"double"
,
self
.
get
(
index
)
s
=
MyScrolledList
(
root
)
scrolled_list
=
MyScrolledList
(
root
)
for
i
in
range
(
30
):
for
i
in
range
(
30
):
s
.
append
(
"item %02d"
%
i
)
scrolled_list
.
append
(
"Item %02d"
%
i
)
return
root
def
main
():
root
=
test
()
root
.
mainloop
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_scrolled_list
)
Lib/idlelib/ToolTip.py
View file @
62012fc7
...
@@ -76,14 +76,21 @@ class ListboxToolTip(ToolTipBase):
...
@@ -76,14 +76,21 @@ class ListboxToolTip(ToolTipBase):
for
item
in
self
.
items
:
for
item
in
self
.
items
:
listbox
.
insert
(
END
,
item
)
listbox
.
insert
(
END
,
item
)
def
main
():
def
_tooltip
(
parent
):
# Test code
root
=
Tk
()
root
=
Tk
()
b
=
Button
(
root
,
text
=
"Hello"
,
command
=
root
.
destroy
)
root
.
title
(
"Test tooltip"
)
b
.
pack
()
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
update
()
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
tip
=
ListboxToolTip
(
b
,
[
"Hello"
,
"world"
])
label
=
Label
(
root
,
text
=
"Place your mouse over buttons"
)
label
.
pack
()
button1
=
Button
(
root
,
text
=
"Button 1"
)
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"
])
root
.
mainloop
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_tooltip
)
Lib/idlelib/TreeWidget.py
View file @
62012fc7
...
@@ -449,29 +449,27 @@ class ScrolledCanvas:
...
@@ -449,29 +449,27 @@ class ScrolledCanvas:
return
"break"
return
"break"
# Testing functions
def
_tree_widget
(
parent
):
root
=
Tk
()
def
test
():
root
.
title
(
"Test TreeWidget"
)
from
idlelib
import
PyShell
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
=
Toplevel
(
PyShell
.
root
)
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
root
.
configure
(
bd
=
0
,
bg
=
"yellow"
)
# test with scrollable canvas
root
.
focus_set
()
sc
=
ScrolledCanvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
,
takefocus
=
1
)
sc
=
ScrolledCanvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
,
takefocus
=
1
)
sc
.
frame
.
pack
(
expand
=
1
,
fill
=
"both"
)
sc
.
frame
.
pack
(
expand
=
1
,
fill
=
"both"
,
side
=
LEFT
)
item
=
FileTreeItem
(
"C:/windows/desktop"
)
item
=
FileTreeItem
(
os
.
getcwd
()
)
node
=
TreeNode
(
sc
.
canvas
,
None
,
item
)
node
=
TreeNode
(
sc
.
canvas
,
None
,
item
)
node
.
expand
()
node
.
expand
()
def
test2
():
# test without scrollable canvas
# test w/o scrolling canvas
root
=
Tk
()
root
.
configure
(
bd
=
0
)
canvas
=
Canvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
)
canvas
=
Canvas
(
root
,
bg
=
"white"
,
highlightthickness
=
0
)
canvas
.
pack
(
expand
=
1
,
fill
=
"both"
)
canvas
.
pack
(
expand
=
0
,
fill
=
"both"
,
side
=
RIGHT
)
item
=
FileTreeItem
(
os
.
curdir
)
item
=
FileTreeItem
(
os
.
getcwd
()
)
node
=
TreeNode
(
canvas
,
None
,
item
)
node
=
TreeNode
(
canvas
,
None
,
item
)
node
.
update
()
node
.
update
()
canvas
.
focus_set
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test
()
from
idlelib.idle_test.htest
import
run
run
(
_tree_widget
)
Lib/idlelib/WidgetRedirector.py
View file @
62012fc7
...
@@ -104,10 +104,12 @@ class OriginalCommand:
...
@@ -104,10 +104,12 @@ class OriginalCommand:
return
self
.
tk_call
(
self
.
orig_and_operation
+
args
)
return
self
.
tk_call
(
self
.
orig_and_operation
+
args
)
def
main
(
):
def
_widget_redirector
(
parent
):
root
=
Tk
()
root
=
Tk
()
root
.
wm_protocol
(
"WM_DELETE_WINDOW"
,
root
.
quit
)
root
.
title
(
"Test WidgetRedirector"
)
text
=
Text
()
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
text
=
Text
(
root
)
text
.
pack
()
text
.
pack
()
text
.
focus_set
()
text
.
focus_set
()
redir
=
WidgetRedirector
(
text
)
redir
=
WidgetRedirector
(
text
)
...
@@ -117,10 +119,7 @@ def main():
...
@@ -117,10 +119,7 @@ def main():
previous_tcl_fcn
(
*
args
)
previous_tcl_fcn
(
*
args
)
previous_tcl_fcn
=
redir
.
register
(
"insert"
,
my_insert
)
previous_tcl_fcn
=
redir
.
register
(
"insert"
,
my_insert
)
root
.
mainloop
()
root
.
mainloop
()
redir
.
unregister
(
"insert"
)
# runs after first 'close window'
redir
.
close
()
root
.
mainloop
()
root
.
destroy
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
from
idlelib.idle_test.htest
import
run
run
(
_widget_redirector
)
Lib/idlelib/aboutDialog.py
View file @
62012fc7
...
@@ -12,11 +12,16 @@ class AboutDialog(Toplevel):
...
@@ -12,11 +12,16 @@ class AboutDialog(Toplevel):
"""Modal about dialog for idle
"""Modal about dialog for idle
"""
"""
def
__init__
(
self
,
parent
,
title
):
def
__init__
(
self
,
parent
,
title
,
_htest
=
False
):
"""
_htest - bool, change box location when running htest
"""
Toplevel
.
__init__
(
self
,
parent
)
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+%d+%d"
%
(
parent
.
winfo_rootx
()
+
30
,
# place dialog below parent if running htest
parent
.
winfo_rooty
()
+
30
))
self
.
geometry
(
"+%d+%d"
%
(
parent
.
winfo_rootx
()
+
30
,
parent
.
winfo_rooty
()
+
(
30
if
not
_htest
else
100
)))
self
.
bg
=
"#707070"
self
.
bg
=
"#707070"
self
.
fg
=
"#ffffff"
self
.
fg
=
"#ffffff"
self
.
CreateWidgets
()
self
.
CreateWidgets
()
...
...
Lib/idlelib/configHelpSourceEdit.py
View file @
62012fc7
...
@@ -8,13 +8,14 @@ import tkMessageBox
...
@@ -8,13 +8,14 @@ import tkMessageBox
import
tkFileDialog
import
tkFileDialog
class
GetHelpSourceDialog
(
Toplevel
):
class
GetHelpSourceDialog
(
Toplevel
):
def
__init__
(
self
,
parent
,
title
,
menuItem
=
''
,
filePath
=
''
):
def
__init__
(
self
,
parent
,
title
,
menuItem
=
''
,
filePath
=
''
,
_htest
=
False
):
"""Get menu entry and url/ local file location for Additional Help
"""Get menu entry and url/ local file location for Additional Help
User selects a name for the Help resource and provides a web url
User selects a name for the Help resource and provides a web url
or a local file as its source. The user can enter a url or browse
or a local file as its source. The user can enter a url or browse
for the file.
for the file.
_htest - bool, change box location when running htest
"""
"""
Toplevel
.
__init__
(
self
,
parent
)
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
configure
(
borderwidth
=
5
)
...
@@ -31,12 +32,14 @@ class GetHelpSourceDialog(Toplevel):
...
@@ -31,12 +32,14 @@ class GetHelpSourceDialog(Toplevel):
self
.
withdraw
()
#hide while setting geometry
self
.
withdraw
()
#hide while setting geometry
#needs to be done here so that the winfo_reqwidth is valid
#needs to be done here so that the winfo_reqwidth is valid
self
.
update_idletasks
()
self
.
update_idletasks
()
#centre dialog over parent:
#centre dialog over parent. below parent if running htest.
self
.
geometry
(
"+%d+%d"
%
self
.
geometry
(
((
parent
.
winfo_rootx
()
+
((
parent
.
winfo_width
()
/
2
)
"+%d+%d"
%
(
-
(
self
.
winfo_reqwidth
()
/
2
)),
parent
.
winfo_rootx
()
+
parent
.
winfo_rooty
()
+
((
parent
.
winfo_height
()
/
2
)
(
parent
.
winfo_width
()
/
2
-
self
.
winfo_reqwidth
()
/
2
),
-
(
self
.
winfo_reqheight
()
/
2
)))))
parent
.
winfo_rooty
()
+
((
parent
.
winfo_height
()
/
2
-
self
.
winfo_reqheight
()
/
2
)
if
not
_htest
else
150
)))
self
.
deiconify
()
#geometry set, unhide
self
.
deiconify
()
#geometry set, unhide
self
.
bind
(
'<Return>'
,
self
.
Ok
)
self
.
bind
(
'<Return>'
,
self
.
Ok
)
self
.
wait_window
()
self
.
wait_window
()
...
@@ -159,11 +162,5 @@ class GetHelpSourceDialog(Toplevel):
...
@@ -159,11 +162,5 @@ class GetHelpSourceDialog(Toplevel):
self
.
destroy
()
self
.
destroy
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
#test the dialog
from
idlelib.idle_test.htest
import
run
root
=
Tk
()
run
(
GetHelpSourceDialog
)
def
run
():
keySeq
=
''
dlg
=
GetHelpSourceDialog
(
root
,
'Get Help Source'
)
print
dlg
.
result
Button
(
root
,
text
=
'Dialog'
,
command
=
run
).
pack
()
root
.
mainloop
()
Lib/idlelib/dynOptionMenuWidget.py
View file @
62012fc7
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
OptionMenu widget modified to allow dynamic menu reconfiguration
OptionMenu widget modified to allow dynamic menu reconfiguration
and setting of highlightthickness
and setting of highlightthickness
"""
"""
from
Tkinter
import
OptionMenu
from
Tkinter
import
OptionMenu
,
_setit
,
Tk
,
StringVar
,
Button
from
Tkinter
import
_setit
import
copy
import
copy
import
re
class
DynOptionMenu
(
OptionMenu
):
class
DynOptionMenu
(
OptionMenu
):
"""
"""
...
@@ -33,3 +34,24 @@ class DynOptionMenu(OptionMenu):
...
@@ -33,3 +34,24 @@ class DynOptionMenu(OptionMenu):
command
=
_setit
(
self
.
variable
,
item
,
self
.
command
))
command
=
_setit
(
self
.
variable
,
item
,
self
.
command
))
if
value
:
if
value
:
self
.
variable
.
set
(
value
)
self
.
variable
.
set
(
value
)
def
_dyn_option_menu
(
parent
):
root
=
Tk
()
root
.
title
(
"Tets dynamic option menu"
)
var
=
StringVar
(
root
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
150
))
var
.
set
(
"Old option set"
)
#Set the default value
dyn
=
DynOptionMenu
(
root
,
var
,
"old1"
,
"old2"
,
"old3"
,
"old4"
)
dyn
.
pack
()
def
update
():
dyn
.
SetMenu
([
"new1"
,
"new2"
,
"new3"
,
"new4"
],
value
=
"new option set"
)
button
=
Button
(
root
,
text
=
"Change option set"
,
command
=
update
)
button
.
pack
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
from
idlelib.idle_test.htest
import
run
run
(
_dyn_option_menu
)
Lib/idlelib/idle_test/htest.py
View file @
62012fc7
...
@@ -35,17 +35,51 @@ import Tkinter as tk
...
@@ -35,17 +35,51 @@ import Tkinter as tk
AboutDialog_spec
=
{
AboutDialog_spec
=
{
'file'
:
'aboutDialog'
,
'file'
:
'aboutDialog'
,
'kwds'
:
{
'title'
:
'About test'
},
'kwds'
:
{
'title'
:
'aboutDialog test'
,
'msg'
:
"Try each button"
'_htest'
:
True
,
},
'msg'
:
"Test every button. Ensure Python, TK and IDLE versions "
"are correctly displayed.
\
n
[Close] to exit."
,
}
}
_calltip_window_spec
=
{
'file'
:
'CallTipWindow'
,
'kwds'
:
{},
'msg'
:
"Typing '(' should display a calltip.
\
n
"
"Typing ') should hide the calltip.
\
n
"
}
_editor_window_spec
=
{
_class_browser_spec
=
{
'file'
:
'EditorWindow'
,
'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"
,
}
_color_delegator_spec
=
{
'file'
:
'ColorDelegator'
,
'kwds'
:
{},
'kwds'
:
{},
'msg'
:
"Test editor functions of interest"
'msg'
:
"The text is sample Python code.
\
n
"
"Ensure components like comments, keywords, builtins,
\
n
"
"string, definitions, and break are correctly colored.
\
n
"
"The default color scheme is in idlelib/config-highlight.def"
}
}
_dyn_option_menu_spec
=
{
'file'
:
'dynOptionMenuWidget'
,
'kwds'
:
{},
'msg'
:
"Select one of the many options in the 'old option set'.
\
n
"
"Click the button to change the option set.
\
n
"
"Select one of the many options in the 'new option set'."
}
#_editor_window_spec = {
# 'file': 'EditorWindow',
# 'kwds': {},
# 'msg': "Test editor functions of interest"
# }
GetCfgSectionNameDialog_spec
=
{
GetCfgSectionNameDialog_spec
=
{
'file'
:
'configSectionNameDialog'
,
'file'
:
'configSectionNameDialog'
,
'kwds'
:
{
'title'
:
'Get Name'
,
'kwds'
:
{
'title'
:
'Get Name'
,
...
@@ -54,7 +88,19 @@ GetCfgSectionNameDialog_spec = {
...
@@ -54,7 +88,19 @@ GetCfgSectionNameDialog_spec = {
'_htest'
:
True
},
'_htest'
:
True
},
'msg'
:
"After the text entered with [Ok] is stripped, <nothing>, "
'msg'
:
"After the text entered with [Ok] is stripped, <nothing>, "
"'abc', or more that 30 chars are errors.
\
n
"
"'abc', or more that 30 chars are errors.
\
n
"
"Close 'Get Name' with a valid entry (printed to Shell), [Cancel], or [X]"
,
"Close 'Get Name' with a valid entry (printed to Shell), "
"[Cancel], or [X]"
,
}
GetHelpSourceDialog_spec
=
{
'file'
:
'configHelpSourceEdit'
,
'kwds'
:
{
'title'
:
'Get helpsource'
,
'_htest'
:
True
},
'msg'
:
"Enter menu item name and help file path
\
n
"
"<nothing> and more than 30 chars are invalid menu item names.
\
n
"
"<nothing>, file does not exist are invalid path items.
\
n
"
"Test for incomplete web address for help file path.
\
n
"
"A valid entry will be printed to shell with [0k].
\
n
"
"[Cancel] will print None to shell"
,
}
}
_help_dialog_spec
=
{
_help_dialog_spec
=
{
...
@@ -63,30 +109,151 @@ _help_dialog_spec = {
...
@@ -63,30 +109,151 @@ _help_dialog_spec = {
'msg'
:
"If the help text displays, this works"
'msg'
:
"If the help text displays, this works"
}
}
def
run
(
test
):
_io_binding_spec
=
{
"Display a widget with callable *test* using a _spec dict"
'file'
:
'IOBinding'
,
'kwds'
:
{},
'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."
}
_multistatus_bar_spec
=
{
'file'
:
'MultiStatusBar'
,
'kwds'
:
{},
'msg'
:
"Ensure presence of multi-status bar below text area.
\
n
"
"Click 'Update Status' to change the multi-status text"
}
_object_browser_spec
=
{
'file'
:
'ObjectBrowser'
,
'kwds'
:
{},
'msg'
:
"Double click on items upto the lowest level.
\
n
"
"Attributes of the objects and related information "
"will be displayed side-by-side at each level."
}
_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."
}
_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."
}
_tabbed_pages_spec
=
{
'file'
:
'tabbedpages'
,
'kwds'
:
{},
'msg'
:
"Toggle between the two tabs 'foo' and 'bar'
\
n
"
"Add a tab by entering a suitable name for it.
\
n
"
"Remove an existing tab by entering its name.
\
n
"
"Remove all existing tabs.
\
n
"
"<nothing> is an invalid add page and remove page name.
\
n
"
}
TextViewer_spec
=
{
'file'
:
'textView'
,
'kwds'
:
{
'title'
:
'Test textView'
,
'text'
:
'The quick brown fox jumps over the lazy dog.
\
n
'
*
35
,
'_htest'
:
True
},
'msg'
:
"Test for read-only property of text.
\
n
"
"Text is selectable. Window is scrollable."
,
}
_tooltip_spec
=
{
'file'
:
'ToolTip'
,
'kwds'
:
{},
'msg'
:
"Place mouse cursor over both the buttons
\
n
"
"A tooltip should appear with some text."
}
_tree_widget_spec
=
{
'file'
:
'TreeWidget'
,
'kwds'
:
{},
'msg'
:
"You should see two canvas' 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."
}
_widget_redirector_spec
=
{
'file'
:
'WidgetRedirector'
,
'kwds'
:
{},
'msg'
:
"Every text insert should be printed to console."
}
def
run
(
test
=
None
):
root
=
tk
.
Tk
()
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
=
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
))
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
=
test_spec
[
'kwds'
]
test_kwds
[
'parent'
]
=
root
test_kwds
[
'parent'
]
=
root
mod
=
import_module
(
'idlelib.'
+
test_spec
[
'file'
])
test
=
getattr
(
mod
,
test_name
)
test_list
.
append
((
test_spec
,
test_kwds
,
test
))
help_string
=
[
tk
.
StringVar
(
''
)]
test_name
=
[
tk
.
StringVar
(
''
)]
callable_object
=
[
None
]
test_kwds
=
[
None
]
def
next
():
if
len
(
test_list
)
==
1
:
next_button
.
pack_forget
()
test_spec
,
test_kwds
[
0
],
test
=
test_list
.
pop
()
help_string
[
0
].
set
(
test_spec
[
'msg'
])
test_name
[
0
].
set
(
'test '
+
test_spec
[
'name'
])
callable_object
[
0
]
=
test
def
run_test
():
def
run_test
():
widget
=
test
(
**
test_kwds
)
widget
=
callable_object
[
0
](
**
test_kwds
[
0
]
)
try
:
try
:
print
(
widget
.
result
)
print
(
widget
.
result
)
except
AttributeError
:
except
AttributeError
:
pass
pass
tk
.
Label
(
root
,
text
=
test_spec
[
'msg'
],
justify
=
'left'
).
pack
()
tk
.
Button
(
root
,
text
=
'Test '
+
test
.
__name__
,
command
=
run_test
).
pack
()
root
.
mainloop
()
def
runall
():
label
=
tk
.
Label
(
root
,
textvariable
=
help_string
[
0
],
justify
=
'left'
)
"Run all tests. Quick and dirty version."
label
.
pack
()
for
k
,
d
in
globals
().
items
():
button
=
tk
.
Button
(
root
,
textvariable
=
test_name
[
0
],
command
=
run_test
)
if
k
.
endswith
(
'_spec'
):
button
.
pack
()
mod
=
import_module
(
'idlelib.'
+
d
[
'file'
])
next_button
=
tk
.
Button
(
root
,
text
=
"Next"
,
command
=
next
)
test
=
getattr
(
mod
,
k
[:
-
5
])
next_button
.
pack
()
run
(
test
)
next
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
run
all
()
run
()
Lib/idlelib/tabbedpages.py
View file @
62012fc7
...
@@ -467,9 +467,12 @@ class TabbedPageSet(Frame):
...
@@ -467,9 +467,12 @@ class TabbedPageSet(Frame):
self
.
_tab_set
.
set_selected_tab
(
page_name
)
self
.
_tab_set
.
set_selected_tab
(
page_name
)
if
__name__
==
'__main__'
:
def
_tabbed_pages
(
parent
)
:
# test dialog
# test dialog
root
=
Tk
()
root
=
Tk
()
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+%d+%d"
%
(
x
,
y
+
175
))
root
.
title
(
"Test tabbed pages"
)
tabPage
=
TabbedPageSet
(
root
,
page_names
=
[
'Foobar'
,
'Baz'
],
n_rows
=
0
,
tabPage
=
TabbedPageSet
(
root
,
page_names
=
[
'Foobar'
,
'Baz'
],
n_rows
=
0
,
expand_tabs
=
False
,
expand_tabs
=
False
,
)
)
...
@@ -488,3 +491,8 @@ if __name__ == '__main__':
...
@@ -488,3 +491,8 @@ if __name__ == '__main__':
labelPgName
.
pack
(
padx
=
5
)
labelPgName
.
pack
(
padx
=
5
)
entryPgName
.
pack
(
padx
=
5
)
entryPgName
.
pack
(
padx
=
5
)
root
.
mainloop
()
root
.
mainloop
()
if
__name__
==
'__main__'
:
from
idlelib.idle_test.htest
import
run
run
(
_tabbed_pages
)
Lib/idlelib/textView.py
View file @
62012fc7
...
@@ -9,15 +9,17 @@ class TextViewer(Toplevel):
...
@@ -9,15 +9,17 @@ class TextViewer(Toplevel):
"""A simple text viewer dialog for IDLE
"""A simple text viewer dialog for IDLE
"""
"""
def
__init__
(
self
,
parent
,
title
,
text
,
modal
=
True
):
def
__init__
(
self
,
parent
,
title
,
text
,
modal
=
True
,
_htest
=
False
):
"""Show the given text in a scrollable window with a 'close' button
"""Show the given text in a scrollable window with a 'close' button
_htest - bool, change box location when running htest
"""
"""
Toplevel
.
__init__
(
self
,
parent
)
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
configure
(
borderwidth
=
5
)
# place dialog below parent if running htest
self
.
geometry
(
"=%dx%d+%d+%d"
%
(
625
,
500
,
self
.
geometry
(
"=%dx%d+%d+%d"
%
(
625
,
500
,
parent
.
winfo_rootx
()
+
10
,
parent
.
winfo_rootx
()
+
10
,
parent
.
winfo_rooty
()
+
10
))
parent
.
winfo_rooty
()
+
(
10
if
not
_htest
else
100
)
))
#elguavas - config placeholders til config stuff completed
#elguavas - config placeholders til config stuff completed
self
.
bg
=
'#ffffff'
self
.
bg
=
'#ffffff'
self
.
fg
=
'#000000'
self
.
fg
=
'#000000'
...
@@ -79,21 +81,5 @@ def view_file(parent, title, filename, encoding=None, modal=True):
...
@@ -79,21 +81,5 @@ def view_file(parent, title, filename, encoding=None, modal=True):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
#test the dialog
from
idlelib.idle_test.htest
import
run
root
=
Tk
()
run
(
TextViewer
)
root
.
title
(
'textView test'
)
filename
=
'./textView.py'
text
=
file
(
filename
,
'r'
).
read
()
btn1
=
Button
(
root
,
text
=
'view_text'
,
command
=
lambda
:
view_text
(
root
,
'view_text'
,
text
))
btn1
.
pack
(
side
=
LEFT
)
btn2
=
Button
(
root
,
text
=
'view_file'
,
command
=
lambda
:
view_file
(
root
,
'view_file'
,
filename
))
btn2
.
pack
(
side
=
LEFT
)
btn3
=
Button
(
root
,
text
=
'nonmodal view_text'
,
command
=
lambda
:
view_text
(
root
,
'nonmodal view_text'
,
text
,
modal
=
False
))
btn3
.
pack
(
side
=
LEFT
)
close
=
Button
(
root
,
text
=
'Close'
,
command
=
root
.
destroy
)
close
.
pack
(
side
=
RIGHT
)
root
.
mainloop
()
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