]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | wxPython README |
2 | --------------- | |
3 | ||
4 | Introduction | |
5 | ------------ | |
6 | The code in this subtree is a Python Extension Module that enables the | |
7 | use of wxWindows from the Python language. So what is Python? Go to | |
8 | http://www.python.org to learn more but in a nutshell, it's an | |
9 | extremly cool object oriented language. It's easier than Perl and | |
10 | nearly as powerful. It runs on more platforms than Java, and by some | |
11 | reports, is even faster than Java with a JIT compiler! | |
12 | ||
13 | So why would you wan to use wxPython over just C++ and wxWindows? | |
14 | Personally I prefer using Python for everything. I only use C++ when | |
15 | I absolutly have to eek more performance out of an algorithm, and even | |
16 | then I ususally code it as an extension module and leave the majority | |
17 | of the program in Python. Another good thing to use wxPython for is | |
18 | quick prototyping of your wxWindows apps. With C++ you have to | |
19 | continuously go though the edit-compile-link-run cycle, which can be | |
20 | quite time comsuming. With Python it is only an edit-run cycle. You | |
21 | can easily build an application in a few hours with Python that would | |
22 | normally take a few days with C++. Converting a wxPython app to a | |
23 | C++/wxWindows app should be a straight forward task. | |
24 | ||
25 | This extension module attempts to mirror the class heiarchy of | |
26 | wxWindows as closely as possble. This means that there is a wxFrame | |
27 | class in wxPython that looks, smells, tastes and acts almost the same | |
28 | as the wxFrame class in the C++ version. Unfortunatly, I wasn't able | |
29 | to match things exactly because of differences in the languages, but | |
30 | the differences should be easy to absorb because they are natural to | |
31 | Python. For example, some methods that return mutliple values via | |
32 | argument pointers in C++ will return a tuple of values in Python. | |
33 | These differences have not been documented yet so if something isn't | |
34 | working the same as described in the wxWindows documents the best | |
35 | thing to do is to scan through the wxPython sources. | |
36 | ||
37 | Currently this extension module is designed such that the entire | |
38 | application will be written in Python. I havn't tried it yet, but I | |
39 | am sure that attempting to embed wxPython in a C++ wxWindows | |
40 | application will cause problems. However there is a plan to support | |
41 | this in the future. | |
42 | ||
43 | ||
44 | ||
45 | Build Instructions | |
46 | ------------------ | |
47 | I used SWIG (http://www.swig.org) to create the source code for the | |
48 | extension module. This enabled me to only have to deal with a small | |
d279310d | 49 | amount of code and only have to bother with the exceptional issues. |
7bf85405 RD |
50 | SWIG takes care of the rest and generates all the repetative code for |
51 | me. You don't need SWIG to build the extension module as all the | |
52 | generated C++ code is included in the src directory. | |
53 | ||
54 | wxPython is organized as a Python package. This means that the | |
55 | directory containing the results of the build process should be a | |
56 | subdirectory of a directory on the PYTHONPATH. (And preferably should | |
57 | be named wxPython.) You can control where the bulid process will dump | |
58 | wxPython by setting the TARGETDIR makefile variable. The default is | |
59 | $(WXWIN)/utils/wxPython, where this README.txt is located. If you | |
60 | leave it here then you should add $(WXWIN)/utils to your PYTHONPATH. | |
61 | However, you may prefer to use something that is already on your | |
62 | PYTHONPATH, such as the site-packages directory on Unix systems. | |
63 | ||
64 | ||
65 | Win32 | |
66 | ----- | |
67 | ||
68 | 1. Build wxWindows with USE_RESOURCE_LOADING_IN_MSW set to 1 in | |
69 | include/wx/msw/setup.h so icons can be loaded dynamically. | |
70 | ||
71 | 2. Change into the $(WXWIN)/utils/wxPython/src directory. | |
72 | ||
73 | 3. Edit makefile.nt and specify where your python installation is at. | |
74 | You may also want to fiddle with the TARGETDIR variable as described | |
75 | above. | |
76 | ||
77 | 4. Run nmake -f makefile.nt | |
78 | ||
79 | 5. If it builds successfully, congratulations! Move on to the next | |
80 | step. If not then you can try mailing me for help. Also, I will | |
d279310d | 81 | always have a pre-built win32 version of this extension module at |
7bf85405 RD |
82 | http://starship.skyport.net/crew/robind/python. |
83 | ||
84 | 6. Change to the $(WXWIN)/utils/wxPython/tests directory. | |
85 | ||
86 | 7. Try executing the test programs. Note that some of these print | |
87 | diagnositc or test info to standard output, so they will require the | |
88 | console version of python. For example: | |
89 | ||
90 | python test1.py | |
91 | ||
92 | To run them without requiring a console, you can use the pythonw.exe | |
93 | version of Python either from the command line or from a shortcut. | |
94 | ||
95 | ||
96 | ||
97 | Unix | |
98 | ---- | |
99 | ||
100 | NOTE: I don't have wxPython working yet with wxGTK, so if you aren't | |
101 | using Win32 you can skip the rest of this file and check back in a | |
102 | week or so. | |
103 | ||
104 | ||
105 | 1. Change into the $(WXWIN)/utils/wxPython/src directory. | |
106 | ||
107 | 2. Edit Setup.in and ensure that the flags, directories, and toolkit | |
108 | options are correct. See the above commentary about TARGETDIR. | |
109 | ||
110 | 3. Run this command to generate a makefile: | |
111 | ||
112 | make -f Makefile.pre.in boot | |
113 | ||
114 | 4. Run these commands to build and then install the wxPython extension | |
115 | module: | |
116 | ||
117 | make | |
118 | make install | |
119 | ||
120 | ||
121 | 5. Change to the $(WXWIN)/utils/wxPython/tests directory. | |
122 | ||
123 | 6. Try executing the test programs. For example: | |
124 | ||
125 | python test1.py | |
126 | ||
127 | ||
128 | ||
129 | ------------------------ | |
130 | 8/8/1998 | |
131 | ||
132 | Robin Dunn | |
2d6dfbb7 | 133 | robin@alldunn.com |