-
Notifications
You must be signed in to change notification settings - Fork 443
/
aboutme.py
231 lines (200 loc) · 8.89 KB
/
aboutme.py
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
import sys
import wx
import wx.html as html
from BitTornado.zurllib import urlopen
from webbrowser import open_new
from threading import Thread
from traceback import print_exc
import urllib
################################################################
#
# Class: MyHtmlWindow
#
# Helper class to display html in a panel and handle clicking
# on urls.
#
################################################################
class MyHtmlWindow(html.HtmlWindow):
def __init__(self, parent, id):
html.HtmlWindow.__init__(self, parent, id, size=(400, 300))
self.Bind(wx.EVT_SCROLLWIN, self.OnScroll)
def OnScroll(self, event):
event.Skip()
def OnLinkClicked(self, linkinfo):
t = Thread(target = open_new(linkinfo.GetHref()))
t.setName( "AboutMeLinkOpen"+t.getName() )
t.setDaemon(True)
t.start()
################################################################
#
# Class: MyHtmlDialog
#
# Displays html formatted information in a dialog
#
################################################################
class MyHtmlDialog(wx.Dialog):
def __init__(self, parent, title, content):
wx.Dialog.__init__(self, parent, -1, title)
btn = wx.Button(self, wx.ID_OK, " OK ")
btn.SetDefault()
color = self.GetBackgroundColour()
bgcolor = "#%02x%02x%02x" % (color.Red(), color.Green(), color.Blue())
about_html = "<HTML><HEAD><TITLE>" + title + "</TITLE></HEAD>" + \
"<BODY BGCOLOR=" + bgcolor + " TEXT=#000000>" + \
content + \
"</BODY></HTML>"
self.html = MyHtmlWindow(self, -1)
self.html.SetPage(about_html)
buttonbox = wx.BoxSizer(wx.HORIZONTAL)
buttonbox.Add(btn, 0, wx.ALL, 5)
outerbox = wx.BoxSizer(wx.VERTICAL)
outerbox.Add(self.html, 0, wx.EXPAND|wx.ALL, 5)
outerbox.Add(buttonbox, 0, wx.ALIGN_CENTER)
self.SetAutoLayout(True)
self.SetSizer(outerbox)
self.Fit()
################################################################
#
# Class: VersionDialog
#
# Show information about the current version of ABC
#
################################################################
class VersionDialog(MyHtmlDialog):
def __init__(self, parent):
self.parent = parent
self.utility = parent.utility
content = ""
try :
if not self.hasNewVersion():
content += "<FONT SIZE=+1>"
content += self.utility.lang.get('nonewversion')
content += "<BR>\n"
content += "</FONT>"
else:
content += "<FONT SIZE=+1>"
newversion = self.utility.lang.get('hasnewversion')
content += "<a href=" + self.update_url + ">" + newversion + "</a>"
content += "<BR>\n"
content += "</FONT>"
except :
content = self.utility.lang.get('cantconnectwebserver')
print_exc()
title = self.utility.lang.get('abclatestversion')
MyHtmlDialog.__init__(self, parent, title, content)
def hasNewVersion(self):
my_version = self.utility.getVersion()
try:
curr_status = urllib.urlopen('http:https://tribler.org/version').readlines()
line1 = curr_status[0]
if len(curr_status) > 1:
self.update_url = curr_status[1].strip()
else:
self.update_url = 'http:https://tribler.org'
_curr_status = line1.split()
self.curr_version = _curr_status[0]
return self.newversion(self.curr_version, my_version)
except:
print_exc()
return False
def newversion(self, curr_version, my_version):
curr = curr_version.split('.')
my = my_version.split('.')
if len(my) >= len(curr):
nversion = len(my)
else:
nversion = len(curr)
for i in range(nversion):
if i < len(my):
my_v = int(my[i])
else:
my_v = 0
if i < len(curr):
curr_v = int(curr[i])
else:
curr_v = 0
if curr_v > my_v:
return True
elif curr_v < my_v:
return False
return False
################################################################
#
# Class: AboutMeDialog
#
# Display credits information about who has contributed to ABC
# along with what software modules it uses.
#
################################################################
class AboutMeDialog(MyHtmlDialog):
def __init__(self, parent):
self.parent = parent
self.utility = parent.utility
bittornado_version = "0.3.13"
py2exe_version = "0.6.2"
nsis_version = "2.09"
title = self.utility.lang.get('aboutabc')
# # Start UI in Dialog
# #######################
#
# btn = wx.Button(self, wx.ID_OK, " OK ")
# btn.SetDefault()
#
# color = self.GetBackgroundColour()
# bgcolor = "#%02x%02x%02x" % (color.Red(), color.Green(), color.Blue())
wx_version = str(wx.MAJOR_VERSION) + "." + str(wx.MINOR_VERSION) + "." + str(wx.RELEASE_NUMBER)
major, minor, micro, releaselevel, serial = sys.version_info
python_version = str(major) + "." + str(minor) + "." + str(micro)
content = "<B><CENTER>" + \
self.utility.lang.get('title') + \
"<BR>" + \
self.utility.lang.get('version') + \
"</CENTER></B>" + \
"<FONT SIZE=-1>" + \
"<P><TABLE BORDER=0 CELLSPACING=0>" + \
"<TR>" + \
"<TD>Author:</TD>" + \
"<TD>Tribler Team & Choopan Rattanapoka ([email protected])</TD>" + \
"</TR>" + \
"<TR>" + \
"<TD>Date:</TD>" + \
"<TD>" + self.utility.lang.get('build_date') + "</TD>" + \
"</TR>" + \
"<TR>" + \
"<TD>Homepage:</TD>" + \
"<TD><A HREF=http:https://www.tribler.org>Tribler Homepage</A></TD>" + \
"</TR>" + \
"<TR>" + \
"<TD>Forums:</TD>" + \
"<TD><A HREF=http:https://sourceforge.net/forum/?group_id=159448>Tribler Forums</A></TD>" + \
"</TR>" + \
"<TR>" + \
"<TD>Additional Code:</TD>" + \
"<TD>Tim Tucker (<A HREF=mailto:[email protected]>[email protected]</A>)</TD>" + \
"</TR>" + \
"<TR><TD> </TD><TD>" + \
"NoirSoldats ([email protected])" + \
"<BR>kratoak5" + \
"<BR>roee88" + \
"<BR>Delft University of Technology (<A HREF=mailto:[email protected]>[email protected]</A>)" + \
"<BR>Vrije Universiteit Amsterdam" + \
"</TD></TR>" + \
"<TR>" + \
"<TD COLSPAN=2>" + self.utility.lang.get('translate') + "</TD>"\
"</TR>" + \
"</TABLE>" + \
"<P>The system core is <A HREF=http:https://www.bittornado.com>BitTornado " + bittornado_version + "</A>" + \
"<BR>based on Bittorrent coded by Bram Cohen" + \
"<P>Special Thanks:" + \
"<BR>Greg Fleming (www.darkproject.com)" + \
"<BR>Pir4nhaX (www.clanyakuza.com)" + \
"<BR>Michel Hartmann (php4abc.i-networx.de)" + \
"<BR>Everybody for supporting ABC" + \
"<P>Powered by <A HREF=http:https://www.python.org>Python " + python_version + "</A>, " + \
"<A HREF=http:https://www.wxpython.org>wxPython " + wx_version + "</A>, " + \
"<A HREF=http:https://starship.python.net/crew/theller/py2exe/>py2exe " + py2exe_version + "</A>, " + \
"<A HREF=http:https://nsis.sourceforge.net/>NSIS " + nsis_version + "</A>" + \
"<P>Copyright (c) 2003-2004, Choopan Rattanapoka" + \
"<P>Copyright (c) 2005-2007, Delft University of Technology and Vrije Universiteit Amsterdam" + \
"</FONT>"
MyHtmlDialog.__init__(self, parent, title, content)