~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Lib/idlelib/aboutDialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""About Dialog for IDLE
 
2
 
 
3
"""
 
4
 
 
5
from Tkinter import *
 
6
import os
 
7
import os.path
 
8
import textView
 
9
import idlever
 
10
 
 
11
class AboutDialog(Toplevel):
 
12
    """Modal about dialog for idle
 
13
 
 
14
    """
 
15
    def __init__(self,parent,title):
 
16
        Toplevel.__init__(self, parent)
 
17
        self.configure(borderwidth=5)
 
18
        self.geometry("+%d+%d" % (parent.winfo_rootx()+30,
 
19
                                  parent.winfo_rooty()+30))
 
20
        self.bg = "#707070"
 
21
        self.fg = "#ffffff"
 
22
        self.CreateWidgets()
 
23
        self.resizable(height=FALSE, width=FALSE)
 
24
        self.title(title)
 
25
        self.transient(parent)
 
26
        self.grab_set()
 
27
        self.protocol("WM_DELETE_WINDOW", self.Ok)
 
28
        self.parent = parent
 
29
        self.buttonOk.focus_set()
 
30
        self.bind('<Return>',self.Ok) #dismiss dialog
 
31
        self.bind('<Escape>',self.Ok) #dismiss dialog
 
32
        self.wait_window()
 
33
 
 
34
    def CreateWidgets(self):
 
35
        frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
 
36
        frameButtons = Frame(self)
 
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)
 
58
        labelEmail.grid(row=6, column=0, columnspan=2,
 
59
                        sticky=W, padx=10, pady=0)
 
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 (?!?)
 
70
        tkVer = repr(TkVersion).split('.')
 
71
        tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
 
72
        if tkVer[len(tkVer)-1] == '':
 
73
            tkVer[len(tkVer)-1] = '0'
 
74
        tkVer = '.'.join(tkVer)
 
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)
 
95
        idle_v = Label(frameBg, text='IDLE version:   ' + idlever.IDLE_VERSION,
 
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)
 
112
 
 
113
    def ShowLicense(self):
 
114
        self.display_printer_text('About - License', license)
 
115
 
 
116
    def ShowCopyright(self):
 
117
        self.display_printer_text('About - Copyright', copyright)
 
118
 
 
119
    def ShowPythonCredits(self):
 
120
        self.display_printer_text('About - Python Credits', credits)
 
121
 
 
122
    def ShowIDLECredits(self):
 
123
        self.display_file_text('About - Credits', 'CREDITS.txt', 'iso-8859-1')
 
124
 
 
125
    def ShowIDLEAbout(self):
 
126
        self.display_file_text('About - Readme', 'README.txt')
 
127
 
 
128
    def ShowIDLENEWS(self):
 
129
        self.display_file_text('About - NEWS', 'NEWS.txt')
 
130
 
 
131
    def display_printer_text(self, title, printer):
 
132
        printer._Printer__setup()
 
133
        text = '\n'.join(printer._Printer__lines)
 
134
        textView.view_text(self, title, text)
 
135
 
 
136
    def display_file_text(self, title, filename, encoding=None):
 
137
        fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename)
 
138
        textView.view_file(self, title, fn, encoding)
 
139
 
 
140
    def Ok(self, event=None):
 
141
        self.destroy()
 
142
 
 
143
if __name__ == '__main__':
 
144
    # test the dialog
 
145
    root = Tk()
 
146
    def run():
 
147
        import aboutDialog
 
148
        aboutDialog.AboutDialog(root, 'About')
 
149
    Button(root, text='Dialog', command=run).pack()
 
150
    root.mainloop()