diff --git a/Lib/idlelib/CREDITS.txt b/Lib/idlelib/CREDITS.txt new file mode 100644 index 00000000000..30c2073f0ff --- /dev/null +++ b/Lib/idlelib/CREDITS.txt @@ -0,0 +1,17 @@ +IDLEfork Credits +================== + +Guido van Rossum, as well as being the creator of the Python language, was +the original creator of IDLE. His great work continues as both a contributor +to, and 'benevolent dictator for life' of Python and IDLE/IDLEfork. + +The main developers who have been so far active on IDLEfork version 0.8.1 +and greater are, Guido van Rossum, Stephen M. Gava and Kurt B. Kaiser. + +The IDLE fork project was initiated and brought up to version 0.7.1 by +David Scherer, Peter Schneider-Kamp and Nicholas Riley. + +There are doubtless others who should be included here, especially those +who may have contributed to IDLE versions prior ot 0.8. Please contact +the IDLEfork coordinator to have yourself included here if you are one of +those I have missed! (contact details at http://idlefork.sourceforge.net) diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py new file mode 100644 index 00000000000..85cbe4611c1 --- /dev/null +++ b/Lib/idlelib/aboutDialog.py @@ -0,0 +1,133 @@ +##---------------------------------------------------------------------------## +## +## idle - about box +## elguavas +## +##---------------------------------------------------------------------------## +""" +about box for idle +""" +from Tkinter import * +import string +import textView +import idlever +class AboutDialog(Toplevel): + """ + modal about dialog for idle + """ + def __init__(self,parent,title): + Toplevel.__init__(self, parent) + self.configure(borderwidth=5) + self.geometry("+%d+%d" % (parent.winfo_rootx()+30, + parent.winfo_rooty()+30)) + #elguavas - config placeholders til config stuff completed + self.bg="#555555" + self.fg="#ffffff" + #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.title(title) + self.transient(parent) + self.grab_set() + self.protocol("WM_DELETE_WINDOW", self.Ok) + self.parent = parent + self.buttonOk.focus_set() + #key bindings for this dialog + self.bind('',self.CreditsButtonBinding) #credits button + #self.bind('',self.LicenseButtonBinding) #license button + self.bind('',self.LicenseButtonBinding) #readme button + self.bind('',self.Ok) #dismiss dialog + self.bind('',self.Ok) #dismiss dialog + self.wait_window() + + def CreateWidgets(self): + frameMain = Frame(self,borderwidth=2,relief=SUNKEN) + frameButtons = Frame(self) + frameButtons.pack(side=BOTTOM,fill=X) + frameMain.pack(side=TOP,expand=TRUE,fill=BOTH) + self.buttonOk = Button(frameButtons,text='Ok', + command=self.Ok)#,default=ACTIVE + self.buttonOk.pack(padx=5,pady=5) + #self.picture = Image('photo',data=self.pictureData) + frameBg = Frame(frameMain,bg=self.bg) + frameBg.pack(expand=TRUE,fill=BOTH) + labelTitle = Label(frameBg,text='IDLEfork',fg=self.fg,bg=self.bg, + font=('courier', 24, 'bold')) + labelTitle.grid(row=0,column=0,sticky=W,padx=10,pady=10) + #labelPicture = Label(frameBg,text='[picture]') + #image=self.picture,bg=self.bg) + #labelPicture.grid(row=0,column=1,sticky=W,rowspan=2,padx=0,pady=3) + labelVersion = Label(frameBg,text='version '+idlever.IDLE_VERSION, + fg=self.fg,bg=self.bg,font=self.textFont) + labelVersion.grid(row=1,column=0,sticky=W,padx=10,pady=5) + labelCopyright = Label(frameBg, + text="A development version of Python's lightweight\n"+ + 'Integrated DeveLopment Environment, IDLE.', + justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont) + labelCopyright.grid(row=2,column=0,sticky=W,columnspan=3,padx=10,pady=5) + labelLicense = Label(frameBg, + text='Licenced under the Python 2.1.1 PSF Licence\n'+ + '(a GPL compatible licence with extra freedoms)', + justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont) + labelLicense.grid(row=3,column=0,sticky=W,columnspan=3,padx=10,pady=5) + framePad = Frame(frameBg,height=5,bg=self.bg).grid(row=4,column=0) + labelEmail = Label(frameBg,text='email: idle-dev@python.org', + justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont) + labelEmail.grid(row=5,column=0,columnspan=2,sticky=W,padx=10,pady=0) + labelWWW = Label(frameBg,text='www: http://idlefork.sourceforge.net', + justify=LEFT,fg=self.fg,bg=self.bg,font=self.textFont) + labelWWW.grid(row=6,column=0,columnspan=2,sticky=W,padx=10,pady=0) + frameDivider = Frame(frameBg,borderwidth=1,relief=SUNKEN, + height=2,bg=self.bg).grid(row=7,column=0,sticky=(E,W),columnspan=3, + padx=5,pady=5) + labelPythonVer = Label(frameBg,text='Python version: '+ + sys.version.split()[0],fg=self.fg,bg=self.bg,font=self.textFont) + labelPythonVer.grid(row=8,column=0,sticky=W,padx=10,pady=0) + #handle weird tk version num in windoze python >= 1.6 (?!?) + tkVer = `TkVersion`.split('.') + tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:] + if tkVer[len(tkVer)-1] == '': + tkVer[len(tkVer)-1] = '0' + tkVer = string.join(tkVer,'.') + labelTkVer = Label(frameBg,text='Tk version: '+tkVer,fg=self.fg,bg=self.bg, + font=self.textFont) + labelTkVer.grid(row=8,column=1,sticky=W,padx=2,pady=0) + #labelOs = Label(frameBg,text='python os name: '+pyching.os, + # font=self.fontText,fg=self.fg,bg=self.bg) + #labelOs.grid(row=6,column=0,sticky=W,padx=10,pady=0) + #labelOsType = Label(frameBg,text='python os type: '+pyching.osType, + # font=self.fontText,fg=self.fg,bg=self.bg) + #labelOsType.grid(row=6,column=1,sticky=W,padx=5,pady=0) + #framePad = Frame(frameBg,bg=self.bg,height=5).grid(row=7,column=0) + + self.buttonLicense = Button(frameBg,text='View Readme',underline=5, + width=14,highlightbackground=self.bg,command=self.ShowLicense)#takefocus=FALSE + self.buttonLicense.grid(row=9,column=0,sticky=W,padx=10,pady=10) + self.buttonCredits = Button(frameBg,text='View Credits',underline=5, + width=14,highlightbackground=self.bg,command=self.ShowCredits)#takefocus=FALSE + self.buttonCredits.grid(row=9,column=1,columnspan=2,sticky=E,padx=10,pady=10) + + def CreditsButtonBinding(self,event): + self.buttonCredits.invoke() + + def LicenseButtonBinding(self,event): + self.buttonLicense.invoke() + + def ShowLicense(self): + textView.TextViewer(self,title='About - Readme', + fileName='./README.txt') + + def ShowCredits(self): + textView.TextViewer(self,title='About - Credits', + fileName='./CREDITS.txt') + + def Ok(self, event=None): + self.destroy() + +if __name__ == '__main__': + #test the dialog + root=Tk() + Button(root,text='About',command=lambda:AboutDialog(root,'About')).pack() + root.mainloop() diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py new file mode 100644 index 00000000000..f46f95f3043 --- /dev/null +++ b/Lib/idlelib/configDialog.py @@ -0,0 +1,138 @@ +##---------------------------------------------------------------------------## +## +## idle - configuration dialog +## elguavas +## +##---------------------------------------------------------------------------## +""" +configuration dialog +""" +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',) + + 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('',self.Ok) #dismiss dialog + self.bind('',self.CancelBinding) #dismiss dialog, no save + self.bind('',self.SaveBinding) #dismiss dialog, save + self.bind('',self.RevertBinding) #revert to defaults + self.bind('',self.ChangePageBinding) + self.bind('',self.ChangePageBinding) + self.bind('',self.ChangePageBinding) + self.bind('',self.ChangePageBinding) + self.wait_window() + + def Cancel(self): + self.destroy() + + def Save(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 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) + + #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() diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py new file mode 100644 index 00000000000..72d8b34a371 --- /dev/null +++ b/Lib/idlelib/textView.py @@ -0,0 +1,77 @@ +##---------------------------------------------------------------------------## +## +## idle - simple text view dialog +## elguavas +## +##---------------------------------------------------------------------------## +""" +simple text browser for idle +""" +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 + + 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('',self.Ok) #dismiss dialog + self.bind('',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()