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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
# Programmer: Daniel Pozmanter
# E-mail: drpython@bluebottle.com
# Note: You must reply to the verification e-mail to get through.
#
# Copyright 2003-2010 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
# Patch by Knut Gerwens, January 2007: added import of wx.lib.stattext,
# replaced all occurences of 'wx.StaticText' with 'wx.lib.stattext.GenStaticText'
# because wx.StaticText displayed some lines truncated when wxPython is run with wxGTK
import wx, wx.html, wx.lib.stattext
import os, sys, string, platform
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.lib.stattext.GenStaticText(self, id, text)
self.stText.SetBackgroundColour(wx.WHITE)
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.lib.stattext.GenStaticText(self, -1, "DrPython - Python IDE")
app.SetBackgroundColour(wx.WHITE)
app.SetFont(standardfont)
author = wx.lib.stattext.GenStaticText(self, -1, "(c) 2003-2010, Daniel Pozmanter")
author.SetBackgroundColour(wx.WHITE)
author.SetFont(standardfont)
credits = drStaticLink(self, 1, " Credits ", "/usr/share/doc/drpython/documentation/credits.html", drframe)
website = drStaticLink(self, 2, " http://drpython.sourceforge.net/ ", "http://drpython.sourceforge.net/", drframe)
self.theSizer = wx.BoxSizer(wx.VERTICAL)
tempstat = wx.lib.stattext.GenStaticText(self, -1, " ")
tempstat.SetBackgroundColour(wx.WHITE)
self.theSizer.Add(tempstat, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
self.theSizer.Add(app, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
tempstat = wx.lib.stattext.GenStaticText(self, -1, " ")
tempstat.SetBackgroundColour(wx.WHITE)
self.theSizer.Add(tempstat, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
self.theSizer.Add(author, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
tempstat = wx.lib.stattext.GenStaticText(self, -1, " ")
tempstat.SetBackgroundColour(wx.WHITE)
self.theSizer.Add(tempstat, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
self.theSizer.Add(credits, 0, wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
tempstat = wx.lib.stattext.GenStaticText(self, -1, " ")
tempstat.SetBackgroundColour(wx.WHITE)
self.theSizer.Add(tempstat, 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 = open("/usr/share/doc/drpython/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):
wx.Panel.__init__(self, parent, id)
version = string.join(map(lambda x: str(x), sys.version_info[:4]), '.')
wxplatform = string.join(wx.PlatformInfo[1:], ', ')
platforminfo = platform.dist()
systeminfo = '''wxPython Version: %s
wxPython Platform: %s
Python Version: %s
Python Platform: %s
Operating System Info: %s %s %s
Operating System Release: %s''' % (wx.VERSION_STRING, wxplatform, version, sys.platform, platforminfo[0], platforminfo[1], platforminfo[2], platform.release())
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, app_version):
wx.Dialog.__init__(self, parent, -1, ("About DrPython"), wx.DefaultPosition, (500, 400), wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | 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), "System Info")
self.btnClose = wx.Button(self, 101, "&Close")
rootmode = False
additional_info = ""
if parent.PLATFORM_IS_GTK:
if os.getuid() == 0:
rootmode = True
additional_info = " (root mode)"
stext = wx.lib.stattext.GenStaticText(self, -1, "DrPython - " + app_version + additional_info)
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.lib.stattext.GenStaticText(self, -1, " "), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)
iconname = "drpython.png"
if rootmode:
iconname = "drpython_root.png"
self.topSizer.Add(wx.StaticBitmap(self, -1,
wx.BitmapFromImage(wx.Image("/usr/share/doc/drpython/documentation/drpython.png", wx.BITMAP_TYPE_PNG))),
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)
self.topSizer.Add(wx.lib.stattext.GenStaticText(self, -1, " "), 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)
self.topSizer.Add(stext, 0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL)
self.theSizer.Add(wx.lib.stattext.GenStaticText(self, -1, " "), 0, wx.SHAPED)
self.theSizer.Add(self.topSizer, 0, wx.SHAPED)
self.theSizer.Add(wx.lib.stattext.GenStaticText(self, -1, " "), 0, wx.SHAPED)
self.theSizer.Add(self.notebook, 1, wx.EXPAND)
self.theSizer.Add(wx.lib.stattext.GenStaticText(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, app_version):
d = drAboutDialog(parent, app_version)
d.ShowModal()
d.Destroy()
|