blob: 3a76b0b1409d344674af1efbe71317aa8571864f [file] [log] [blame]
Steven M. Gava44d3d1a2001-07-31 06:59:02 +00001##---------------------------------------------------------------------------##
2##
3## idle - about box
4## elguavas
5##
6##---------------------------------------------------------------------------##
7"""
8about box for idle
9"""
10from Tkinter import *
Steven M. Gava885c0bb2001-07-31 10:44:35 +000011import string, os
Steven M. Gava44d3d1a2001-07-31 06:59:02 +000012import textView
13import idlever
14class AboutDialog(Toplevel):
Steven M. Gava885c0bb2001-07-31 10:44:35 +000015 """
16 modal about dialog for idle
17 """
18 def __init__(self,parent,title):
19 Toplevel.__init__(self, parent)
20 self.configure(borderwidth=5)
21 self.geometry("+%d+%d" % (parent.winfo_rootx()+30,
22 parent.winfo_rooty()+30))
23 #elguavas - config placeholders til config stuff completed
24 self.bg="#555555"
25 self.fg="#ffffff"
26 #no ugly bold default text font on *nix
27 self.textFont=tuple(Label().cget('font').split())[0:2]+('normal',)
Steven M. Gava44d3d1a2001-07-31 06:59:02 +000028
Steven M. Gava885c0bb2001-07-31 10:44:35 +000029 self.CreateWidgets()
30 self.resizable(height=FALSE,width=FALSE)
31 self.title(title)
32 self.transient(parent)
33 self.grab_set()
34 self.protocol("WM_DELETE_WINDOW", self.Ok)
35 self.parent = parent
36 self.buttonOk.focus_set()
37 #key bindings for this dialog
38 self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button
39 #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button
40 self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button
41 self.bind('<Return>',self.Ok) #dismiss dialog
42 self.bind('<Escape>',self.Ok) #dismiss dialog
43 self.wait_window()
44
45 def CreateWidgets(self):
46 frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
47 frameButtons = Frame(self)
48 frameButtons.pack(side=BOTTOM,fill=X)
49 frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
50 self.buttonOk = Button(frameButtons,text='Ok',
51 command=self.Ok)#,default=ACTIVE
52 self.buttonOk.pack(padx=5,pady=5)
53 #self.picture = Image('photo',data=self.pictureData)
54 frameBg = Frame(frameMain,bg=self.bg)
55 frameBg.pack(expand=TRUE,fill=BOTH)
56 labelTitle = Label(frameBg,text='IDLEfork',fg=self.fg,bg=self.bg,
57 font=('courier', 24, 'bold'))
58 labelTitle.grid(row=0,column=0,sticky=W,padx=10,pady=10)
59 #labelPicture = Label(frameBg,text='[picture]')
60 #image=self.picture,bg=self.bg)
61 #labelPicture.grid(row=0,column=1,sticky=W,rowspan=2,padx=0,pady=3)
62 labelVersion = Label(frameBg,text='version '+idlever.IDLE_VERSION,
63 fg=self.fg,bg=self.bg,font=self.textFont)
64 labelVersion.grid(row=1,column=0,sticky=W,padx=10,pady=5)
65 labelCopyright = Label(frameBg,
66 text="A development version of Python's lightweight\n"+
67 'Integrated DeveLopment Environment, IDLE.',
68 justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont)
69 labelCopyright.grid(row=2,column=0,sticky=W,columnspan=3,padx=10,pady=5)
70 labelLicense = Label(frameBg,
71 text='Licenced under the Python 2.1.1 PSF Licence\n'+
72 '(a GPL compatible licence with extra freedoms)',
73 justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont)
74 labelLicense.grid(row=3,column=0,sticky=W,columnspan=3,padx=10,pady=5)
75 framePad = Frame(frameBg,height=5,bg=self.bg).grid(row=4,column=0)
76 labelEmail = Label(frameBg,text='email: idle-dev@python.org',
77 justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont)
78 labelEmail.grid(row=5,column=0,columnspan=2,sticky=W,padx=10,pady=0)
79 labelWWW = Label(frameBg,text='www: http://idlefork.sourceforge.net',
80 justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont)
81 labelWWW.grid(row=6,column=0,columnspan=2,sticky=W,padx=10,pady=0)
82 frameDivider = Frame(frameBg,borderwidth=1,relief=SUNKEN,
83 height=2,bg=self.bg).grid(row=7,column=0,sticky=(E,W),columnspan=3,
84 padx=5,pady=5)
85 labelPythonVer = Label(frameBg,text='Python version: '+
86 sys.version.split()[0],fg=self.fg,bg=self.bg,font=self.textFont)
87 labelPythonVer.grid(row=8,column=0,sticky=W,padx=10,pady=0)
88 #handle weird tk version num in windoze python >= 1.6 (?!?)
89 tkVer = `TkVersion`.split('.')
90 tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
91 if tkVer[len(tkVer)-1] == '':
92 tkVer[len(tkVer)-1] = '0'
93 tkVer = string.join(tkVer,'.')
94 labelTkVer = Label(frameBg,text='Tk version: '+tkVer,fg=self.fg,bg=self.bg,
95 font=self.textFont)
96 labelTkVer.grid(row=8,column=1,sticky=W,padx=2,pady=0)
97 #labelOs = Label(frameBg,text='python os name: '+pyching.os,
98 # font=self.fontText,fg=self.fg,bg=self.bg)
99 #labelOs.grid(row=6,column=0,sticky=W,padx=10,pady=0)
100 #labelOsType = Label(frameBg,text='python os type: '+pyching.osType,
101 # font=self.fontText,fg=self.fg,bg=self.bg)
102 #labelOsType.grid(row=6,column=1,sticky=W,padx=5,pady=0)
103 #framePad = Frame(frameBg,bg=self.bg,height=5).grid(row=7,column=0)
104
105 self.buttonLicense = Button(frameBg,text='View Readme',underline=5,
106 width=14,highlightbackground=self.bg,command=self.ShowLicense)#takefocus=FALSE
107 self.buttonLicense.grid(row=9,column=0,sticky=W,padx=10,pady=10)
108 self.buttonCredits = Button(frameBg,text='View Credits',underline=5,
109 width=14,highlightbackground=self.bg,command=self.ShowCredits)#takefocus=FALSE
110 self.buttonCredits.grid(row=9,column=1,columnspan=2,sticky=E,padx=10,pady=10)
111
112 def CreditsButtonBinding(self,event):
113 self.buttonCredits.invoke()
114
115 def LicenseButtonBinding(self,event):
116 self.buttonLicense.invoke()
117
118 def ShowLicense(self):
119 self.ViewFile('About - Readme','README.txt')
120
121 def ShowCredits(self):
122 self.ViewFile('About - Credits','CREDITS.txt')
123
124 def ViewFile(self,viewTitle,viewFile):
125 fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),viewFile)
126 textView.TextViewer(self,viewTitle,fn)
127
128 def Ok(self, event=None):
129 self.destroy()
Steven M. Gava44d3d1a2001-07-31 06:59:02 +0000130
Steven M. Gava44d3d1a2001-07-31 06:59:02 +0000131if __name__ == '__main__':
Steven M. Gava885c0bb2001-07-31 10:44:35 +0000132 #test the dialog
133 root=Tk()
134 def run():
135 import aboutDialog
136 aboutDialog.AboutDialog(root,'About')
137 Button(root,text='Dialog',command=run).pack()
138 root.mainloop()