~toolpart/+junk/pythoncard

« back to all changes in this revision

Viewing changes to docs/html/framework/resource_files.html

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2006-11-12 17:52:13 UTC
  • mfrom: (2.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20061112175213-tv8bnl6rtpa2qw1o
Tags: 0.8.1-8.1
* Non-maintainer upload.
* Fix path to findfiles, codeEditor and resourceEditor:
   + patch from Ernest ter Kuile <ernestjw@xs4all.nl>. (Closes: #397018)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
2
<html>
 
3
  <head>
 
4
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
5
    <link rel="stylesheet" href="../PythonCard.css" type="text/css" />
 
6
  <title>Framework Overview - Resource Files</title>
 
7
</head>
 
8
  <body>
 
9
<div id="banner">
 
10
<h1>Framework Overview - Resource Files</h1>
 
11
</div>
 
12
<?php include "../sidebar.php" ?>
 
13
<div id="content">
 
14
<p>Updated: April 10, 2004 for release 0.7.3</p>
 
15
 
 
16
<p>Resource files are an old idea, but they are not widely used in the Python
 
17
community. My own experience with resources is based largely on how Mac
 
18
applications used the resource fork. PythonCard separates the window, 
 
19
component layout, menu descriptions, and strings from the source code by putting
 
20
them in a separate .rsrc.py file. This allows the layout to be modified
 
21
independently of the source code and logic of the application. It also
 
22
simplifies supporting multiple layouts for different OS platforms or doing
 
23
international versions of an application. Finally, it means that a
 
24
non-programmer can handle the layout since they do not need to write any
 
25
Python code.</p>
 
26
 
 
27
<p>The resource file typically shares the same base name as the main
 
28
application, so the <a href="http://pythoncard.sourceforge.net/samples/minimal.html">minimal sample</a> has two files:</p>
 
29
 
 
30
<pre>
 
31
  minimal.py
 
32
  minimal.rsrc.py
 
33
</pre>
 
34
 
 
35
<p>The resource file has a .py extension because the resource file is actually
 
36
a valid Python dictionary and so it is easy to edit and validate
 
37
the resource file using a Python-aware editor. The files are plain text.
 
38
They are not in XML format since a separate program would be necessary to
 
39
validate the XML and I feel that XML is less human-readable than the
 
40
equivelant nested dictionary/list done using Python syntax.</p>
 
41
 
 
42
<p>For the most part, it is no longer necessary to edit resource files in a text 
 
43
editor, instead you can use the resourceEditor sample to change the layout 
 
44
and menus for a PythonCard application.</p>
 
45
 
 
46
<p>Note that once the resource file attributes are frozen we will likely switch 
 
47
to XML for the resource format to improve interop with other layout tools. [Since 
 
48
we're approaching a 1.0 release of PythonCard, I think this is unlikely, but I'll 
 
49
leave this comment in for the time being. - Kevin Altis]</p>
 
50
 
 
51
<p>Binary data necessary for an application such as images and sound files are 
 
52
stored separately. Images necessary for the application components are 
 
53
referenced via 'image' or 'file' attributes in the resource file.</p>
 
54
 
 
55
<p>It is possible to have a fairly short edit/run cycle by keeping the
 
56
layout of your app open in the <a href="../resource_editor_overview.html">resourceEditor</a> (layout editor) and the source code
 
57
open in the <a href="http://pythoncard.sourceforge.net/tools/codeEditor.html">codeEditor</a> or your favorite editor/IDE and then launching the app using the Run
 
58
command under the File menu or from the command-line or a directory browser 
 
59
(Explorer) as you make changes. If you have an error in your source that
 
60
prevents the app from running, you can use the "Run with interpreter" 
 
61
command and the interpreter will be left open showing you where the error
 
62
occurred in your source.</p>
 
63
 
 
64
<p>The organization of the resource file is defined by the spec classes in 
 
65
pom.py spec.py, widget.py, and each component module. When a
 
66
resource is read in (see res.py) it is validated against the specs, default
 
67
arguments are initialized and any undefined component types in the resource
 
68
will cause a runtime error. The resource dictionary is converted to an
 
69
object that supports dot notation automatically and most places in the
 
70
framework where a resource argument is used, it is valid to pass in a
 
71
dictionary instead.</p>
 
72
 
 
73
<p>The noresource sample shows an example of a PythonCard application that 
 
74
does not have a resource file. The noresource sample also shows an 
 
75
example of dynamic component creation when the app starts up.</p>
 
76
 
 
77
<hr>
 
 
b'| <a href="general_concepts_and_limitations.html">General Concepts and Limitations</a> '
 
 
b'| <a href="components.html">Components</a> '
 
 
b'| <a href="dialogs.html">Dialogs</a> '
 
 
b'| <a href="events_and_handlers.html">Events and Handlers</a> '
 
 
b'| <a href="menus.html">Menus</a> '
 
 
b'| <a href="resource_files.html">Resource Files</a> '
 
 
b'| <a href="runtime_tools.html">Runtime Tools</a> '
 
 
b'<hr>'
0
78
   <?php include "../footer.php" ?>
 
79
    <p>$Revision: 1.3 $ : $Author: kasplat $ : Last updated $Date: 2004/08/14 21:51:40 $</p>
 
80
</div> <!-- end of content -->
 
81
</body>
 
82
</html>