-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAboutDialog.py
More file actions
executable file
·163 lines (135 loc) · 5.77 KB
/
AboutDialog.py
File metadata and controls
executable file
·163 lines (135 loc) · 5.77 KB
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
#!/usr/bin/env python
"""
Simple about Dialog class -- I like it better than the one that wxPython comes with
-Chris Barker
"""
import wx
from wx.lib.agw.hyperlink import HyperLinkCtrl
class AboutDialog(wx.Dialog):
"""
A fancier About Dialog that the "usual"
"""
def __init__(self, parent, icon1=None,
icon2=None,
short_name=None,
long_name=None,
version=None,
description=None,
urls=None,
licence=None,
developers=[]):
wx.Dialog.__init__(self, parent)
self.icon1 = icon1
self.icon2 = icon2
self.short_name = short_name
self.long_name = long_name
self.version = version
self.version = version
self.description = description
self.urls = urls
self.licence = licence
self.developers = developers
self.Build()
def Build(self):
# Build the header
Header = wx.BoxSizer(wx.HORIZONTAL)
if self.icon1:
Header.Add(wx.StaticBitmap(self, bitmap=self.icon1), 0)
else:
Header.Add((64, 64))
Header.Add((20, 1), 1)
if self.short_name:
Label = wx.StaticText(self, label=self.short_name)
of = Label.GetFont()
Font = wx.Font(int(of.GetPointSize() * 2),
of.GetFamily(), wx.NORMAL, wx.FONTWEIGHT_BOLD)
Label.SetFont(Font)
Header.Add(Label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
else:
Header.Add((1, 1), 1)
Header.Add((20, 1), 1)
if self.icon2:
Header.Add(wx.StaticBitmap(self, bitmap=self.icon2), 0)
else:
Header.Add((64, 64))
width = Header.MinSize[0]
# Now the rest;
MainSizer = wx.BoxSizer(wx.VERTICAL)
MainSizer.Add(Header, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 5)
if self.long_name:
Label = wx.StaticText(self, label=self.long_name)
of = Label.GetFont()
Font = wx.Font(int(of.GetPointSize() * 1.5),
of.GetFamily(), wx.NORMAL, wx.NORMAL)
Label.SetFont(Font)
MainSizer.Add(Label, 0, wx.TOP | wx.RIGHT |
wx.LEFT | wx.ALIGN_CENTER, 5)
width = max(width, Label.Size[0])
if self.version:
Label = wx.StaticText(self, label="version: "+self.version)
#of = Label.GetFont()
#Font = wx.Font(int(of.GetPointSize() * 1.5), of.GetFamily(), wx.NORMAL, wx.NORMAL)
# Label.SetFont(Font)
MainSizer.Add(Label, 0, wx.BOTTOM | wx.ALIGN_CENTER, 5)
if self.description:
Label = wx.StaticText(self, label=self.description)
# of = Label.GetFont()
# Font = wx.Font(int(of.GetPointSize() * 1.5), of.GetFamily(), wx.NORMAL, wx.NORMAL)
# Label.SetFont(Font)
Label.Wrap(max(250, int(0.9 * width)))
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_CENTER, 5)
if self.licence:
Label = wx.StaticText(self, label="License:")
of = Label.GetFont()
Font = wx.Font(of.GetPointSize(), of.GetFamily(),
wx.NORMAL, wx.BOLD)
Label.SetFont(Font)
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_LEFT, 5)
Label = wx.StaticText(self, label=self.licence)
Label.Wrap(max(250, int(0.9 * width)))
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_CENTER, 2)
if self.developers:
Label = wx.StaticText(self, label="Developed by:")
of = Label.GetFont()
Font = wx.Font(of.GetPointSize(), of.GetFamily(),
wx.NORMAL, wx.BOLD)
Label.SetFont(Font)
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_LEFT, 5)
for developer in self.developers:
Label = wx.StaticText(self, label=" " + developer)
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_LEFT, 0)
if self.urls:
Label = wx.StaticText(self, label="For more information:")
of = Label.GetFont()
Font = wx.Font(of.GetPointSize(), of.GetFamily(),
wx.NORMAL, wx.BOLD)
Label.SetFont(Font)
MainSizer.Add(Label, 0, wx.ALL | wx.ALIGN_LEFT, 5)
for url in self.urls:
Link = HyperLinkCtrl(self,
label=url,
URL=url)
MainSizer.Add(Link, 0, wx.ALL | wx.ALIGN_CENTER, 2)
MainSizer.Add((1, 5), 1)
MainSizer.Add(wx.Button(self, id=wx.ID_OK, label="Dismiss"),
0, wx.ALL | wx.ALIGN_RIGHT, 5)
SpaceSizer = wx.BoxSizer(wx.VERTICAL)
SpaceSizer.Add(MainSizer, 0, wx.ALL, 10)
self.SetSizerAndFit(SpaceSizer)
if __name__ == "__main__":
a = wx.App(False)
d = AboutDialog(None,
icon1=wx.Bitmap("Images/GNOME64.png"),
icon2=wx.Bitmap("Images/NOAA.png"),
short_name='Acronym',
long_name='A Longer Name for the Program',
version="1.2.3",
description="A description of the program. "
"This could be a pretty long bit of text. "
"How shall I know how long to make it? "
"How will it fit in?",
urls=["http://www.some.website.org",
"mailto:someone@somwewhere.com"],
licence="This is a short description of the license used for the program.",
developers=["A Developer", "Another Developer"])
d.ShowModal()