Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
d721c481
Kaydet (Commit)
d721c481
authored
Tem 31, 2001
tarafından
Steven M. Gava
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
indentation style changed to match existing source
üst
885c0bbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
174 deletions
+174
-174
configDialog.py
Lib/idlelib/configDialog.py
+114
-114
textView.py
Lib/idlelib/textView.py
+60
-60
No files found.
Lib/idlelib/configDialog.py
Dosyayı görüntüle @
d721c481
...
...
@@ -11,128 +11,128 @@ from Tkinter import *
import
tkMessageBox
class
ConfigDialog
(
Toplevel
):
"""
configuration dialog for idle
"""
def
__init__
(
self
,
parent
,
title
,
configDict
):
"""
configDict - dictionary of configuration items
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+
%
d+
%
d"
%
(
parent
.
winfo_rootx
()
+
20
,
parent
.
winfo_rooty
()
+
30
))
self
.
config
=
configDict
#elguavas - config placeholders til config stuff completed
self
.
bg
=
self
.
cget
(
'bg'
)
self
.
fg
=
None
#no ugly bold default text font on *nix
self
.
textFont
=
tuple
(
Label
()
.
cget
(
'font'
)
.
split
())[
0
:
2
]
+
(
'normal'
,)
configuration dialog for idle
"""
def
__init__
(
self
,
parent
,
title
,
configDict
):
"""
configDict - dictionary of configuration items
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+
%
d+
%
d"
%
(
parent
.
winfo_rootx
()
+
20
,
parent
.
winfo_rooty
()
+
30
))
self
.
config
=
configDict
#elguavas - config placeholders til config stuff completed
self
.
bg
=
self
.
cget
(
'bg'
)
self
.
fg
=
None
#no ugly bold default text font on *nix
self
.
textFont
=
tuple
(
Label
()
.
cget
(
'font'
)
.
split
())[
0
:
2
]
+
(
'normal'
,)
self
.
CreateWidgets
()
self
.
resizable
(
height
=
FALSE
,
width
=
FALSE
)
self
.
ChangePage
()
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
Cancel
)
self
.
parent
=
parent
self
.
framePages
.
focus_set
()
#key bindings for this dialog
self
.
CreateWidgets
()
self
.
resizable
(
height
=
FALSE
,
width
=
FALSE
)
self
.
ChangePage
()
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
Cancel
)
self
.
parent
=
parent
self
.
framePages
.
focus_set
()
#key bindings for this dialog
# self.bind('<Return>',self.Ok) #dismiss dialog
self
.
bind
(
'<Escape>'
,
self
.
CancelBinding
)
#dismiss dialog, no save
self
.
bind
(
'<Alt-s>'
,
self
.
SaveBinding
)
#dismiss dialog, save
self
.
bind
(
'<Alt-r>'
,
self
.
RevertBinding
)
#revert to defaults
self
.
bind
(
'<Alt-f>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-c>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-k>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-g>'
,
self
.
ChangePageBinding
)
self
.
wait_window
()
def
Cancel
(
self
):
self
.
destroy
()
self
.
bind
(
'<Escape>'
,
self
.
CancelBinding
)
#dismiss dialog, no save
self
.
bind
(
'<Alt-s>'
,
self
.
SaveBinding
)
#dismiss dialog, save
self
.
bind
(
'<Alt-r>'
,
self
.
RevertBinding
)
#revert to defaults
self
.
bind
(
'<Alt-f>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-c>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-k>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-g>'
,
self
.
ChangePageBinding
)
self
.
wait_window
()
def
Cancel
(
self
):
self
.
destroy
()
def
Save
(
self
):
pass
def
Save
(
self
):
pass
def
Revert
(
self
):
pass
def
Revert
(
self
):
pass
def
ChangePage
(
self
):
self
.
pages
[
self
.
pageNum
.
get
()]
.
lift
()
self
.
title
(
'Settings - '
+
self
.
pageButtons
[
self
.
pageNum
.
get
()]
.
cget
(
'text'
))
def
ChangePage
(
self
):
self
.
pages
[
self
.
pageNum
.
get
()]
.
lift
()
self
.
title
(
'Settings - '
+
self
.
pageButtons
[
self
.
pageNum
.
get
()]
.
cget
(
'text'
))
def
CancelBinding
(
self
,
event
):
self
.
Cancel
()
def
SaveBinding
(
self
,
event
):
self
.
Save
()
def
RevertBinding
(
self
,
event
):
self
.
Revert
()
def
ChangePageBinding
(
self
,
event
):
pageKeys
=
(
'f'
,
'c'
,
'k'
,
'g'
)
pos
=
0
for
key
in
pageKeys
:
if
event
.
char
==
key
:
self
.
pageNum
.
set
(
pos
)
self
.
ChangePage
()
return
pos
=
pos
+
1
def
CreateWidgets
(
self
):
self
.
framePages
=
Frame
(
self
,
borderwidth
=
2
,
relief
=
SUNKEN
)
frameActionButtons
=
Frame
(
self
)
framePageButtons
=
Frame
(
self
.
framePages
,
borderwidth
=
1
,
relief
=
SUNKEN
)
#action buttons
self
.
buttonRevert
=
Button
(
frameActionButtons
,
text
=
'Revert'
,
command
=
self
.
Revert
,
underline
=
0
,
takefocus
=
FALSE
)
self
.
buttonSave
=
Button
(
frameActionButtons
,
text
=
'Save'
,
command
=
self
.
Save
,
underline
=
0
,
takefocus
=
FALSE
)
self
.
buttonCancel
=
Button
(
frameActionButtons
,
text
=
'Cancel'
,
command
=
self
.
Cancel
,
takefocus
=
FALSE
)
#page buttons
self
.
pageNum
=
IntVar
()
self
.
pageNum
.
set
(
0
)
buttonPageFonts
=
Radiobutton
(
framePageButtons
,
value
=
0
,
text
=
'Fonts'
)
buttonPageColours
=
Radiobutton
(
framePageButtons
,
value
=
1
,
text
=
'Colours'
)
buttonPageKeys
=
Radiobutton
(
framePageButtons
,
value
=
2
,
text
=
'Keys'
)
buttonPageGeneral
=
Radiobutton
(
framePageButtons
,
value
=
3
,
text
=
'General'
)
self
.
pageButtons
=
(
buttonPageFonts
,
buttonPageColours
,
buttonPageKeys
,
buttonPageGeneral
)
for
button
in
self
.
pageButtons
:
button
.
config
(
command
=
self
.
ChangePage
,
underline
=
0
,
takefocus
=
FALSE
,
indicatoron
=
FALSE
,
highlightthickness
=
0
,
variable
=
self
.
pageNum
,
selectcolor
=
self
.
bg
,
borderwidth
=
1
)
button
.
pack
(
side
=
LEFT
)
#pages
framePageFonts
=
Frame
(
self
.
framePages
)
framePageColours
=
Frame
(
self
.
framePages
)
framePageKeys
=
Frame
(
self
.
framePages
)
framePageGeneral
=
Frame
(
self
.
framePages
)
self
.
pages
=
(
framePageFonts
,
framePageColours
,
framePageKeys
,
framePageGeneral
)
#pageFonts
Button
(
framePageFonts
,
text
=
'fonts page test'
)
.
pack
(
padx
=
30
,
pady
=
30
)
#pageColours
Button
(
framePageColours
,
text
=
'colours page test'
)
.
pack
(
padx
=
60
,
pady
=
60
)
#pageKeys
Button
(
framePageKeys
,
text
=
'keys page test'
)
.
pack
(
padx
=
90
,
pady
=
90
)
#pageGeneral
Button
(
framePageGeneral
,
text
=
'general page test'
)
.
pack
(
padx
=
110
,
pady
=
110
)
def
CancelBinding
(
self
,
event
):
self
.
Cancel
()
def
SaveBinding
(
self
,
event
):
self
.
Save
()
#grid in framePages so we can overlap pages
framePageButtons
.
grid
(
row
=
0
,
column
=
0
,
sticky
=
W
)
for
page
in
self
.
pages
:
page
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
(
N
,
S
,
E
,
W
))
def
RevertBinding
(
self
,
event
):
self
.
Revert
()
self
.
buttonRevert
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
self
.
buttonSave
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
self
.
buttonCancel
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
frameActionButtons
.
pack
(
side
=
BOTTOM
)
self
.
framePages
.
pack
(
side
=
TOP
,
expand
=
TRUE
,
fill
=
BOTH
)
def
ChangePageBinding
(
self
,
event
):
pageKeys
=
(
'f'
,
'c'
,
'k'
,
'g'
)
pos
=
0
for
key
in
pageKeys
:
if
event
.
char
==
key
:
self
.
pageNum
.
set
(
pos
)
self
.
ChangePage
()
return
pos
=
pos
+
1
def
CreateWidgets
(
self
):
self
.
framePages
=
Frame
(
self
,
borderwidth
=
2
,
relief
=
SUNKEN
)
frameActionButtons
=
Frame
(
self
)
framePageButtons
=
Frame
(
self
.
framePages
,
borderwidth
=
1
,
relief
=
SUNKEN
)
#action buttons
self
.
buttonRevert
=
Button
(
frameActionButtons
,
text
=
'Revert'
,
command
=
self
.
Revert
,
underline
=
0
,
takefocus
=
FALSE
)
self
.
buttonSave
=
Button
(
frameActionButtons
,
text
=
'Save'
,
command
=
self
.
Save
,
underline
=
0
,
takefocus
=
FALSE
)
self
.
buttonCancel
=
Button
(
frameActionButtons
,
text
=
'Cancel'
,
command
=
self
.
Cancel
,
takefocus
=
FALSE
)
#page buttons
self
.
pageNum
=
IntVar
()
self
.
pageNum
.
set
(
0
)
buttonPageFonts
=
Radiobutton
(
framePageButtons
,
value
=
0
,
text
=
'Fonts'
)
buttonPageColours
=
Radiobutton
(
framePageButtons
,
value
=
1
,
text
=
'Colours'
)
buttonPageKeys
=
Radiobutton
(
framePageButtons
,
value
=
2
,
text
=
'Keys'
)
buttonPageGeneral
=
Radiobutton
(
framePageButtons
,
value
=
3
,
text
=
'General'
)
self
.
pageButtons
=
(
buttonPageFonts
,
buttonPageColours
,
buttonPageKeys
,
buttonPageGeneral
)
for
button
in
self
.
pageButtons
:
button
.
config
(
command
=
self
.
ChangePage
,
underline
=
0
,
takefocus
=
FALSE
,
indicatoron
=
FALSE
,
highlightthickness
=
0
,
variable
=
self
.
pageNum
,
selectcolor
=
self
.
bg
,
borderwidth
=
1
)
button
.
pack
(
side
=
LEFT
)
#pages
framePageFonts
=
Frame
(
self
.
framePages
)
framePageColours
=
Frame
(
self
.
framePages
)
framePageKeys
=
Frame
(
self
.
framePages
)
framePageGeneral
=
Frame
(
self
.
framePages
)
self
.
pages
=
(
framePageFonts
,
framePageColours
,
framePageKeys
,
framePageGeneral
)
#pageFonts
Button
(
framePageFonts
,
text
=
'fonts page test'
)
.
pack
(
padx
=
30
,
pady
=
30
)
#pageColours
Button
(
framePageColours
,
text
=
'colours page test'
)
.
pack
(
padx
=
60
,
pady
=
60
)
#pageKeys
Button
(
framePageKeys
,
text
=
'keys page test'
)
.
pack
(
padx
=
90
,
pady
=
90
)
#pageGeneral
Button
(
framePageGeneral
,
text
=
'general page test'
)
.
pack
(
padx
=
110
,
pady
=
110
)
#grid in framePages so we can overlap pages
framePageButtons
.
grid
(
row
=
0
,
column
=
0
,
sticky
=
W
)
for
page
in
self
.
pages
:
page
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
(
N
,
S
,
E
,
W
))
self
.
buttonRevert
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
self
.
buttonSave
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
self
.
buttonCancel
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
)
frameActionButtons
.
pack
(
side
=
BOTTOM
)
self
.
framePages
.
pack
(
side
=
TOP
,
expand
=
TRUE
,
fill
=
BOTH
)
if
__name__
==
'__main__'
:
#test the dialog
root
=
Tk
()
Button
(
root
,
text
=
'Dialog'
,
command
=
lambda
:
ConfigDialog
(
root
,
'Settings'
,
None
))
.
pack
()
root
.
mainloop
()
#test the dialog
root
=
Tk
()
Button
(
root
,
text
=
'Dialog'
,
command
=
lambda
:
ConfigDialog
(
root
,
'Settings'
,
None
))
.
pack
()
root
.
mainloop
()
Lib/idlelib/textView.py
Dosyayı görüntüle @
d721c481
...
...
@@ -11,67 +11,67 @@ from Tkinter import *
import
tkMessageBox
class
TextViewer
(
Toplevel
):
"""
simple text viewer dialog for idle
"""
def
__init__
(
self
,
parent
,
title
,
fileName
):
"""
fileName - string,should be an absoulute filename
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+
%
d+
%
d"
%
(
parent
.
winfo_rootx
()
+
10
,
parent
.
winfo_rooty
()
+
10
))
#elguavas - config placeholders til config stuff completed
self
.
bg
=
None
self
.
fg
=
None
simple text viewer dialog for idle
"""
def
__init__
(
self
,
parent
,
title
,
fileName
):
"""
fileName - string,should be an absoulute filename
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+
%
d+
%
d"
%
(
parent
.
winfo_rootx
()
+
10
,
parent
.
winfo_rooty
()
+
10
))
#elguavas - config placeholders til config stuff completed
self
.
bg
=
None
self
.
fg
=
None
self
.
CreateWidgets
()
self
.
title
(
title
)
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
Ok
)
self
.
parent
=
parent
self
.
textView
.
focus_set
()
#key bindings for this dialog
self
.
bind
(
'<Return>'
,
self
.
Ok
)
#dismiss dialog
self
.
bind
(
'<Escape>'
,
self
.
Ok
)
#dismiss dialog
self
.
LoadTextFile
(
fileName
)
self
.
textView
.
config
(
state
=
DISABLED
)
self
.
wait_window
()
def
LoadTextFile
(
self
,
fileName
):
textFile
=
None
try
:
textFile
=
open
(
fileName
,
'r'
)
except
IOError
:
tkMessageBox
.
showerror
(
title
=
'File Load Error'
,
message
=
'Unable to load file '
+
`fileName`
+
' .'
)
else
:
self
.
textView
.
insert
(
0.0
,
textFile
.
read
())
def
CreateWidgets
(
self
):
frameText
=
Frame
(
self
)
frameButtons
=
Frame
(
self
)
self
.
buttonOk
=
Button
(
frameButtons
,
text
=
'Ok'
,
command
=
self
.
Ok
,
takefocus
=
FALSE
,
default
=
ACTIVE
)
self
.
scrollbarView
=
Scrollbar
(
frameText
,
orient
=
VERTICAL
,
takefocus
=
FALSE
,
highlightthickness
=
0
)
self
.
textView
=
Text
(
frameText
,
wrap
=
WORD
,
highlightthickness
=
0
)
self
.
scrollbarView
.
config
(
command
=
self
.
textView
.
yview
)
self
.
textView
.
config
(
yscrollcommand
=
self
.
scrollbarView
.
set
)
self
.
buttonOk
.
pack
(
padx
=
5
,
pady
=
5
)
self
.
scrollbarView
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
self
.
textView
.
pack
(
side
=
LEFT
,
expand
=
TRUE
,
fill
=
BOTH
)
frameButtons
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
frameText
.
pack
(
side
=
TOP
,
expand
=
TRUE
,
fill
=
BOTH
)
def
Ok
(
self
,
event
=
None
):
self
.
destroy
()
self
.
CreateWidgets
()
self
.
title
(
title
)
self
.
transient
(
parent
)
self
.
grab_set
()
self
.
protocol
(
"WM_DELETE_WINDOW"
,
self
.
Ok
)
self
.
parent
=
parent
self
.
textView
.
focus_set
()
#key bindings for this dialog
self
.
bind
(
'<Return>'
,
self
.
Ok
)
#dismiss dialog
self
.
bind
(
'<Escape>'
,
self
.
Ok
)
#dismiss dialog
self
.
LoadTextFile
(
fileName
)
self
.
textView
.
config
(
state
=
DISABLED
)
self
.
wait_window
()
def
LoadTextFile
(
self
,
fileName
):
textFile
=
None
try
:
textFile
=
open
(
fileName
,
'r'
)
except
IOError
:
tkMessageBox
.
showerror
(
title
=
'File Load Error'
,
message
=
'Unable to load file '
+
`fileName`
+
' .'
)
else
:
self
.
textView
.
insert
(
0.0
,
textFile
.
read
())
def
CreateWidgets
(
self
):
frameText
=
Frame
(
self
)
frameButtons
=
Frame
(
self
)
self
.
buttonOk
=
Button
(
frameButtons
,
text
=
'Ok'
,
command
=
self
.
Ok
,
takefocus
=
FALSE
,
default
=
ACTIVE
)
self
.
scrollbarView
=
Scrollbar
(
frameText
,
orient
=
VERTICAL
,
takefocus
=
FALSE
,
highlightthickness
=
0
)
self
.
textView
=
Text
(
frameText
,
wrap
=
WORD
,
highlightthickness
=
0
)
self
.
scrollbarView
.
config
(
command
=
self
.
textView
.
yview
)
self
.
textView
.
config
(
yscrollcommand
=
self
.
scrollbarView
.
set
)
self
.
buttonOk
.
pack
(
padx
=
5
,
pady
=
5
)
self
.
scrollbarView
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
self
.
textView
.
pack
(
side
=
LEFT
,
expand
=
TRUE
,
fill
=
BOTH
)
frameButtons
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
frameText
.
pack
(
side
=
TOP
,
expand
=
TRUE
,
fill
=
BOTH
)
def
Ok
(
self
,
event
=
None
):
self
.
destroy
()
if
__name__
==
'__main__'
:
#test the dialog
root
=
Tk
()
Button
(
root
,
text
=
'View'
,
command
=
lambda
:
TextViewer
(
root
,
'Text'
,
'./textView.py'
))
.
pack
()
root
.
mainloop
()
#test the dialog
root
=
Tk
()
Button
(
root
,
text
=
'View'
,
command
=
lambda
:
TextViewer
(
root
,
'Text'
,
'./textView.py'
))
.
pack
()
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