10 class AboutDialog(Toplevel
):
12 modal about dialog for idle
14 def __init__(self
,parent
,title
):
15 Toplevel
.__init
__(self
, parent
)
16 self
.configure(borderwidth
=5)
17 self
.geometry("+%d+%d" % (parent
.winfo_rootx()+30,
18 parent
.winfo_rooty()+30))
23 self
.resizable(height
=FALSE
,width
=FALSE
)
25 self
.transient(parent
)
27 self
.protocol("WM_DELETE_WINDOW", self
.Ok
)
29 self
.buttonOk
.focus_set()
30 #key bindings for this dialog
31 self
.bind('<Alt-c>',self
.CreditsButtonBinding
) #credits button
32 self
.bind('<Alt-l>',self
.LicenseButtonBinding
) #license button
33 self
.bind('<Return>',self
.Ok
) #dismiss dialog
34 self
.bind('<Escape>',self
.Ok
) #dismiss dialog
37 def CreateWidgets(self
):
38 frameMain
= Frame(self
,borderwidth
=2,relief
=SUNKEN
)
39 frameButtons
= Frame(self
)
40 frameButtons
.pack(side
=BOTTOM
,fill
=X
)
41 frameMain
.pack(side
=TOP
,expand
=TRUE
,fill
=BOTH
)
42 self
.buttonOk
= Button(frameButtons
,text
='Ok',
43 command
=self
.Ok
)#,default=ACTIVE
44 self
.buttonOk
.pack(padx
=5,pady
=5)
45 #self.picture = Image('photo',data=self.pictureData)
46 frameBg
= Frame(frameMain
,bg
=self
.bg
)
47 frameBg
.pack(expand
=TRUE
,fill
=BOTH
)
48 labelTitle
= Label(frameBg
,text
='IDLEfork',fg
=self
.fg
,bg
=self
.bg
,
49 font
=('courier', 24, 'bold'))
50 labelTitle
.grid(row
=0,column
=0,sticky
=W
,padx
=10,pady
=10)
51 #labelPicture = Label(frameBg,text='[picture]')
52 #image=self.picture,bg=self.bg)
53 #labelPicture.grid(row=0,column=1,sticky=W,rowspan=2,padx=0,pady=3)
54 labelVersion
= Label(frameBg
,text
='version '+idlever
.IDLE_VERSION
,
55 fg
=self
.fg
,bg
=self
.bg
)
56 labelVersion
.grid(row
=1,column
=0,sticky
=W
,padx
=10,pady
=5)
57 labelDesc
= Label(frameBg
,
58 text
="A development version of Python's lightweight\n"+
59 'Integrated DeveLopment Environment, IDLE.',
60 justify
=LEFT
,fg
=self
.fg
,bg
=self
.bg
)
61 labelDesc
.grid(row
=2,column
=0,sticky
=W
,columnspan
=3,padx
=10,pady
=5)
62 labelCopyright
= Label(frameBg
,
63 text
="Copyright (c) 2001 Python Software Foundation;\nAll Rights Reserved",
64 justify
=LEFT
,fg
=self
.fg
,bg
=self
.bg
)
65 labelCopyright
.grid(row
=3,column
=0,sticky
=W
,columnspan
=3,padx
=10,pady
=5)
66 labelLicense
= Label(frameBg
,
67 text
='Released under the Python 2.1.1 PSF Licence',
68 justify
=LEFT
,fg
=self
.fg
,bg
=self
.bg
)
69 labelLicense
.grid(row
=4,column
=0,sticky
=W
,columnspan
=3,padx
=10,pady
=5)
70 Frame(frameBg
,height
=5,bg
=self
.bg
).grid(row
=5,column
=0)
71 labelEmail
= Label(frameBg
,text
='email: idle-dev@python.org',
72 justify
=LEFT
,fg
=self
.fg
,bg
=self
.bg
)
73 labelEmail
.grid(row
=6,column
=0,columnspan
=2,sticky
=W
,padx
=10,pady
=0)
74 labelWWW
= Label(frameBg
,text
='www: http://idlefork.sourceforge.net',
75 justify
=LEFT
,fg
=self
.fg
,bg
=self
.bg
)
76 labelWWW
.grid(row
=7,column
=0,columnspan
=2,sticky
=W
,padx
=10,pady
=0)
77 Frame(frameBg
,borderwidth
=1,relief
=SUNKEN
,
78 height
=2,bg
=self
.bg
).grid(row
=8,column
=0,sticky
=EW
,
79 columnspan
=3, padx
=5, pady
=5)
80 labelPythonVer
= Label(frameBg
,text
='Python version: '+
81 sys
.version
.split()[0],fg
=self
.fg
,bg
=self
.bg
)
82 labelPythonVer
.grid(row
=9,column
=0,sticky
=W
,padx
=10,pady
=0)
83 #handle weird tk version num in windoze python >= 1.6 (?!?)
84 tkVer
= `TkVersion`
.split('.')
85 tkVer
[len(tkVer
)-1] = str('%.3g' % (float('.'+tkVer
[len(tkVer
)-1])))[2:]
86 if tkVer
[len(tkVer
)-1] == '':
87 tkVer
[len(tkVer
)-1] = '0'
88 tkVer
= string
.join(tkVer
,'.')
89 labelTkVer
= Label(frameBg
,text
='Tk version: '+
90 tkVer
,fg
=self
.fg
,bg
=self
.bg
)
91 labelTkVer
.grid(row
=9,column
=1,sticky
=W
,padx
=2,pady
=0)
93 self
.buttonLicense
= Button(frameBg
,text
='View License',underline
=5,
94 width
=14,highlightbackground
=self
.bg
,command
=self
.ShowLicense
)#takefocus=FALSE
95 self
.buttonLicense
.grid(row
=10,column
=0,sticky
=W
,padx
=10,pady
=10)
96 self
.buttonCredits
= Button(frameBg
,text
='View Credits',underline
=5,
97 width
=14,highlightbackground
=self
.bg
,command
=self
.ShowCredits
)#takefocus=FALSE
98 self
.buttonCredits
.grid(row
=10,column
=1,columnspan
=2,sticky
=E
,padx
=10,pady
=10)
100 def CreditsButtonBinding(self
,event
):
101 self
.buttonCredits
.invoke()
103 def LicenseButtonBinding(self
,event
):
104 self
.buttonLicense
.invoke()
106 def ShowLicense(self
):
107 self
.ViewFile('About - License','LICENSE.txt')
109 def ShowCredits(self
):
110 self
.ViewFile('About - Credits','CREDITS.txt')
112 def ViewFile(self
,viewTitle
,viewFile
):
113 fn
=os
.path
.join(os
.path
.abspath(os
.path
.dirname(__file__
)),viewFile
)
114 textView
.TextViewer(self
,viewTitle
,fn
)
116 def Ok(self
, event
=None):
119 if __name__
== '__main__':
124 aboutDialog
.AboutDialog(root
,'About')
125 Button(root
,text
='Dialog',command
=run
).pack()