andrej@1565: #!/usr/bin/env python andrej@1565: # -*- coding: utf-8 -*- andrej@1565: andrej@1565: # Copyright (c) 2009, 2010 by Steven Sproat andrej@1628: # Copyright (c) 2016 by Andrey Skvortsov edouard@3909: # Copyright (c) 2024 by Edouard Tisserant edouard@3909: andrej@1628: # See COPYING file for copyrights details. kinsamanka@3750: andrej@1565: import os andrej@1565: import wx edouard@3570: import wx.adv andrej@1565: from wx.lib.agw.hyperlink import HyperLinkCtrl andrej@1565: andrej@1565: andrej@1565: class AboutDialog(wx.Dialog): andrej@1565: """ edouard@3909: Simpler replacement of About Dialog that shows LongVersion andrej@1565: """ andrej@1565: def __init__(self, parent, info): andrej@1565: title = _("About") + " " + info.Name andrej@1565: wx.Dialog.__init__(self, parent, title=title) andrej@1565: self.info = info andrej@1565: andrej@1565: if parent and parent.GetIcon(): andrej@1565: self.SetIcon(parent.GetIcon()) andrej@1565: andrej@1565: image = None andrej@1565: if self.info.Icon: edouard@3586: bitmap = wx.Bitmap() edouard@3586: bitmap.CopyFromIcon(self.info.Icon) andrej@1565: image = wx.StaticBitmap(self, bitmap=bitmap) andrej@1565: andrej@1565: name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version)) andrej@1565: description = wx.StaticText(self, label=info.Description) andrej@1589: description.Wrap(400) andrej@1565: copyright = wx.StaticText(self, label=info.Copyright) andrej@1565: url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1]) edouard@3906: long_version = wx.StaticText(self, label=info.GetLongVersion()) andrej@1565: andrej@1565: font = name.GetClassDefaultAttributes().font andrej@1565: font.SetWeight(wx.FONTWEIGHT_BOLD) andrej@1565: font.SetPointSize(18) andrej@1565: name.SetFont(font) andrej@1565: andrej@1565: credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits")) andrej@1565: license = wx.Button(self, label=_("&License")) andrej@1612: close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close")) andrej@1565: andrej@1565: btnSizer = wx.BoxSizer(wx.HORIZONTAL) andrej@1565: btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5) andrej@1565: btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5) andrej@1565: btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5) andrej@1565: andrej@1565: sizer = wx.BoxSizer(wx.VERTICAL) andrej@1565: if image: andrej@1565: sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5) andrej@1565: sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10) andrej@1565: sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10) andrej@1565: sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10) andrej@1565: sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15) edouard@3906: sizer.Add(long_version, flag=wx.CENTER | wx.BOTTOM, border=10) andrej@1565: sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5) andrej@1565: andrej@1565: container = wx.BoxSizer(wx.VERTICAL) andrej@1565: container.Add(sizer, flag=wx.ALL, border=10) andrej@1565: self.SetSizer(container) andrej@1565: self.Layout() andrej@1565: self.Fit() andrej@1565: self.Centre() andrej@1565: self.Show(True) andrej@1565: self.SetEscapeId(close.GetId()) andrej@1565: andrej@1565: credits.Bind(wx.EVT_BUTTON, self.on_credits) andrej@1565: license.Bind(wx.EVT_BUTTON, self.on_license) andrej@1565: close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) andrej@1565: andrej@1565: def on_license(self, event): andrej@1565: LicenseDialog(self, self.info) andrej@1565: andrej@1565: def on_credits(self, event): andrej@1565: CreditsDialog(self, self.info) andrej@1565: andrej@1565: andrej@1565: class CreditsDialog(wx.Dialog): andrej@1565: def __init__(self, parent, info): andrej@1565: wx.Dialog.__init__(self, parent, title=_("Credits"), size=(475, 320), andrej@1565: style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) andrej@1565: andrej@1565: if parent and parent.GetIcon(): andrej@1565: self.SetIcon(parent.GetIcon()) andrej@1565: andrej@1565: self.SetMinSize((300, 200)) andrej@1565: notebook = wx.Notebook(self) andrej@1565: close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close")) andrej@1565: close.SetDefault() andrej@1565: andrej@1565: developer = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE) andrej@1565: translators = wx.TextCtrl(notebook, style=wx.TE_READONLY | wx.TE_MULTILINE) andrej@1565: kinsamanka@3750: developer.SetValue('\n'.join(info.Developers)) kinsamanka@3750: translators.SetValue('\n'.join(info.Translators)) andrej@1565: andrej@1565: notebook.AddPage(developer, text=_("Written by")) andrej@1565: notebook.AddPage(translators, text=_("Translated by")) andrej@1565: andrej@1565: btnSizer = wx.BoxSizer(wx.HORIZONTAL) andrej@1565: btnSizer.Add(close) andrej@1565: andrej@1565: sizer = wx.BoxSizer(wx.VERTICAL) andrej@1565: sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 10) andrej@1565: sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10) andrej@1565: self.SetSizer(sizer) andrej@1565: self.Layout() andrej@1565: self.Show() andrej@1565: self.SetEscapeId(close.GetId()) andrej@1565: andrej@1565: close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) andrej@1565: andrej@1565: andrej@1565: class LicenseDialog(wx.Dialog): andrej@1565: def __init__(self, parent, info): andrej@1565: wx.Dialog.__init__(self, parent, title=_("License"), size=(500, 400), andrej@1565: style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) andrej@1565: andrej@1565: if parent and parent.GetIcon(): andrej@1565: self.SetIcon(parent.GetIcon()) andrej@1565: andrej@1565: self.SetMinSize((400, 300)) andrej@1565: close = wx.Button(self, id=wx.ID_CLOSE, label=_("&Close")) andrej@1565: andrej@1565: ctrl = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE) andrej@1565: ctrl.SetValue(info.License) andrej@1565: andrej@1565: btnSizer = wx.BoxSizer(wx.HORIZONTAL) andrej@1565: btnSizer.Add(close) andrej@1565: andrej@1565: sizer = wx.BoxSizer(wx.VERTICAL) andrej@1565: sizer.Add(ctrl, 1, wx.EXPAND | wx.ALL, 10) andrej@1565: sizer.Add(btnSizer, flag=wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, border=10) andrej@1565: self.SetSizer(sizer) andrej@1565: self.Layout() andrej@1565: self.Show() andrej@1565: self.SetEscapeId(close.GetId()) andrej@1565: andrej@1565: close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy()) andrej@1565: andrej@1736: andrej@1565: def ShowAboutDialog(parent, info): edouard@3909: AboutDialog(parent, info)