dialogs/AboutDialog.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 09 Mar 2017 15:35:19 +0300
changeset 1657 3a98027ff372
parent 1628 6309efe91289
child 1736 7e61baa047f0
permissions -rwxr-xr-x
apply constraints to names for tasks and task instances in resource configuration

The same rules as for IEC identifiers are applied.
- no non-lating characters, ...
- no IEC keywords
- check for duplicate names in resource configuration

closes #19
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
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
import os
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    34
import sys
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    35
import time
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
#----------------------------------------------------------------------
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
class AboutDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    43
    """
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    44
    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
    45
    well...sucks.
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
    """
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
        title = _("About") + " " + info.Name
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    49
        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
    50
        self.info = info
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
            self.SetIcon(parent.GetIcon())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    54
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    55
        image = None
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    56
        if self.info.Icon:
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    57
            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
    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
#----------------------------------------------------------------------
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   111
class CreditsDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   112
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   113
        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
   114
                           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
   115
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   116
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   117
            self.SetIcon(parent.GetIcon())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   118
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   119
        self.SetMinSize((300, 200))
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   120
        notebook = wx.Notebook(self)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   121
        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
   122
        close.SetDefault()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   123
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   124
        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
   125
        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
   126
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   127
        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
   128
        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
   129
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   130
        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
   131
        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
   132
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   133
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   134
        btnSizer.Add(close)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   135
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   136
        sizer = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   137
        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
   138
        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
   139
        self.SetSizer(sizer)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   140
        self.Layout()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   141
        self.Show()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   142
        self.SetEscapeId(close.GetId())
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
        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
   145
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   146
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
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   149
class LicenseDialog(wx.Dialog):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   150
    def __init__(self, parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   151
        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
   152
                           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
   153
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   154
        if parent and parent.GetIcon():
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   155
            self.SetIcon(parent.GetIcon())
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
        self.SetMinSize((400, 300))
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   158
        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
   159
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   160
        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
   161
        ctrl.SetValue(info.License)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   162
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   163
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   164
        btnSizer.Add(close)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   165
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   166
        sizer = wx.BoxSizer(wx.VERTICAL)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   167
        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
   168
        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
   169
        self.SetSizer(sizer)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   170
        self.Layout()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   171
        self.Show()
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   172
        self.SetEscapeId(close.GetId())
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   173
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   174
        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
   175
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   176
#----------------------------------------------------------------------
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   177
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   178
def ShowAboutDialog(parent, info):
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   179
    if os.name == "nt":
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   180
        AboutDialog(parent, info)
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   181
    else:
894f31f8ca64 make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   182
        wx.AboutBox(info)