File: drAboutDialog.py

package info (click to toggle)
drpython 161-3.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,588 kB
  • ctags: 1,470
  • sloc: python: 15,817; sh: 358; makefile: 43
file content (220 lines) | stat: -rw-r--r-- 7,149 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#	Programmer:	Daniel Pozmanter
#	E-mail:		drpython@bluebottle.com
#	Note:		You must reply to the verification e-mail to get through.
#
#	Copyright 2003-2005 Daniel Pozmanter
#
#	Distributed under the terms of the GPL (GNU Public License)
#
#    DrPython is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#About Dialog

import wx, wx.html
import sys, string

class drStaticLink(wx.Panel):

	def __init__(self, parent, id, text, target, drframe):
		wx.Panel.__init__(self, parent, id)

		self.drframe = drframe

		self.link = target

		self.SetBackgroundColour(wx.Colour(255, 255, 255))

		self.stText = wx.StaticText(self, id, text)
		self.stText.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD))

		self.stText.SetForegroundColour(wx.Colour(0, 90, 255))

		self.theSizer = wx.BoxSizer(wx.HORIZONTAL)

		self.theSizer.Add(self.stText, 0, wx.SHAPED | wx.ALIGN_CENTER)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

		self.SetSize(self.stText.GetSize())

		self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
		self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
		self.stText.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
		self.stText.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)

	def OnMouseEnter(self, event):
		self.SetBackgroundColour(wx.Colour(255, 198, 107))
		event.Skip()

	def OnMouseLeave(self, event):
		self.SetBackgroundColour(wx.Colour(255, 255, 255))
		event.Skip()

	def OnLeftDown(self, event):
		self.SetBackgroundColour(wx.Colour(255, 156, 0))
		event.Skip()

	def OnLeftUp(self, event):
		self.SetBackgroundColour(wx.Colour(255, 198, 107))
		event.Skip()
		self.drframe.ViewURLInBrowser(self.link)

class drAboutContentPanel(wx.Panel):
	def __init__(self, parent, id, drframe):
		wx.Panel.__init__(self, parent, id)

		self.SetBackgroundColour(wx.Colour(255, 255, 255))

		standardfont = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD)

		app = wx.StaticText(self, -1, 'DrPython - Python IDE')

		app.SetFont(standardfont)

		author = wx.StaticText(self, -1, '(c) 2003-2005, Daniel Pozmanter')

		author.SetFont(standardfont)

		credits = drStaticLink(self, 1, ' Credits ', drframe.programdirectory + '/documentation/credits.html', drframe)

		website = drStaticLink(self, 2, ' http://drpython.sourceforge.net/ ', 'http://drpython.sourceforge.net/', drframe)

		self.theSizer = wx.BoxSizer(wx.VERTICAL)

		self.theSizer.Add(wx.StaticText(self, -1, '   '), 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(app, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(wx.StaticText(self, -1, '   '), 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(author, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(wx.StaticText(self, -1, '   '), 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(credits, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(wx.StaticText(self, -1, '   '), 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
		self.theSizer.Add(website, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

class drAboutPanel(wx.Panel):
	def __init__(self, parent, id, drframe):
		wx.Panel.__init__(self, parent, id)

		aboutpanel = drAboutContentPanel(self, id, drframe)

		self.theSizer = wx.BoxSizer(wx.VERTICAL)

		self.theSizer.Add(aboutpanel, 1, wx.EXPAND)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

class drLicensePanel(wx.Panel):
	def __init__(self, parent, id, drframe):
		wx.Panel.__init__(self, parent, id)

		try:
			f = file(drframe.programdirectory + '/documentation/gpl.html', 'rb')
			text = f.read()
			f.close()
		except:
			drframe.ShowMessage('Error Reading the GPL!', 'About Dialog Error')
			return

		self.htmlBox = wx.html.HtmlWindow(self, -1)

		self.htmlBox.SetPage(text)

		self.theSizer = wx.BoxSizer(wx.VERTICAL)

		self.theSizer.Add(self.htmlBox, 1, wx.EXPAND)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

class drSystemPanel(wx.Panel):
	def __init__(self, parent, id, drframe):
		wx.Panel.__init__(self, parent, id)

		version = string.join(map(lambda x: str(x), sys.version_info[:4]), '.')

		wxplatform = string.join(wx.PlatformInfo[1:], ', ')

		systeminfo = '''wxPython Version: %s

wxPython Platform: %s

Python Version: %s

Python Platform: %s''' % (wx.VERSION_STRING, wxplatform, version, sys.platform)

		self.txt = wx.TextCtrl(self, -1, systeminfo, style = wx.TE_READONLY | wx.TE_MULTILINE)

		self.txt.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD))

		self.theSizer = wx.BoxSizer(wx.VERTICAL)

		self.theSizer.Add(self.txt, 1, wx.EXPAND)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

class drAboutDialog(wx.Dialog):

	def __init__(self, parent):
		wx.Dialog.__init__(self, parent, -1, ("About DrPython"), wx.DefaultPosition, wx.Size(500, 400), wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME | wx.RESIZE_BORDER)

		self.parent = parent

		self.notebook = wx.Notebook(self, -1, style=wx.CLIP_CHILDREN)

		self.notebook.AddPage(drAboutPanel(self.notebook, -1, parent), 'About')
		self.notebook.AddPage(drLicensePanel(self.notebook, -1, parent), 'License Agreement')
		self.notebook.AddPage(drSystemPanel(self.notebook, -1, parent), 'System Info')

		self.btnClose = wx.Button(self, 101, "&Close")

		stext = wx.StaticText(self, -1, 'DrPython - 161')
		stext.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD))

		self.theSizer = wx.BoxSizer(wx.VERTICAL)

		self.topSizer = wx.BoxSizer(wx.HORIZONTAL)

		self.topSizer.Add(wx.StaticText(self, -1, '  '), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)

		self.topSizer.Add(wx.StaticBitmap(self, -1, wx.BitmapFromImage(wx.Image(parent.programdirectory + '/documentation/drpython.png', wx.BITMAP_TYPE_PNG))), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)

		self.topSizer.Add(wx.StaticText(self, -1, '  '), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)

		self.topSizer.Add(stext, 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)

		self.theSizer.Add(wx.StaticText(self, -1, '  '), 0, wx.SHAPED)
		self.theSizer.Add(self.topSizer, 0, wx.SHAPED)
		self.theSizer.Add(wx.StaticText(self, -1, '  '), 0, wx.SHAPED)
		self.theSizer.Add(self.notebook, 1, wx.EXPAND)
		self.theSizer.Add(wx.StaticText(self, -1, '  '), 0, wx.SHAPED)
		self.theSizer.Add(self.btnClose, 0, wx.SHAPED | wx.ALIGN_CENTER)

		self.SetAutoLayout(True)
		self.SetSizer(self.theSizer)

		self.Bind(wx.EVT_BUTTON, self.OnbtnClose, id=101)

	def OnbtnClose(self, event):
		self.EndModal(0)

def Show(parent):
	d = drAboutDialog(parent)
	d.ShowModal()
	d.Destroy()