From: Robin Dunn Date: Mon, 9 Oct 2006 18:55:10 +0000 (+0000) Subject: Added wx.AboutBox() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f541d8293a16153070587cbd0c48795d717f002a Added wx.AboutBox() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41825 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/demo/AboutBox.py b/wxPython/demo/AboutBox.py new file mode 100644 index 0000000000..783c33b0dc --- /dev/null +++ b/wxPython/demo/AboutBox.py @@ -0,0 +1,66 @@ + +import wx + +#---------------------------------------------------------------------- + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + b = wx.Button(self, -1, "Show a wx.AboutBox", (50,50)) + self.Bind(wx.EVT_BUTTON, self.OnButton, b) + + + def OnButton(self, evt): + # First we create and fill the info object + info = wx.AboutDialogInfo() + info.Name = "Hello World" + info.Version = "1.2.3" + info.Copyright = "(C) 2006 Programmers and Coders Everywhere" + info.Description = \ + "A \"hello world\" program is a software program that prints out "\ + "\"Hello world!\" on a display device. It is used in many introductory "\ + "tutorials for teaching a programming language. Such a program is "\ + "typically one of the simplest programs possible in a computer language. "\ + "A \"hello world\" program can be a useful sanity test to make sure that "\ + "a language's compiler, development environment, and run-time environment "\ + "are correctly installed." + info.WebSite = ("http://en.wikipedia.org/wiki/Hello_world", "Hello World home page") + info.Developers = [ "Joe Programmer", + "Jane Coder", + "Vippy the Mascot" ] + + # Then we call wx.AboutBox giving it that info object + wx.AboutBox(info) + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wx.AboutBox

+ +This function shows the native standard about dialog containing the +information specified in info. If the current platform has a native +about dialog which is capable of showing all the fields in info, the +native dialog is used, otherwise the function falls back to the +generic wxWidgets version of the dialog. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) + diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index c0a19c56b0..ec9b65f664 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -66,6 +66,7 @@ _treeList = [ 'ButtonPanel', 'FlatNotebook', 'CustomTreeCtrl', + 'AboutBox', ]), # managed windows == things with a (optional) caption you can close @@ -80,6 +81,7 @@ _treeList = [ # the common dialogs ('Common Dialogs', [ + 'AboutBox', 'ColourDialog', 'DirDialog', 'FileDialog', diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index 78ed4c9b51..29e8650b64 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -280,6 +280,17 @@ For consistency, all classes having an Ok() method now also have IsOk(), use of the latter form is preferred although the former hasn't been deprecated yet +wx.BufferedDC and wx.BufferedPaintDC, if created with a reference to a +window and no program supplied buffer bitmap, will not do its own +buffering if the window is already double buffered by the system. +Also added a wx.AutoBufferedPaintDC that is a subclass of wx.PaintDC +on platforms that do double buffering by default, and a subclass of +wx.BufferedPaintDC on the platforms that don't. + +Added the wx.AboutBox() function and wx.AboutDialogInfo class. They +provide a way to show a standard About box for the application, which +will either be a native dialog or a generic one depending on what info +is provided and if it can all be shown with the native dialog. diff --git a/wxPython/setup.py b/wxPython/setup.py index 43a2a37691..b860e78ae7 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -332,6 +332,7 @@ swig_sources = run_swig(['misc.i'], 'src', GENDIR, PKGDIR, 'src/_clipbrd.i', 'src/_stdpaths.i', 'src/_power.i', + 'src/_about.i', ], True) ext = Extension('_misc_', swig_sources, diff --git a/wxPython/src/_about.i b/wxPython/src/_about.i new file mode 100644 index 0000000000..cad8b1619a --- /dev/null +++ b/wxPython/src/_about.i @@ -0,0 +1,302 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: _about.i +// Purpose: SWIG interface for wxAboutDialog +// +// Author: Robin Dunn +// +// Created: 08-Oct-2006 +// RCS-ID: $Id$ +// Copyright: (c) 2006 by Total Control Software +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +// Not a %module + +%{ +#include +%} + +//--------------------------------------------------------------------------- +%newgroup + + +DocStr(wxAboutDialogInfo, +"`wx.AboutDialogInfo contains information shown in the standard About +dialog displayed by the `wx.AboutBox` function. This class contains +the general information about the program, such as its name, version, +copyright and so on, as well as lists of the program developers, +documentation writers, artists and translators. + +While all the main platforms have a native implementation of the about +dialog, they are often more limited than the generic version provided +by wxWidgets and so the generic version is used if +`wx.AboutDialogInfo` has any fields not supported by the native +version. Currently GTK+ version supports all the possible fields +natively but MSW and Mac versions don't support URLs, licence text nor +custom icons in the about dialog and if either of those is used, +wxAboutBox() will automatically use the generic version so you should +avoid specifying these fields to achieve more native look and feel. +", ""); + +class wxAboutDialogInfo +{ +public: + wxAboutDialogInfo(); + ~wxAboutDialogInfo(); + + DocDeclStr( + void , SetName(const wxString& name), + "Set the name of the program. If this method is not called, the string +returned by `wx.App.GetAppName` will be shown in the dialog.", ""); + + DocDeclStr( + wxString , GetName() const, + "Returns the program name.", ""); + + %property(Name, GetName, SetName); + + DocDeclStr( + void , SetVersion(const wxString& version), + "Set the version of the program. The version is in free format, +i.e. not necessarily in the x.y.z form but it shouldn't contain the +\"version\" word.", ""); + + DocDeclStr( + bool , HasVersion() const, + "Returns ``True`` if the version property has been set.", ""); + + DocDeclStr( + wxString , GetVersion() const, + "Returns the version value.", ""); + + %property(Version, GetVersion, SetVersion); + + + DocDeclStr( + void , SetDescription(const wxString& desc), + "Set brief, but possibly multiline, description of the program.", ""); + + DocDeclStr( + bool , HasDescription() const, + "Returns ``True`` if the description property has been set.", ""); + + DocDeclStr( + wxString , GetDescription() const, + "Returns the description value.", ""); + + %property(Description, GetDescription, SetDescription); + + + DocDeclStr( + void , SetCopyright(const wxString& copyright), + "Set the short string containing the program copyright +information. Notice that any occurrences of \"(C)\" in ``copyright`` +will be replaced by the copyright symbol (circled C) automatically, +which means that you can avoid using this symbol in the program source +code which can be problematic.", ""); + + DocDeclStr( + bool , HasCopyright() const, + "Returns ``True`` if the copyright property has been set.", ""); + + DocDeclStr( + wxString , GetCopyright() const, + "Returns the copyright value.", ""); + + %property(Copyright, GetCopyright, SetCopyright); + + + DocDeclStr( + void , SetLicence(const wxString& licence), + "Set the long, multiline string containing the text of the program +licence. + +Only GTK+ version supports showing the licence text in the native +about dialog currently so the generic version will be used under all +the other platforms if this method is called. To preserve the native +look and feel it is advised that you do not call this method but +provide a separate menu item in the \"Help\" menu for displaying the +text of your program licence. +", ""); + + DocDeclStr( + void , SetLicense(const wxString& licence), + "This is the same as `SetLicence`.", ""); + + DocDeclStr( + bool , HasLicence() const, + "Returns ``True`` if the licence property has been set.", ""); + + DocDeclStr( + wxString , GetLicence() const, + "Returns the licence value.", ""); + + %property(Licence, GetLicence, SetLicence); + %pythoncode { License = Licence } + + + DocDeclStr( + void , SetIcon(const wxIcon& icon), + "Set the icon to be shown in the dialog. By default the icon of the +main frame will be shown if the native about dialog supports custom +icons. If it doesn't but a valid icon is specified using this method, +the generic about dialog is used instead so you should avoid calling +this function for maximally native look and feel.", ""); + + DocDeclStr( + bool , HasIcon() const, + "Returns ``True`` if the icon property has been set.", ""); + + DocDeclStr( + wxIcon , GetIcon() const, + "Return the current icon value.", ""); + + %property(Icon, GetIcon, SetIcon); + + + // web site for the program and its description (defaults to URL itself if + // empty) + %Rename(_SetWebSite, + void , SetWebSite(const wxString& url, const wxString& desc = wxEmptyString)); + %Rename(_GetWebSiteURL, + wxString , GetWebSiteURL() const); + %Rename(_GetWebSiteDescription, + wxString , GetWebSiteDescription() const); + bool HasWebSite() const; + + %pythoncode { + def SetWebSite(self, args): + """ + SetWebSite(self, URL, [Description]) + + Set the web site property. The ``args`` parameter can + either be a single string for the URL, to a 2-tuple of + (URL, Description) strings. + """ + if type(args) in [str, unicode]: + self._SetWebSite(args) + else: + self._SetWebSite(args[0], args[1]) + + def GetWebSite(self): + """ + GetWebSite(self) --> (URL, Description) + """ + return (self._GetWebSiteURL(), self._GetWebSiteDescription()) + } + %property(WebSite, GetWebSite, SetWebSite) + + + + DocDeclAStr( + void , SetDevelopers(const wxArrayString& developers), + "SetDevelopers(self, list developers)", + "Set the list of the developers of the program.", ""); + + DocDeclStr( + void , AddDeveloper(const wxString& developer), + "Add a string to the list of developers.", ""); + + DocDeclStr( + bool , HasDevelopers() const, + "Returns ``True if any developers have been set.", ""); + + DocDeclAStr( + const wxArrayString& , GetDevelopers() const, + "GetDevelopers(self) --> list", + "Returns the list of developers.", ""); + + %property(Developers, GetDevelopers, SetDevelopers); + + + DocDeclAStr( + void , SetDocWriters(const wxArrayString& docwriters), + "SetDocWriters(self, list docwriters)", + "Set the list of the documentation writers.", ""); + + DocDeclStr( + void , AddDocWriter(const wxString& docwriter), + "Add a string to the list of documentation writers.", ""); + + DocDeclStr( + bool , HasDocWriters() const, + "Returns ``True if any documentation writers have been set.", ""); + + DocDeclAStr( + const wxArrayString& , GetDocWriters() const, + "GetDocWriters(self) --> list", + "Returns the list of documentation writers.", ""); + + %property(DocWriters, GetDocWriters, SetDocWriters); + + + DocDeclAStr( + void , SetArtists(const wxArrayString& artists), + "SetArtists(self, list artists)", + "Set the list of artists for the program.", ""); + + DocDeclStr( + void , AddArtist(const wxString& artist), + "Add a string to the list of artists.", ""); + + DocDeclStr( + bool , HasArtists() const, + "Returns ``True`` if any artists have been set.", ""); + + DocDeclAStr( + const wxArrayString& , GetArtists() const, + "GetArtists(self) --> list", + "Returns the list od artists.", ""); + + %property(Artists, GetArtists, SetArtists); + + + + DocDeclAStr( + void , SetTranslators(const wxArrayString& translators), + "SetTranslators(self, list translators)", + "Sets the list of program translators.", ""); + + DocDeclStr( + void , AddTranslator(const wxString& translator), + "Add a string to the list of translators.", ""); + + DocDeclStr( + bool , HasTranslators() const, + "Returns ``True`` if any translators have been set.", ""); + + DocDeclAStr( + const wxArrayString& , GetTranslators() const, + "GetTranslators(self) --> list", + "Returns the list of program translators.", ""); + + %property(Translators, GetTranslators, SetTranslators); + + + // implementation only + // ------------------- + + // "simple" about dialog shows only textual information (with possibly + // default icon but without hyperlink nor any long texts such as the + // licence text) + bool IsSimple() const; + + // get the description and credits (i.e. all of developers, doc writers, + // artists and translators) as a one long multiline string + wxString GetDescriptionAndCredits() const; + +}; + + + +DocStr(wxAboutBox, + "This function shows the standard about dialog containing the +information specified in ``info``. If the current platform has a +native about dialog which is capable of showing all the fields in +``info``, the native dialog is used, otherwise the function falls back +to the generic wxWidgets version of the dialog.", ""); + +void wxAboutBox(const wxAboutDialogInfo& info); + + +//--------------------------------------------------------------------------- diff --git a/wxPython/src/misc.i b/wxPython/src/misc.i index db0e94597c..6b5ad1ce34 100644 --- a/wxPython/src/misc.i +++ b/wxPython/src/misc.i @@ -49,5 +49,6 @@ MAKE_CONST_WXSTRING_NOSWIG(EmptyString); %include _display.i %include _stdpaths.i %include _power.i +%include _about.i //---------------------------------------------------------------------------