Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/aboutDialog.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | b53604fad54b |
| children | eab361617f6a |
| rev | line source |
|---|---|
| 29423 | 1 """About Dialog for IDLE |
| 2 | |
|
18899
0132af63506b
some new dialogs and support files for new about and configuration implementations
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
3 """ |
| 26474 | 4 |
|
47183
b53604fad54b
Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents:
47101
diff
changeset
|
5 from Tkinter import * |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
6 import os |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
7 import os.path |
|
18899
0132af63506b
some new dialogs and support files for new about and configuration implementations
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
8 import textView |
|
0132af63506b
some new dialogs and support files for new about and configuration implementations
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
9 import idlever |
| 26474 | 10 |
|
18899
0132af63506b
some new dialogs and support files for new about and configuration implementations
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
11 class AboutDialog(Toplevel): |
| 29423 | 12 """Modal about dialog for idle |
| 13 | |
| 26959 | 14 """ |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
15 def __init__(self,parent,title): |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
16 Toplevel.__init__(self, parent) |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
17 self.configure(borderwidth=5) |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
18 self.geometry("+%d+%d" % (parent.winfo_rootx()+30, |
| 29423 | 19 parent.winfo_rooty()+30)) |
| 20 self.bg = "#707070" | |
| 21 self.fg = "#ffffff" | |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
22 self.CreateWidgets() |
| 29423 | 23 self.resizable(height=FALSE, width=FALSE) |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
24 self.title(title) |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
25 self.transient(parent) |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
26 self.grab_set() |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
27 self.protocol("WM_DELETE_WINDOW", self.Ok) |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
28 self.parent = parent |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
29 self.buttonOk.focus_set() |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
30 self.bind('<Return>',self.Ok) #dismiss dialog |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
31 self.bind('<Escape>',self.Ok) #dismiss dialog |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
32 self.wait_window() |
| 26959 | 33 |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
34 def CreateWidgets(self): |
| 29423 | 35 frameMain = Frame(self, borderwidth=2, relief=SUNKEN) |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
36 frameButtons = Frame(self) |
| 29423 | 37 frameButtons.pack(side=BOTTOM, fill=X) |
| 38 frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) | |
| 39 self.buttonOk = Button(frameButtons, text='Close', | |
| 40 command=self.Ok) | |
| 41 self.buttonOk.pack(padx=5, pady=5) | |
| 42 #self.picture = Image('photo', data=self.pictureData) | |
| 43 frameBg = Frame(frameMain, bg=self.bg) | |
| 44 frameBg.pack(expand=TRUE, fill=BOTH) | |
| 45 labelTitle = Label(frameBg, text='IDLE', fg=self.fg, bg=self.bg, | |
| 46 font=('courier', 24, 'bold')) | |
| 47 labelTitle.grid(row=0, column=0, sticky=W, padx=10, pady=10) | |
| 48 #labelPicture = Label(frameBg, text='[picture]') | |
| 49 #image=self.picture, bg=self.bg) | |
| 50 #labelPicture.grid(row=1, column=1, sticky=W, rowspan=2, | |
| 51 # padx=0, pady=3) | |
| 52 byline = "Python's Integrated DeveLopment Environment" + 5*'\n' | |
| 53 labelDesc = Label(frameBg, text=byline, justify=LEFT, | |
| 54 fg=self.fg, bg=self.bg) | |
| 55 labelDesc.grid(row=2, column=0, sticky=W, columnspan=3, padx=10, pady=5) | |
| 56 labelEmail = Label(frameBg, text='email: idle-dev@python.org', | |
| 57 justify=LEFT, fg=self.fg, bg=self.bg) | |
|
29497
6531c76b604d
Add ':' after IDLE version, fix spacing on a couple of lines I missed
Kurt B. Kaiser <kbk@shore.net>
parents:
29483
diff
changeset
|
58 labelEmail.grid(row=6, column=0, columnspan=2, |
|
6531c76b604d
Add ':' after IDLE version, fix spacing on a couple of lines I missed
Kurt B. Kaiser <kbk@shore.net>
parents:
29483
diff
changeset
|
59 sticky=W, padx=10, pady=0) |
| 29423 | 60 labelWWW = Label(frameBg, text='www: http://www.python.org/idle/', |
| 61 justify=LEFT, fg=self.fg, bg=self.bg) | |
| 62 labelWWW.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0) | |
| 63 Frame(frameBg, borderwidth=1, relief=SUNKEN, | |
| 64 height=2, bg=self.bg).grid(row=8, column=0, sticky=EW, | |
| 65 columnspan=3, padx=5, pady=5) | |
| 66 labelPythonVer = Label(frameBg, text='Python version: ' + \ | |
| 67 sys.version.split()[0], fg=self.fg, bg=self.bg) | |
| 68 labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0) | |
| 69 # handle weird tk version num in windoze python >= 1.6 (?!?) | |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
30807
diff
changeset
|
70 tkVer = repr(TkVersion).split('.') |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
71 tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:] |
| 26959 | 72 if tkVer[len(tkVer)-1] == '': |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
73 tkVer[len(tkVer)-1] = '0' |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
74 tkVer = '.'.join(tkVer) |
| 29423 | 75 labelTkVer = Label(frameBg, text='Tk version: '+ |
| 76 tkVer, fg=self.fg, bg=self.bg) | |
| 77 labelTkVer.grid(row=9, column=1, sticky=W, padx=2, pady=0) | |
| 78 py_button_f = Frame(frameBg, bg=self.bg) | |
| 79 py_button_f.grid(row=10, column=0, columnspan=2, sticky=NSEW) | |
| 80 buttonLicense = Button(py_button_f, text='License', width=8, | |
| 81 highlightbackground=self.bg, | |
| 82 command=self.ShowLicense) | |
| 83 buttonLicense.pack(side=LEFT, padx=10, pady=10) | |
| 84 buttonCopyright = Button(py_button_f, text='Copyright', width=8, | |
| 85 highlightbackground=self.bg, | |
| 86 command=self.ShowCopyright) | |
| 87 buttonCopyright.pack(side=LEFT, padx=10, pady=10) | |
| 88 buttonCredits = Button(py_button_f, text='Credits', width=8, | |
| 89 highlightbackground=self.bg, | |
| 90 command=self.ShowPythonCredits) | |
| 91 buttonCredits.pack(side=LEFT, padx=10, pady=10) | |
| 92 Frame(frameBg, borderwidth=1, relief=SUNKEN, | |
| 93 height=2, bg=self.bg).grid(row=11, column=0, sticky=EW, | |
| 94 columnspan=3, padx=5, pady=5) | |
|
29497
6531c76b604d
Add ':' after IDLE version, fix spacing on a couple of lines I missed
Kurt B. Kaiser <kbk@shore.net>
parents:
29483
diff
changeset
|
95 idle_v = Label(frameBg, text='IDLE version: ' + idlever.IDLE_VERSION, |
| 29423 | 96 fg=self.fg, bg=self.bg) |
| 97 idle_v.grid(row=12, column=0, sticky=W, padx=10, pady=0) | |
| 98 idle_button_f = Frame(frameBg, bg=self.bg) | |
| 99 idle_button_f.grid(row=13, column=0, columnspan=3, sticky=NSEW) | |
| 100 idle_about_b = Button(idle_button_f, text='README', width=8, | |
| 101 highlightbackground=self.bg, | |
| 102 command=self.ShowIDLEAbout) | |
| 103 idle_about_b.pack(side=LEFT, padx=10, pady=10) | |
| 104 idle_news_b = Button(idle_button_f, text='NEWS', width=8, | |
| 105 highlightbackground=self.bg, | |
| 106 command=self.ShowIDLENEWS) | |
| 107 idle_news_b.pack(side=LEFT, padx=10, pady=10) | |
| 108 idle_credits_b = Button(idle_button_f, text='Credits', width=8, | |
| 109 highlightbackground=self.bg, | |
| 110 command=self.ShowIDLECredits) | |
| 111 idle_credits_b.pack(side=LEFT, padx=10, pady=10) | |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
112 |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
113 def ShowLicense(self): |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
114 self.display_printer_text('About - License', license) |
| 29423 | 115 |
| 116 def ShowCopyright(self): | |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
117 self.display_printer_text('About - Copyright', copyright) |
| 29423 | 118 |
| 119 def ShowPythonCredits(self): | |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
120 self.display_printer_text('About - Python Credits', credits) |
| 29423 | 121 |
| 122 def ShowIDLECredits(self): | |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
123 self.display_file_text('About - Credits', 'CREDITS.txt', 'iso-8859-1') |
| 26959 | 124 |
| 29423 | 125 def ShowIDLEAbout(self): |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
126 self.display_file_text('About - Readme', 'README.txt') |
| 29423 | 127 |
| 128 def ShowIDLENEWS(self): | |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
129 self.display_file_text('About - NEWS', 'NEWS.txt') |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
130 |
|
43462
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
131 def display_printer_text(self, title, printer): |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
132 printer._Printer__setup() |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
133 text = '\n'.join(printer._Printer__lines) |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
134 textView.view_text(self, title, text) |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
135 |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
136 def display_file_text(self, title, filename, encoding=None): |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
137 fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) |
|
9ae4e8a53486
textView cleanup. Patch 1718043 Tal Einat.
Kurt B. Kaiser <kbk@shore.net>
parents:
31515
diff
changeset
|
138 textView.view_file(self, title, fn, encoding) |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
139 |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
140 def Ok(self, event=None): |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
141 self.destroy() |
| 26959 | 142 |
|
18899
0132af63506b
some new dialogs and support files for new about and configuration implementations
Steven M. Gava <elguavas@python.net>
parents:
diff
changeset
|
143 if __name__ == '__main__': |
| 29423 | 144 # test the dialog |
| 145 root = Tk() | |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
146 def run(): |
|
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
147 import aboutDialog |
|
29497
6531c76b604d
Add ':' after IDLE version, fix spacing on a couple of lines I missed
Kurt B. Kaiser <kbk@shore.net>
parents:
29483
diff
changeset
|
148 aboutDialog.AboutDialog(root, 'About') |
| 29423 | 149 Button(root, text='Dialog', command=run).pack() |
|
18905
7628aa816ada
improve viewfile handling
Steven M. Gava <elguavas@python.net>
parents:
18899
diff
changeset
|
150 root.mainloop() |
