~ubuntu-branches/ubuntu/utopic/python-traitsui/utopic

« back to all changes in this revision

Viewing changes to traitsui/help.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-07-09 13:57:39 UTC
  • Revision ID: james.westby@ubuntu.com-20110709135739-x5u20q86huissmn1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#------------------------------------------------------------------------------
 
2
#
 
3
#  Copyright (c) 2005, Enthought, Inc.
 
4
#  All rights reserved.
 
5
#
 
6
#  This software is provided without warranty under the terms of the BSD
 
7
#  license included in enthought/LICENSE.txt and may be redistributed only
 
8
#  under the conditions described in the aforementioned license.  The license
 
9
#  is also available online at http://www.enthought.com/licenses/BSD.txt
 
10
#
 
11
#  Thanks for using Enthought open source!
 
12
#
 
13
#  Author: David C. Morrill
 
14
#  Date:   02/04/2005
 
15
#
 
16
#------------------------------------------------------------------------------
 
17
 
 
18
""" Defines the help interface for displaying the help associated with a
 
19
    Traits UI View object.
 
20
"""
 
21
 
 
22
#-------------------------------------------------------------------------------
 
23
#  Imports:
 
24
#-------------------------------------------------------------------------------
 
25
 
 
26
from __future__ import absolute_import
 
27
 
 
28
from .toolkit import toolkit
 
29
 
 
30
#-------------------------------------------------------------------------------
 
31
#  Default handler for showing the help associated with a view:
 
32
#-------------------------------------------------------------------------------
 
33
 
 
34
def default_show_help ( info, control ):
 
35
    """ Default handler for showing the help associated with a view.
 
36
    """
 
37
    toolkit().show_help( info.ui, control )
 
38
 
 
39
# The default handler for showing help
 
40
show_help = default_show_help
 
41
 
 
42
#-------------------------------------------------------------------------------
 
43
#  Allows an application to change the default show help handler:
 
44
#-------------------------------------------------------------------------------
 
45
 
 
46
def on_help_call ( new_show_help = None ):
 
47
    """ Sets a new global help provider function.
 
48
 
 
49
    Parameters
 
50
    ----------
 
51
    new_show_help : function
 
52
        The function to set as the new global help provider
 
53
 
 
54
    Returns
 
55
    -------
 
56
    The previous global help provider function
 
57
 
 
58
    Description
 
59
    -----------
 
60
    The help provider function must have a signature of
 
61
    *function*(*info*, *control*), where *info* is a UIInfo object for the
 
62
    current view, and *control* is the UI control that invokes the function
 
63
    (typically, a **Help** button). It is provided in case the help provider
 
64
    needs to position the help window relative to the **Help** button.
 
65
 
 
66
    To retrieve the current help provider function, call this function with
 
67
    no arguments.
 
68
    """
 
69
    global show_help
 
70
 
 
71
    result = show_help
 
72
    if new_show_help is not None:
 
73
        show_help = new_show_help
 
74
    return result
 
75