dialogs/AboutDialog.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 24 Nov 2023 14:51:27 +0100
changeset 3878 58bce98b9ac6
parent 3750 f62625418bff
child 3906 f831ff63ca6e
permissions -rw-r--r--
SVGHMI: fix exception when stopping
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
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3586
diff changeset
    34
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
3570
eb915a9fdcb0 IDE: fix About dialog not showing (wxPython4 sequel), update copyright section.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 1881
diff changeset
    37
import wx.adv
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    38
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
    39
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
class AboutDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    42
    """
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    43
    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
    44
    well...sucks.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
    """
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
        title = _("About") + " " + info.Name
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
        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
    49
        self.info = info
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
            self.SetIcon(parent.GetIcon())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    54
        image = None
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    55
        if self.info.Icon:
3586
cbc6a6ccd52e IDE: Fixed About dialog exception on Windows, and typo in about dialog's content.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3570
diff changeset
    56
            bitmap = wx.Bitmap()
cbc6a6ccd52e IDE: Fixed About dialog exception on Windows, and typo in about dialog's content.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3570
diff changeset
    57
            bitmap.CopyFromIcon(self.info.Icon)
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    58
            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
    59
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    60
        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
    61
        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
    62
        description.Wrap(400)
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    63
        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
    64
        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
    65
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    66
        font = name.GetClassDefaultAttributes().font
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    67
        font.SetWeight(wx.FONTWEIGHT_BOLD)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    68
        font.SetPointSize(18)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    69
        name.SetFont(font)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    70
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    71
        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
    72
        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
    73
        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
    74
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    75
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    76
        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
    77
        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
    78
        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
    79
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    80
        sizer = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    81
        if image:
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    82
            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
    83
        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
    84
        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
    85
        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
    86
        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
    87
        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
    88
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    89
        container = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    90
        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
    91
        self.SetSizer(container)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    92
        self.Layout()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    93
        self.Fit()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    94
        self.Centre()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    95
        self.Show(True)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    96
        self.SetEscapeId(close.GetId())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    97
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    98
        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
    99
        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
   100
        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
   101
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   102
    def on_license(self, event):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   103
        LicenseDialog(self, self.info)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   104
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   105
    def on_credits(self, event):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   106
        CreditsDialog(self, self.info)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   107
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   108
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
class CreditsDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   111
        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
   112
                           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
   113
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   114
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   115
            self.SetIcon(parent.GetIcon())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   116
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   117
        self.SetMinSize((300, 200))
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   118
        notebook = wx.Notebook(self)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   119
        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
   120
        close.SetDefault()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   121
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   122
        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
   123
        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
   124
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3586
diff changeset
   125
        developer.SetValue('\n'.join(info.Developers))
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3586
diff changeset
   126
        translators.SetValue('\n'.join(info.Translators))
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   127
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   128
        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
   129
        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
   130
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   131
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   132
        btnSizer.Add(close)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   133
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   134
        sizer = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   135
        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
   136
        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
   137
        self.SetSizer(sizer)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   138
        self.Layout()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   139
        self.Show()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   140
        self.SetEscapeId(close.GetId())
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
        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
   143
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   144
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   145
class LicenseDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   146
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   147
        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
   148
                           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
   149
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   150
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   151
            self.SetIcon(parent.GetIcon())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   152
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   153
        self.SetMinSize((400, 300))
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   154
        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
   155
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   156
        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
   157
        ctrl.SetValue(info.License)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   158
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   159
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   160
        btnSizer.Add(close)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   161
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   162
        sizer = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   163
        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
   164
        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
   165
        self.SetSizer(sizer)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   166
        self.Layout()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   167
        self.Show()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   168
        self.SetEscapeId(close.GetId())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   169
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   170
        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
   171
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1628
diff changeset
   172
1565
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   173
def ShowAboutDialog(parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   174
    if os.name == "nt":
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   175
        AboutDialog(parent, info)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   176
    else:
3570
eb915a9fdcb0 IDE: fix About dialog not showing (wxPython4 sequel), update copyright section.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 1881
diff changeset
   177
        wx.adv.AboutBox(info)