File: about.py

package info (click to toggle)
python-bumps 1.0.0b2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,144 kB
  • sloc: python: 23,941; xml: 493; ansic: 373; makefile: 209; sh: 91; javascript: 90
file content (193 lines) | stat: -rw-r--r-- 7,260 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Copyright (C) 2006-2011, University of Maryland
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/ or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

# Author: James Krycka

"""
This module contains a custom About Dialog class and associated text strings
used for informational display purposes.  Note that the product version is
maintained in the version.py file and therefore is imported here.
"""

import os
import wx

try:
    from agw.hyperlink import HyperLinkCtrl
except ImportError:  # if it's not there, try the older location.
    from wx.lib.agw.hyperlink import HyperLinkCtrl

from wx.lib.wordwrap import wordwrap

from .. import __version__ as APP_VERSION
from .utilities import resource

# Resource files.
PROG_ICON = "bumps.ico"

# Text strings used in About Dialog boxes and for other project identification
# purposes.
#
# Note that paragraphs intended to be processed by wordwrap are formatted as
# one string without newline characters.
APP_NAME = "Bumps"

APP_TITLE = "Bumps: curve fitter with uncertainty estimation"

APP_COPYRIGHT = "(C) 2011 University of Maryland"

APP_DESCRIPTION = """\
The Bumps uncertainty modeler provides an interactive user interface for \
modelling an experiment and fitting it to data.\
varying free form layers.
"""

APP_LICENSE = """\
Permission is hereby granted, free of charge, to any person obtaining a copy \
of this software and associated documentation files (the "Software"), to deal \
in the Software without restriction, including without limitation the rights \
to use, copy, modify, merge, publish, distribute, sublicense, and/ or sell \
copies of the Software, and to permit persons to whom the Software is \
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in \
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \
THE SOFTWARE.
"""

APP_CREDITS = """\
This program was developed jointly by the University of Maryland (UMD) and \
the National Institute of Standards and Technology (NIST) as part of the \
Distributed Data Analysis of Neutron Scattering Experiments (DANSE) project \
funded by the US National Science Foundation under grant DMR-0520547. \
Principal contributors:

Paul Kienzle, NIST
    - Application concept and design
    - Application API and Command Line Interface development
    - Optimizers and uncertainty analysis
    - Documentation

Ismet Sahin, UMD
    - Optimizers

James Krycka, UMD
    - Graphical User Interface design and development
    - Window's installer

Nikunj Patel, UMD
    - Graphical User Interface design and development

Christopher Metting, UMD
    - Artwork
"""

APP_PROJECT_URL = "http://github.com/bumps"
APP_PROJECT_TAG = "Bumps home page"

APP_TUTORIAL_URL = "http://pypi.org/docs/bumps"
APP_TUTORIAL_TAG = "Bumps documentation"
APP_TUTORIAL = """\
For the Bumps User's Guide and Reference Manual, please visit:\
"""

# ==============================================================================


class AboutDialog(wx.Dialog):
    """
    This class creates a pop-up About Dialog box with several display options.
    """

    def __init__(
        self,
        parent=None,
        id=wx.ID_ANY,
        title="About",
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.DEFAULT_DIALOG_STYLE,
        show_name=True,
        show_notice=True,
        show_link=True,
        show_link_docs=False,
        info="...",
    ):
        wx.Dialog.__init__(self, parent, id, title, pos, size, style)

        # Display the application's icon in the title bar.
        icon = wx.Icon(resource(PROG_ICON), wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        # Set the font for this window and all child windows (widgets) from the
        # parent window, or from the system defaults if no parent is given.
        # A dialog box does not inherit font info from its parent, so we will
        # explicitly get it from the parent and apply it to the dialog box.
        if parent is not None:
            font = parent.GetFont()
            self.SetFont(font)

        # Display program name and version.
        if show_name:
            prog = wx.StaticText(self, wx.ID_ANY, label=(APP_NAME + " " + APP_VERSION))
            font = prog.GetFont()
            font.SetPointSize(font.GetPointSize() + 1)
            font.SetWeight(wx.BOLD)
            prog.SetFont(font)

        # Display copyright notice.
        if show_notice:
            copyright = wx.StaticText(self, wx.ID_ANY, label=APP_COPYRIGHT)

        # Display hyperlink to the home page and/or doc page.
        if show_link:
            hyper1 = HyperLinkCtrl(self, wx.ID_ANY, label=APP_PROJECT_TAG, URL=APP_PROJECT_URL)
        if show_link_docs:
            hyper2 = HyperLinkCtrl(self, wx.ID_ANY, label=APP_TUTORIAL_TAG, URL=APP_TUTORIAL_URL)

        # Display the body of text for this about dialog box.
        info = wx.StaticText(self, wx.ID_ANY, label=wordwrap(info, 530, wx.ClientDC(self)))
        # Create the OK button control.
        ok_button = wx.Button(self, wx.ID_OK, "OK")
        ok_button.SetDefault()

        # Use a vertical box sizer to manage the widget layout..
        sizer = wx.BoxSizer(wx.VERTICAL)
        if show_name:
            sizer.Add(prog, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, border=10)
        if show_notice:
            sizer.Add(copyright, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, border=10)
        sizer.Add(info, 0, wx.ALL, border=10)
        if show_link:
            sizer.Add(hyper1, 0, wx.ALL, border=10)
        if show_link_docs:
            sizer.Add(hyper2, 0, wx.ALL, border=10)
        sizer.Add(ok_button, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, border=10)

        # Finalize the sizer and establish the dimensions of the dialog box.
        self.SetSizer(sizer)
        sizer.Fit(self)