Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 1 | """About Dialog for IDLE |
| 2 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 3 | """ |
Neal Norwitz | 539594f | 2002-11-30 19:12:41 +0000 | [diff] [blame] | 4 | |
Neal Norwitz | 9d72bb4 | 2007-04-17 08:48:32 +0000 | [diff] [blame] | 5 | import os |
Terry Jan Reedy | 296c66e | 2015-05-16 19:28:32 -0400 | [diff] [blame] | 6 | from sys import version |
| 7 | from tkinter import * |
Kurt B. Kaiser | 2d7f6a0 | 2007-08-22 23:01:33 +0000 | [diff] [blame] | 8 | from idlelib import textView |
Neal Norwitz | 539594f | 2002-11-30 19:12:41 +0000 | [diff] [blame] | 9 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 10 | class AboutDialog(Toplevel): |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 11 | """Modal about dialog for idle |
| 12 | |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 13 | """ |
Terry Jan Reedy | 1b392ff | 2014-05-24 18:48:18 -0400 | [diff] [blame] | 14 | def __init__(self, parent, title, _htest=False): |
| 15 | """ |
| 16 | _htest - bool, change box location when running htest |
| 17 | """ |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 18 | Toplevel.__init__(self, parent) |
| 19 | self.configure(borderwidth=5) |
Terry Jan Reedy | 1b392ff | 2014-05-24 18:48:18 -0400 | [diff] [blame] | 20 | # place dialog below parent if running htest |
| 21 | self.geometry("+%d+%d" % ( |
| 22 | parent.winfo_rootx()+30, |
| 23 | parent.winfo_rooty()+(30 if not _htest else 100))) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 24 | self.bg = "#707070" |
| 25 | self.fg = "#ffffff" |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 26 | self.CreateWidgets() |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 27 | self.resizable(height=FALSE, width=FALSE) |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 28 | self.title(title) |
| 29 | self.transient(parent) |
| 30 | self.grab_set() |
| 31 | self.protocol("WM_DELETE_WINDOW", self.Ok) |
| 32 | self.parent = parent |
| 33 | self.buttonOk.focus_set() |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 34 | self.bind('<Return>',self.Ok) #dismiss dialog |
| 35 | self.bind('<Escape>',self.Ok) #dismiss dialog |
| 36 | self.wait_window() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 37 | |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 38 | def CreateWidgets(self): |
Terry Jan Reedy | 296c66e | 2015-05-16 19:28:32 -0400 | [diff] [blame] | 39 | release = version[:version.index(' ')] |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 40 | frameMain = Frame(self, borderwidth=2, relief=SUNKEN) |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 41 | frameButtons = Frame(self) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 42 | frameButtons.pack(side=BOTTOM, fill=X) |
| 43 | frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) |
| 44 | self.buttonOk = Button(frameButtons, text='Close', |
| 45 | command=self.Ok) |
| 46 | self.buttonOk.pack(padx=5, pady=5) |
| 47 | #self.picture = Image('photo', data=self.pictureData) |
| 48 | frameBg = Frame(frameMain, bg=self.bg) |
| 49 | frameBg.pack(expand=TRUE, fill=BOTH) |
| 50 | labelTitle = Label(frameBg, text='IDLE', fg=self.fg, bg=self.bg, |
| 51 | font=('courier', 24, 'bold')) |
| 52 | labelTitle.grid(row=0, column=0, sticky=W, padx=10, pady=10) |
| 53 | #labelPicture = Label(frameBg, text='[picture]') |
| 54 | #image=self.picture, bg=self.bg) |
| 55 | #labelPicture.grid(row=1, column=1, sticky=W, rowspan=2, |
| 56 | # padx=0, pady=3) |
| 57 | byline = "Python's Integrated DeveLopment Environment" + 5*'\n' |
| 58 | labelDesc = Label(frameBg, text=byline, justify=LEFT, |
| 59 | fg=self.fg, bg=self.bg) |
| 60 | labelDesc.grid(row=2, column=0, sticky=W, columnspan=3, padx=10, pady=5) |
| 61 | labelEmail = Label(frameBg, text='email: idle-dev@python.org', |
| 62 | justify=LEFT, fg=self.fg, bg=self.bg) |
Kurt B. Kaiser | 7345375 | 2003-06-16 18:46:42 +0000 | [diff] [blame] | 63 | labelEmail.grid(row=6, column=0, columnspan=2, |
| 64 | sticky=W, padx=10, pady=0) |
Terry Jan Reedy | ee3e561 | 2014-10-14 16:56:42 -0400 | [diff] [blame] | 65 | labelWWW = Label(frameBg, text='https://docs.python.org/' + |
Terry Jan Reedy | 296c66e | 2015-05-16 19:28:32 -0400 | [diff] [blame] | 66 | version[:3] + '/library/idle.html', |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 67 | justify=LEFT, fg=self.fg, bg=self.bg) |
| 68 | labelWWW.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0) |
| 69 | Frame(frameBg, borderwidth=1, relief=SUNKEN, |
| 70 | height=2, bg=self.bg).grid(row=8, column=0, sticky=EW, |
| 71 | columnspan=3, padx=5, pady=5) |
Terry Jan Reedy | 296c66e | 2015-05-16 19:28:32 -0400 | [diff] [blame] | 72 | labelPythonVer = Label(frameBg, text='Python version: ' + |
| 73 | release, fg=self.fg, bg=self.bg) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 74 | labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0) |
Roger Serwy | 0803a39 | 2013-04-08 20:57:13 -0500 | [diff] [blame] | 75 | tkVer = self.tk.call('info', 'patchlevel') |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 76 | labelTkVer = Label(frameBg, text='Tk version: '+ |
| 77 | tkVer, fg=self.fg, bg=self.bg) |
| 78 | labelTkVer.grid(row=9, column=1, sticky=W, padx=2, pady=0) |
| 79 | py_button_f = Frame(frameBg, bg=self.bg) |
| 80 | py_button_f.grid(row=10, column=0, columnspan=2, sticky=NSEW) |
| 81 | buttonLicense = Button(py_button_f, text='License', width=8, |
| 82 | highlightbackground=self.bg, |
| 83 | command=self.ShowLicense) |
| 84 | buttonLicense.pack(side=LEFT, padx=10, pady=10) |
| 85 | buttonCopyright = Button(py_button_f, text='Copyright', width=8, |
| 86 | highlightbackground=self.bg, |
| 87 | command=self.ShowCopyright) |
| 88 | buttonCopyright.pack(side=LEFT, padx=10, pady=10) |
| 89 | buttonCredits = Button(py_button_f, text='Credits', width=8, |
| 90 | highlightbackground=self.bg, |
| 91 | command=self.ShowPythonCredits) |
| 92 | buttonCredits.pack(side=LEFT, padx=10, pady=10) |
| 93 | Frame(frameBg, borderwidth=1, relief=SUNKEN, |
| 94 | height=2, bg=self.bg).grid(row=11, column=0, sticky=EW, |
| 95 | columnspan=3, padx=5, pady=5) |
Terry Jan Reedy | 296c66e | 2015-05-16 19:28:32 -0400 | [diff] [blame] | 96 | idle_v = Label(frameBg, text='IDLE version: ' + release, |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 97 | fg=self.fg, bg=self.bg) |
| 98 | idle_v.grid(row=12, column=0, sticky=W, padx=10, pady=0) |
| 99 | idle_button_f = Frame(frameBg, bg=self.bg) |
| 100 | idle_button_f.grid(row=13, column=0, columnspan=3, sticky=NSEW) |
| 101 | idle_about_b = Button(idle_button_f, text='README', width=8, |
| 102 | highlightbackground=self.bg, |
| 103 | command=self.ShowIDLEAbout) |
| 104 | idle_about_b.pack(side=LEFT, padx=10, pady=10) |
| 105 | idle_news_b = Button(idle_button_f, text='NEWS', width=8, |
| 106 | highlightbackground=self.bg, |
| 107 | command=self.ShowIDLENEWS) |
| 108 | idle_news_b.pack(side=LEFT, padx=10, pady=10) |
| 109 | idle_credits_b = Button(idle_button_f, text='Credits', width=8, |
| 110 | highlightbackground=self.bg, |
| 111 | command=self.ShowIDLECredits) |
| 112 | idle_credits_b.pack(side=LEFT, padx=10, pady=10) |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 113 | |
Terry Jan Reedy | 3567651 | 2016-01-16 23:44:04 -0500 | [diff] [blame] | 114 | # License, et all, are of type _sitebuiltins._Printer |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 115 | def ShowLicense(self): |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 116 | self.display_printer_text('About - License', license) |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 117 | |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 118 | def ShowCopyright(self): |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 119 | self.display_printer_text('About - Copyright', copyright) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 120 | |
| 121 | def ShowPythonCredits(self): |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 122 | self.display_printer_text('About - Python Credits', credits) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 123 | |
Terry Jan Reedy | 3567651 | 2016-01-16 23:44:04 -0500 | [diff] [blame] | 124 | # Encode CREDITS.txt to utf-8 for proper version of Loewis. |
| 125 | # Specify others as ascii until need utf-8, so catch errors. |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 126 | def ShowIDLECredits(self): |
Terry Jan Reedy | 3567651 | 2016-01-16 23:44:04 -0500 | [diff] [blame] | 127 | self.display_file_text('About - Credits', 'CREDITS.txt', 'utf-8') |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 128 | |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 129 | def ShowIDLEAbout(self): |
Terry Jan Reedy | 3567651 | 2016-01-16 23:44:04 -0500 | [diff] [blame] | 130 | self.display_file_text('About - Readme', 'README.txt', 'ascii') |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 131 | |
| 132 | def ShowIDLENEWS(self): |
Terry Jan Reedy | 3567651 | 2016-01-16 23:44:04 -0500 | [diff] [blame] | 133 | self.display_file_text('About - NEWS', 'NEWS.txt', 'ascii') |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 134 | |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 135 | def display_printer_text(self, title, printer): |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 136 | printer._Printer__setup() |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 137 | text = '\n'.join(printer._Printer__lines) |
| 138 | textView.view_text(self, title, text) |
Kurt B. Kaiser | 09cb74b | 2003-06-12 04:20:56 +0000 | [diff] [blame] | 139 | |
Guido van Rossum | 8ce8a78 | 2007-11-01 19:42:39 +0000 | [diff] [blame] | 140 | def display_file_text(self, title, filename, encoding=None): |
| 141 | fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) |
| 142 | textView.view_file(self, title, fn, encoding) |
Steven M. Gava | 885c0bb | 2001-07-31 10:44:35 +0000 | [diff] [blame] | 143 | |
| 144 | def Ok(self, event=None): |
| 145 | self.destroy() |
Kurt B. Kaiser | 6655e4b | 2002-12-31 16:03:23 +0000 | [diff] [blame] | 146 | |
Steven M. Gava | 44d3d1a | 2001-07-31 06:59:02 +0000 | [diff] [blame] | 147 | if __name__ == '__main__': |
Terry Jan Reedy | 06313b7 | 2014-05-11 23:32:32 -0400 | [diff] [blame] | 148 | from idlelib.idle_test.htest import run |
| 149 | run(AboutDialog) |