File: dynamicloader.html

package info (click to toggle)
python-pmw 0.6.2-0.1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,652 kB
  • ctags: 2,716
  • sloc: python: 10,720; makefile: 44; sh: 24
file content (121 lines) | stat: -rw-r--r-- 5,356 bytes parent folder | download
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

    <html>
    <head>
    <title>Dynamic loader</title>
    </head>

    <body bgcolor="#ffffff" text="#000000" link="#0000ee"
	vlink="551a8b" alink="ff0000">

    <center><P ALIGN="CENTER">
    <IMG SRC = transdove.gif ALT = "" WIDTH=70 HEIGHT=75>
    <IMG SRC = transdove.gif ALT = "" WIDTH=70 HEIGHT=75>
    <IMG SRC = transdove.gif ALT = "" WIDTH=70 HEIGHT=75>
    </p></center>

    <h1 ALIGN="CENTER">Dynamic loader</h1>
    <p>
    
<p>
    There are two aspects of Pmw, unrelated to megawidgets, that
    require special attention.  Firstly, Pmw is made up of many
    sub-modules, potentially making access to its various classes and
    functions cumbersome for the user.  Secondly, Pmw is regularly
    being modified and added to, thus requiring the release of new
    versions.  Therefore, techniques for making access to the
    sub-modules easy and efficient and for dealing with the different
    versions have been developed.  These techniques are incorporated
    into the dynamic loader which Pmw creates when it is first
    imported.</p>

<p>    The first purpose of the loader is to give access to all Pmw classes
    and functions through a single entry point, the <strong>Pmw.</strong> prefix.  For
    example, to access the ComboBox class (which resides in one of the
    sub-modules of Pmw), you just have to use <code>Pmw.ComboBox</code>.  Without
    the loader, this would be a more complicated reference, such as,
    hypothetically, <code>Pmw.PmwComboBox.Combobox</code>.</p>

<p>    The second purpose of the loader is to delay the importing of the
    sub-modules until they are needed.  This improves the startup time
    of applications which only use a few Pmw megawidgets.  It also
    allows more megawidgets to be added to the library without slowing
    down applications which do not use them.</p>

<p>    The third purpose of the loader is to allow a script using Pmw to
    specify which version of Pmw it requires.  This allows an
    application to continue working correctly even after newer releases
    of Pmw have been made which are not compatible with the version
    expected by the application.  Several versions of Pmw can be
    installed at once, with the actual version used being specified by
    each application.  In addition, the loader can be configured to
    search in one or more alpha versions of Pmw.  These versions may
    contain new megawidgets, or new versions of existing megawidgets,
    that are currently not in the base releases.</p>

<p>    Several functions are available to set and query the version of
    Pmw being used.  These are <code>Pmw.setversion()</code> and
    <code>Pmw.setalphaversions()</code> which specify the version and alpha
    versions (if any) to use for this session; <code>Pmw.version()</code> which
    returns the version(s) being used by this session; and
    <code>Pmw.installedversions()</code> which returns the version(s) of Pmw
    currently installed.  These are described in the
    <a href="PmwFunctions.html">Pmw functions reference manual</a>.</p>

<p>    When Pmw is first imported, an instance of PmwLoader is created
    and placed into <code>sys.modules['Pmw']</code>.  From that point on, any
    reference to attributes of the Pmw 'module' is handled by the
    loader.  The real Pmw package is stored in <code>sys.modules['_Pmw']</code>.</p>

<p>    The loader searches the Pmw package base directory for
    sub-directories with the prefixes <code>Pmw_</code> and <code>Alpha_</code>, which
    contain Pmw base releases and alpha releases.  The version numbers
    are given by the part of the directory name following the prefix. 
    These versions are available for use and are those returned by the
    <code>Pmw.installedversions</code> function.  The current version is set to
    the base release with the greatest version number.  When the first
    reference to a Pmw class or function is made, the loader reads the
    files named <strong>Pmw.def</strong> in the current base version directory and
    also in the alpha directories (if any).  These files list all the
    classes and functions supported by the version.  Pmw attributes
    are first searched for in the alpha directories and then in the
    base version directory.  The first directory which supports the
    reference is used.  In this way, alpha versions override base
    versions.</p>

<p>    The directory <code>Alpha_99_9_example</code> contains a simple example of
    how to structure an alpha version.  The following code can be used
    to request that the alpha version be used and then creates an
    instance of a new megawidget defined in the alpha version.</p>

<dl><dd><pre> import Pmw
 Pmw.setalphaversions('99.9.example')

 # Create a standard message dialog using the base Pmw version.
 ordinary = Pmw.MessageDialog(
     message_text = 'Ordinary\nPmw Dialog')

 # Create an example dialog using the alpha Pmw version.
 alpha = Pmw.AlphaExample()</pre></dl>

<p></p>



    <center><P ALIGN="CENTER">
    <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
    </p></center>
    

    <font size=-1>
    <center><P ALIGN="CENTER">
    <a href="index.html">Home</a>. 
    Pmw 0.6.2
    Maintainer
    <a href="mailto:gregm@iname.com">gregm@iname.com</a>.
    23 Feb 1998
    </p></center>
    </font>

    </body>
    </html>