author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Thu, 21 Jan 2021 05:04:23 +0100 | |
branch | svghmi |
changeset 3113 | 18133b90196e |
parent 1881 | 091005ec69c4 |
child 3570 | eb915a9fdcb0 |
permissions | -rw-r--r-- |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
3 |
|
1628
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
6 |
# This file is based on code written for Whyteboard project. |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
7 |
# |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
8 |
# Copyright (c) 2009, 2010 by Steven Sproat |
1628
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
9 |
# Copyright (c) 2016 by Andrey Skvortsov <andrej.skvortzov@gmail.com> |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
10 |
# |
1628
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
11 |
# See COPYING file for copyrights details. |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
12 |
# |
1628
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
13 |
# This program is free software; you can redistribute it and/or |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
14 |
# modify it under the terms of the GNU General Public License |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
15 |
# as published by the Free Software Foundation; either version 2 |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
16 |
# of the License, or (at your option) any later version. |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
17 |
# |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
18 |
# This program is distributed in the hope that it will be useful, |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
19 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
21 |
# GNU General Public License for more details. |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
22 |
# |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
23 |
# You should have received a copy of the GNU General Public License |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
24 |
# along with this program; if not, write to the Free Software |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
25 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
6309efe91289
fix file header in AboutDialog.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1612
diff
changeset
|
26 |
# |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
27 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
28 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
29 |
""" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
30 |
This module contains classes extended from wx.Dialog used by the GUI. |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
31 |
""" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
32 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
33 |
|
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
34 |
from __future__ import absolute_import |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
35 |
import os |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
36 |
import wx |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
37 |
from wx.lib.agw.hyperlink import HyperLinkCtrl |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
38 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
39 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
40 |
class AboutDialog(wx.Dialog): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
41 |
""" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
42 |
A replacement About Dialog for Windows, as it uses a generic frame that |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
43 |
well...sucks. |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
44 |
""" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
45 |
def __init__(self, parent, info): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
46 |
title = _("About") + " " + info.Name |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
47 |
wx.Dialog.__init__(self, parent, title=title) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
48 |
self.info = info |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
49 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
50 |
if parent and parent.GetIcon(): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
51 |
self.SetIcon(parent.GetIcon()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
52 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
53 |
image = None |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
54 |
if self.info.Icon: |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
55 |
bitmap = wx.BitmapFromIcon(self.info.Icon) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
56 |
image = wx.StaticBitmap(self, bitmap=bitmap) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
57 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
58 |
name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version)) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
59 |
description = wx.StaticText(self, label=info.Description) |
1589
a5fd07db1db6
make about dialog on Windows not so big
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
60 |
description.Wrap(400) |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
61 |
copyright = wx.StaticText(self, label=info.Copyright) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
62 |
url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1]) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
63 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
64 |
font = name.GetClassDefaultAttributes().font |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
65 |
font.SetWeight(wx.FONTWEIGHT_BOLD) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
66 |
font.SetPointSize(18) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
67 |
name.SetFont(font) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
68 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
69 |
credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits")) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
70 |
license = wx.Button(self, label=_("&License")) |
1612
bd03e1217fa5
fix close button in system menu for AboutDialog on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1589
diff
changeset
|
71 |
close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close")) |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
72 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
73 |
btnSizer = wx.BoxSizer(wx.HORIZONTAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
74 |
btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
75 |
btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
76 |
btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
77 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
78 |
sizer = wx.BoxSizer(wx.VERTICAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
79 |
if image: |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
80 |
sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
81 |
sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
82 |
sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
83 |
sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
84 |
sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
85 |
sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
86 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
87 |
container = wx.BoxSizer(wx.VERTICAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
88 |
container.Add(sizer, flag=wx.ALL, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
89 |
self.SetSizer(container) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
90 |
self.Layout() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
91 |
self.Fit() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
92 |
self.Centre() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
93 |
self.Show(True) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
94 |
self.SetEscapeId(close.GetId()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
95 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
96 |
credits.Bind(wx.EVT_BUTTON, self.on_credits) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
97 |
license.Bind(wx.EVT_BUTTON, self.on_license) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
98 |
close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
99 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
100 |
def on_license(self, event): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
101 |
LicenseDialog(self, self.info) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
102 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
103 |
def on_credits(self, event): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
104 |
CreditsDialog(self, self.info) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
105 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
106 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
107 |
class CreditsDialog(wx.Dialog): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
108 |
def __init__(self, parent, info): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
109 |
wx.Dialog.__init__(self, parent, title=_("Credits"), size=(475, 320), |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
110 |
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
111 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
112 |
if parent and parent.GetIcon(): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
113 |
self.SetIcon(parent.GetIcon()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
114 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
115 |
self.SetMinSize((300, 200)) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
116 |
notebook = wx.Notebook(self) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
117 |
close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close")) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
118 |
close.SetDefault() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
119 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
120 |
developer = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
121 |
translators = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
122 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
123 |
developer.SetValue(u'\n'.join(info.Developers)) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
124 |
translators.SetValue(u'\n'.join(info.Translators)) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
125 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
126 |
notebook.AddPage(developer, text=_("Written by")) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
127 |
notebook.AddPage(translators, text=_("Translated by")) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
128 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
129 |
btnSizer = wx.BoxSizer(wx.HORIZONTAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
130 |
btnSizer.Add(close) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
131 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
132 |
sizer = wx.BoxSizer(wx.VERTICAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
133 |
sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
134 |
sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
135 |
self.SetSizer(sizer) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
136 |
self.Layout() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
137 |
self.Show() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
138 |
self.SetEscapeId(close.GetId()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
139 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
140 |
close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
141 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
142 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
143 |
class LicenseDialog(wx.Dialog): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
144 |
def __init__(self, parent, info): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
145 |
wx.Dialog.__init__(self, parent, title=_("License"), size=(500, 400), |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
146 |
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
147 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
148 |
if parent and parent.GetIcon(): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
149 |
self.SetIcon(parent.GetIcon()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
150 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
151 |
self.SetMinSize((400, 300)) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
152 |
close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close")) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
153 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
154 |
ctrl = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
155 |
ctrl.SetValue(info.License) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
156 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
157 |
btnSizer = wx.BoxSizer(wx.HORIZONTAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
158 |
btnSizer.Add(close) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
159 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
160 |
sizer = wx.BoxSizer(wx.VERTICAL) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
161 |
sizer.Add(ctrl, 1, wx.EXPAND | wx.ALL, 10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
162 |
sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
163 |
self.SetSizer(sizer) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
164 |
self.Layout() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
165 |
self.Show() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
166 |
self.SetEscapeId(close.GetId()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
167 |
|
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
168 |
close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
169 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1628
diff
changeset
|
170 |
|
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
171 |
def ShowAboutDialog(parent, info): |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
172 |
if os.name == "nt": |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
173 |
AboutDialog(parent, info) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
174 |
else: |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
175 |
wx.AboutBox(info) |