lots'o' wxpython modules files
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3345 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
23
utils/wxPython/modules/html/BUGS
Normal file
23
utils/wxPython/modules/html/BUGS
Normal file
@@ -0,0 +1,23 @@
|
||||
Known bugs
|
||||
|
||||
html, all:
|
||||
- keys can move the vertical scrollbar, but the window moveth not.
|
||||
problem in wxHTML.
|
||||
|
||||
- widgets are not removed when the HTML contents is changed
|
||||
(this can be fixed by adding ~HtmlWidgetCell { wnd->Destroy(); } )
|
||||
|
||||
- potential problem with the use of ThreadState in html.i
|
||||
(mainly because I don't really know what I'm doing there)
|
||||
|
||||
html, msw:
|
||||
- vertical scrollbar behaves erratically when content smaller than
|
||||
window
|
||||
|
||||
- page with widgets takes forever to draw when constructed
|
||||
in frame constructor
|
||||
|
||||
- sometimes the python scripts with html crash on startup, before
|
||||
the window is displayed (illegal operation). this seems mainly to
|
||||
happen when the various libs are not yet in the disk cache. race
|
||||
condition?
|
363
utils/wxPython/modules/html/Makefile.pre.in
Normal file
363
utils/wxPython/modules/html/Makefile.pre.in
Normal file
@@ -0,0 +1,363 @@
|
||||
# Universal Unix Makefile for Python extensions
|
||||
# =============================================
|
||||
|
||||
# Short Instructions
|
||||
# ------------------
|
||||
|
||||
# 1. Build and install Python (1.5 or newer).
|
||||
# 2. "make -f Makefile.pre.in boot"
|
||||
# 3. "make"
|
||||
# You should now have a shared library.
|
||||
|
||||
# Long Instructions
|
||||
# -----------------
|
||||
|
||||
# Build *and install* the basic Python 1.5 distribution. See the
|
||||
# Python README for instructions. (This version of Makefile.pre.in
|
||||
# only withs with Python 1.5, alpha 3 or newer.)
|
||||
|
||||
# Create a file Setup.in for your extension. This file follows the
|
||||
# format of the Modules/Setup.in file; see the instructions there.
|
||||
# For a simple module called "spam" on file "spammodule.c", it can
|
||||
# contain a single line:
|
||||
# spam spammodule.c
|
||||
# You can build as many modules as you want in the same directory --
|
||||
# just have a separate line for each of them in the Setup.in file.
|
||||
|
||||
# If you want to build your extension as a shared library, insert a
|
||||
# line containing just the string
|
||||
# *shared*
|
||||
# at the top of your Setup.in file.
|
||||
|
||||
# Note that the build process copies Setup.in to Setup, and then works
|
||||
# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
|
||||
# while you're in the process of debugging your Setup.in file, you may
|
||||
# want to edit Setup instead, and copy it back to Setup.in later.
|
||||
# (All this is done so you can distribute your extension easily and
|
||||
# someone else can select the modules they actually want to build by
|
||||
# commenting out lines in the Setup file, without editing the
|
||||
# original. Editing Setup is also used to specify nonstandard
|
||||
# locations for include or library files.)
|
||||
|
||||
# Copy this file (Misc/Makefile.pre.in) to the directory containing
|
||||
# your extension.
|
||||
|
||||
# Run "make -f Makefile.pre.in boot". This creates Makefile
|
||||
# (producing Makefile.pre and sedscript as intermediate files) and
|
||||
# config.c, incorporating the values for sys.prefix, sys.exec_prefix
|
||||
# and sys.version from the installed Python binary. For this to work,
|
||||
# the python binary must be on your path. If this fails, try
|
||||
# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
|
||||
# where <prefix> is the prefix used to install Python for installdir
|
||||
# (and possibly similar for exec_installdir=<exec_prefix>).
|
||||
|
||||
# Note: "make boot" implies "make clobber" -- it assumes that when you
|
||||
# bootstrap you may have changed platforms so it removes all previous
|
||||
# output files.
|
||||
|
||||
# If you are building your extension as a shared library (your
|
||||
# Setup.in file starts with *shared*), run "make" or "make sharedmods"
|
||||
# to build the shared library files. If you are building a statically
|
||||
# linked Python binary (the only solution of your platform doesn't
|
||||
# support shared libraries, and sometimes handy if you want to
|
||||
# distribute or install the resulting Python binary), run "make
|
||||
# python".
|
||||
|
||||
# Note: Each time you edit Makefile.pre.in or Setup, you must run
|
||||
# "make Makefile" before running "make".
|
||||
|
||||
# Hint: if you want to use VPATH, you can start in an empty
|
||||
# subdirectory and say (e.g.):
|
||||
# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
|
||||
|
||||
|
||||
# === Bootstrap variables (edited through "make boot") ===
|
||||
|
||||
# The prefix used by "make inclinstall libainstall" of core python
|
||||
installdir= /usr/local
|
||||
|
||||
# The exec_prefix used by the same
|
||||
exec_installdir=$(installdir)
|
||||
|
||||
# Source directory and VPATH in case you want to use VPATH.
|
||||
# (You will have to edit these two lines yourself -- there is no
|
||||
# automatic support as the Makefile is not generated by
|
||||
# config.status.)
|
||||
srcdir= .
|
||||
VPATH= .
|
||||
|
||||
# === Variables that you may want to customize (rarely) ===
|
||||
|
||||
# (Static) build target
|
||||
TARGET= python
|
||||
|
||||
# Installed python binary (used only by boot target)
|
||||
PYTHON= python
|
||||
|
||||
# Add more -I and -D options here
|
||||
CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
|
||||
|
||||
# These two variables can be set in Setup to merge extensions.
|
||||
# See example[23].
|
||||
BASELIB=
|
||||
BASESETUP=
|
||||
|
||||
# === Variables set by makesetup ===
|
||||
|
||||
MODOBJS= _MODOBJS_
|
||||
MODLIBS= _MODLIBS_
|
||||
|
||||
# === Definitions added by makesetup ===
|
||||
|
||||
# === Variables from configure (through sedscript) ===
|
||||
|
||||
VERSION= @VERSION@
|
||||
CC= @CC@
|
||||
LINKCC= @LINKCC@
|
||||
SGI_ABI= @SGI_ABI@
|
||||
OPT= @OPT@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LDLAST= @LDLAST@
|
||||
DEFS= @DEFS@
|
||||
LIBS= @LIBS@
|
||||
LIBM= @LIBM@
|
||||
LIBC= @LIBC@
|
||||
RANLIB= @RANLIB@
|
||||
MACHDEP= @MACHDEP@
|
||||
SO= @SO@
|
||||
LDSHARED= @LDSHARED@
|
||||
CCSHARED= @CCSHARED@
|
||||
LINKFORSHARED= @LINKFORSHARED@
|
||||
#@SET_CCC@
|
||||
|
||||
# Install prefix for architecture-independent files
|
||||
prefix= /usr/local
|
||||
|
||||
# Install prefix for architecture-dependent files
|
||||
exec_prefix= $(prefix)
|
||||
|
||||
# === Fixed definitions ===
|
||||
|
||||
# Shell used by make (some versions default to the login shell, which is bad)
|
||||
SHELL= /bin/sh
|
||||
|
||||
# Expanded directories
|
||||
BINDIR= $(exec_installdir)/bin
|
||||
LIBDIR= $(exec_prefix)/lib
|
||||
MANDIR= $(installdir)/man
|
||||
INCLUDEDIR= $(installdir)/include
|
||||
SCRIPTDIR= $(prefix)/lib
|
||||
|
||||
# Detailed destination directories
|
||||
BINLIBDEST= $(LIBDIR)/python$(VERSION)
|
||||
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
|
||||
INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
|
||||
EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
|
||||
LIBP= $(exec_installdir)/lib/python$(VERSION)
|
||||
DESTSHARED= $(BINLIBDEST)/site-packages
|
||||
|
||||
LIBPL= $(LIBP)/config
|
||||
|
||||
PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
|
||||
|
||||
MAKESETUP= $(LIBPL)/makesetup
|
||||
MAKEFILE= $(LIBPL)/Makefile
|
||||
CONFIGC= $(LIBPL)/config.c
|
||||
CONFIGCIN= $(LIBPL)/config.c.in
|
||||
SETUP= $(LIBPL)/Setup
|
||||
|
||||
SYSLIBS= $(LIBM) $(LIBC)
|
||||
|
||||
ADDOBJS= $(LIBPL)/python.o config.o
|
||||
|
||||
# Portable install script (configure doesn't always guess right)
|
||||
INSTALL= $(LIBPL)/install-sh -c
|
||||
# Shared libraries must be installed with executable mode on some systems;
|
||||
# rather than figuring out exactly which, we always give them executable mode.
|
||||
# Also, making them read-only seems to be a good idea...
|
||||
INSTALL_SHARED= ${INSTALL} -m 555
|
||||
|
||||
#---------------------------------------------------
|
||||
# Possibly change some definintions for C++
|
||||
ifdef MY_LDSHARED
|
||||
LDSHARED=$(MY_LDSHARED)
|
||||
endif
|
||||
ifdef MY_LINKCC
|
||||
LINKCC=$(MY_LINKCC)
|
||||
endif
|
||||
|
||||
|
||||
# === Fixed rules ===
|
||||
|
||||
# Default target. This builds shared libraries only
|
||||
default: sharedmods
|
||||
|
||||
# Build everything
|
||||
all: static sharedmods
|
||||
|
||||
# Build shared libraries from our extension modules
|
||||
sharedmods: $(SHAREDMODS)
|
||||
|
||||
# Build a static Python binary containing our extension modules
|
||||
static: $(TARGET)
|
||||
$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
|
||||
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
|
||||
$(ADDOBJS) lib.a $(PYTHONLIBS) \
|
||||
$(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
|
||||
-o $(TARGET) $(LDLAST)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# This is a default version of the install target for wxPython. It just
|
||||
# redirects to wxInstall below...
|
||||
|
||||
install: wxInstall
|
||||
|
||||
#install: sharedmods
|
||||
# if test ! -d $(DESTSHARED) ; then \
|
||||
# mkdir $(DESTSHARED) ; else true ; fi
|
||||
# -for i in X $(SHAREDMODS); do \
|
||||
# if test $$i != X; \
|
||||
# then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
|
||||
# fi; \
|
||||
# done
|
||||
|
||||
|
||||
# Build the library containing our extension modules
|
||||
lib.a: $(MODOBJS)
|
||||
-rm -f lib.a
|
||||
ar cr lib.a $(MODOBJS)
|
||||
-$(RANLIB) lib.a
|
||||
|
||||
# This runs makesetup *twice* to use the BASESETUP definition from Setup
|
||||
config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
$(MAKE) -f Makefile do-it-again
|
||||
|
||||
# Internal target to run makesetup for the second time
|
||||
do-it-again:
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
|
||||
# Make config.o from the config.c created by makesetup
|
||||
config.o: config.c
|
||||
$(CC) $(CFLAGS) -c config.c
|
||||
|
||||
# Setup is copied from Setup.in *only* if it doesn't yet exist
|
||||
Setup:
|
||||
cp Setup.in Setup
|
||||
|
||||
# Make the intermediate Makefile.pre from Makefile.pre.in
|
||||
Makefile.pre: Makefile.pre.in sedscript
|
||||
sed -f sedscript Makefile.pre.in >Makefile.pre
|
||||
|
||||
# Shortcuts to make the sed arguments on one line
|
||||
P=prefix
|
||||
E=exec_prefix
|
||||
H=Generated automatically from Makefile.pre.in by sedscript.
|
||||
L=LINKFORSHARED
|
||||
|
||||
# Make the sed script used to create Makefile.pre from Makefile.pre.in
|
||||
sedscript: $(MAKEFILE)
|
||||
sed -n \
|
||||
-e '1s/.*/1i\\/p' \
|
||||
-e '2s%.*%# $H%p' \
|
||||
-e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
|
||||
-e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
|
||||
-e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
|
||||
-e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
|
||||
-e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
|
||||
-e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
|
||||
-e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
|
||||
-e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
|
||||
-e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
|
||||
-e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
|
||||
-e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
|
||||
-e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
|
||||
-e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
|
||||
-e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
|
||||
-e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
|
||||
-e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
|
||||
-e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
|
||||
-e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
|
||||
$(MAKEFILE) >sedscript
|
||||
echo "/^#@SET_CCC@/d" >>sedscript
|
||||
echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
|
||||
echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
|
||||
echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
|
||||
echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
|
||||
echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
|
||||
echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
|
||||
echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
|
||||
|
||||
# Bootstrap target
|
||||
boot: clobber
|
||||
VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
|
||||
installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
|
||||
exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
|
||||
$(MAKE) -f Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
|
||||
VERSION=$$VERSION \
|
||||
installdir=$$installdir \
|
||||
exec_installdir=$$exec_installdir \
|
||||
Makefile
|
||||
|
||||
# Handy target to remove intermediate files and backups
|
||||
clean:
|
||||
-rm -f *.o *~
|
||||
|
||||
# Handy target to remove everything that is easily regenerated
|
||||
clobber: clean
|
||||
-rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
|
||||
-rm -f *.so *.sl so_locations
|
||||
|
||||
|
||||
# Handy target to remove everything you don't want to distribute
|
||||
distclean: clobber
|
||||
-rm -f Makefile Setup
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# Custom rules and dependencies added for wxPython
|
||||
#
|
||||
|
||||
WXP_VERSION=2.1b2
|
||||
|
||||
# WXP_SRCDIR=../wxPython/src
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -I$(WXP_SRCDIR) -D__WXGTK__ $(SEPARATE)
|
||||
|
||||
|
||||
# Implicit rules to run SWIG
|
||||
$(GENCODEDIR)/%.cpp : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
|
||||
rm $(GENCODEDIR)/tmp_wrap.cpp
|
||||
|
||||
|
||||
wxInstall : sharedmods $(PYMODULES)
|
||||
if test ! -d $(TARGETDIR) ; then \
|
||||
mkdir $(TARGETDIR) ; else true ; fi
|
||||
if [ "$(SHAREDMODS)" != "" ]; then \
|
||||
chmod 755 $(SHAREDMODS); \
|
||||
cp $(SHAREDMODS) $(TARGETDIR); fi
|
||||
-for i in $(PYMODULES); do \
|
||||
cp $$i $(TARGETDIR); \
|
||||
done
|
||||
if [ "$(TARGETDIR)" != ".." ]; then \
|
||||
python $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
else \
|
||||
python $(LIBDEST)/compileall.py -l $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py -l $(TARGETDIR);\
|
||||
fi
|
||||
|
||||
|
||||
|
11
utils/wxPython/modules/html/README
Normal file
11
utils/wxPython/modules/html/README
Normal file
@@ -0,0 +1,11 @@
|
||||
Aug. 2 1999 Harm van der Heijden
|
||||
|
||||
What's in here:
|
||||
|
||||
html
|
||||
-- minimal wrap of Vaclaf Slavik's wxHTML (now part of
|
||||
wxWindows); only parts of the wxHtmlWindow class are used.
|
||||
Testsample htmlview.py.
|
||||
There's also a python tag handler, see htmlwidget.py for
|
||||
a demonstration.
|
||||
|
45
utils/wxPython/modules/html/Setup.in
Normal file
45
utils/wxPython/modules/html/Setup.in
Normal file
@@ -0,0 +1,45 @@
|
||||
## This file gives the details of what is needed to build this extension
|
||||
## module so the Makefile can be created.
|
||||
|
||||
## If you have not done "make install" for wxWindows then see Setup.in.linux
|
||||
## for a more verbose version of this file.
|
||||
|
||||
*shared*
|
||||
|
||||
CCC=c++
|
||||
WXWIN=../../..
|
||||
GENCODEDIR=gtk
|
||||
# srcdir=$(GENCODEDIR)
|
||||
WX_CONFIG_CFLAGS=`wx-config --cflags`
|
||||
WX_CONFIG_LIBS=`wx-config --libs`
|
||||
|
||||
|
||||
## Depending on how your Python was built, you may have to set this
|
||||
## value to use the C++ driver to link with instead of the default
|
||||
## C driver. For example:
|
||||
MY_LDSHARED=$(CCC) -shared
|
||||
|
||||
## Same as above, but for statically linking Python and wxPython together,
|
||||
## in other words, if you comment out the *shared* above. If this is the
|
||||
## case then you should ensure that the main() function is Python's, not
|
||||
## wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
## to force this...
|
||||
MY_LINKCC=$(CCC)
|
||||
|
||||
|
||||
## Pick one of these, or set your own. This is where the wxPython module
|
||||
## should be installed. It should be a subdirectory named wxPython.
|
||||
#TARGETDIR=..
|
||||
TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
|
||||
# The location of the wxPython source dir
|
||||
WXP_SRCDIR=../../src
|
||||
|
||||
C_DEFINES = -DSWIG_GLOBAL -DWXP_USE_THREAD -DSEPARATE
|
||||
C_FLAGS = -I. -I$(WXP_SRCDIR) $(WX_CONFIG_CFLAGS)
|
||||
C_LIBS = -lwxPyHelpers $(WX_CONFIG_LIBS)
|
||||
|
||||
PYMODULES = $(GENCODEDIR)/html.py htmlhelper.py
|
||||
|
||||
htmlc $(GENCODEDIR)/html.cpp \
|
||||
$(C_DEFINES) $(C_FLAGS) -Xlinker $(C_LIBS)
|
259
utils/wxPython/modules/html/html.i
Normal file
259
utils/wxPython/modules/html/html.i
Normal file
@@ -0,0 +1,259 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: html.i
|
||||
// Purpose: SWIG definitions of html classes
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 25-nov-1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%module html
|
||||
|
||||
%{
|
||||
#include "helpers.h"
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/fs_zip.h>
|
||||
#include <wx/fs_inet.h>
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
%extern wx.i
|
||||
%extern windows.i
|
||||
%extern _defs.i
|
||||
%extern events.i
|
||||
//%extern windows2.i
|
||||
//%extern windows3.i
|
||||
//%extern frames.i
|
||||
//%extern misc.i
|
||||
//%extern gdi.i
|
||||
//%extern controls.i
|
||||
|
||||
|
||||
%{
|
||||
#ifdef __WXMSW__
|
||||
static wxString wxPyEmptyStr("");
|
||||
static wxPoint wxPyDefaultPosition(wxDefaultPosition);
|
||||
static wxSize wxPyDefaultSize(wxDefaultSize);
|
||||
#endif
|
||||
static PyThreadState* wxPyThreadState;
|
||||
%}
|
||||
|
||||
%pragma(python) code = "import wx,htmlhelper"
|
||||
%pragma(python) code = "widget = htmlc"
|
||||
|
||||
%{
|
||||
|
||||
static PyObject* mod_dict = NULL; // will be set by init
|
||||
|
||||
#include <wx/html/mod_templ.h>
|
||||
|
||||
TAG_HANDLER_BEGIN(PYTHONTAG, "PYTHON")
|
||||
TAG_HANDLER_PROC(tag)
|
||||
{
|
||||
wxWindow *wnd;
|
||||
wxString errmsg;
|
||||
char pbuf[256];
|
||||
|
||||
int fl = 0;
|
||||
|
||||
while (1) {
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(wxPyThreadState);
|
||||
#endif
|
||||
if (tag.HasParam("FLOAT"))
|
||||
tag.ScanParam("FLOAT", "%i", &fl);
|
||||
PyObject* pyfunc = PyDict_GetItemString(mod_dict, "WidgetStarter");
|
||||
if (pyfunc == NULL) {
|
||||
errmsg = "Could not find object WidgetStarter";
|
||||
break;
|
||||
}
|
||||
if (! PyCallable_Check(pyfunc)) {
|
||||
errmsg = "WidgetStarter does not appear to be callable";
|
||||
break;
|
||||
}
|
||||
SWIG_MakePtr(pbuf, m_WParser->GetWindow(), "_wxHtmlWindow_p");
|
||||
PyObject* arglist = Py_BuildValue("(s,s)", pbuf,
|
||||
(const char*)tag.GetAllParams());
|
||||
if (! arglist) {
|
||||
errmsg = "Failed making argument list";
|
||||
break;
|
||||
}
|
||||
PyObject* ret = PyEval_CallObject(pyfunc, arglist);
|
||||
Py_DECREF(arglist);
|
||||
if (ret == NULL) {
|
||||
errmsg = "An error occured while calling WidgetStarter";
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
break;
|
||||
}
|
||||
wnd = NULL;
|
||||
if (PyString_Check(ret)) {
|
||||
char* thisc = PyString_AsString(ret);
|
||||
SWIG_GetPtr(thisc, (void**)&wnd, "_wxWindow_p");
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
if (! wnd) {
|
||||
errmsg = "Could not make a wxWindow pointer from return ptr";
|
||||
break;
|
||||
}
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
wnd -> Show(TRUE);
|
||||
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, fl));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* we got out of the loop. Must be an error. Show a box stating it. */
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
|
||||
wnd = new wxTextCtrl( m_WParser -> GetWindow(), -1,
|
||||
errmsg, wxPoint(0,0),
|
||||
wxSize(300, 100), wxTE_MULTILINE );
|
||||
wnd -> Show(TRUE);
|
||||
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, 100));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TAG_HANDLER_END(PYTHONTAG)
|
||||
|
||||
TAGS_MODULE_BEGIN(PythonTag)
|
||||
|
||||
TAGS_MODULE_ADD(PYTHONTAG)
|
||||
|
||||
TAGS_MODULE_END(PythonTag)
|
||||
|
||||
// Note: see also the init function where we add the module!
|
||||
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// item of history list
|
||||
class HtmlHistoryItem
|
||||
{
|
||||
public:
|
||||
HtmlHistoryItem(const char* p, const char* a);
|
||||
int GetPos() const {return m_Pos;}
|
||||
void SetPos(int p) {m_Pos = p;}
|
||||
const wxString& GetPage() const ;
|
||||
const wxString& GetAnchor() const ;
|
||||
};
|
||||
|
||||
class wxHtmlWindow : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxPyDefaultPosition,
|
||||
const wxSize& size = wxPyDefaultSize,
|
||||
int flags=wxHW_SCROLLBAR_AUTO,
|
||||
const char* name = "htmlWindow");
|
||||
%pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
|
||||
%pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
|
||||
|
||||
bool SetPage(const char* source);
|
||||
// Set HTML page and display it. !! source is HTML document itself,
|
||||
// it is NOT address/filename of HTML document. If you want to
|
||||
// specify document location, use LoadPage() istead
|
||||
// Return value : FALSE if an error occured, TRUE otherwise
|
||||
|
||||
bool LoadPage(const char* location);
|
||||
// Load HTML page from given location. Location can be either
|
||||
// a) /usr/wxGTK2/docs/html/wx.htm
|
||||
// b) http://www.somewhere.uk/document.htm
|
||||
// c) ftp://ftp.somesite.cz/pub/something.htm
|
||||
// In case there is no prefix (http:,ftp:), the method
|
||||
// will try to find it itself (1. local file, then http or ftp)
|
||||
// After the page is loaded, the method calls SetPage() to display it.
|
||||
// Note : you can also use path relative to previously loaded page
|
||||
// Return value : same as SetPage
|
||||
|
||||
wxString GetOpenedPage() const {return m_OpenedPage;}
|
||||
// Returns full location of opened page
|
||||
|
||||
void SetRelatedFrame(wxFrame* frame, const char* format);
|
||||
// sets frame in which page title will be displayed. Format is format of
|
||||
// frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
|
||||
wxFrame* GetRelatedFrame() const;
|
||||
|
||||
void SetRelatedStatusBar(int bar);
|
||||
// after(!) calling SetRelatedFrame, this sets statusbar slot where messages
|
||||
// will be displayed. Default is -1 = no messages.
|
||||
|
||||
void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes);
|
||||
// sets fonts to be used when displaying HTML page.
|
||||
// *_italic_mode can be either wxSLANT or wxITALIC
|
||||
|
||||
void SetTitle(const char* title);
|
||||
// Sets the title of the window
|
||||
// (depending on the information passed to SetRelatedFrame() method)
|
||||
|
||||
void SetBorders(int b);
|
||||
// Sets space between text and window borders.
|
||||
|
||||
//virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||
// saves custom settings into cfg config. it will use the path 'path'
|
||||
// if given, otherwise it will save info into currently selected path.
|
||||
// saved values : things set by SetFonts, SetBorders.
|
||||
//virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||
// ...
|
||||
|
||||
bool HistoryBack();
|
||||
bool HistoryForward();
|
||||
// Goes to previous/next page (in browsing history)
|
||||
// Returns TRUE if successful, FALSE otherwise
|
||||
void HistoryClear();
|
||||
// Resets history
|
||||
|
||||
//wxHtmlContainerCell* GetInternalRepresentation() const;
|
||||
// Returns pointer to conteiners/cells structure.
|
||||
// It should be used ONLY when printing
|
||||
|
||||
//static void AddFilter(wxHtmlFilter *filter);
|
||||
// Adds input filter
|
||||
|
||||
/* This function needs to be eventified! */
|
||||
//virtual void OnLinkClicked(const char* link);
|
||||
// called when users clicked on hypertext link. Default behavior is to
|
||||
// call LoadPage(loc)
|
||||
|
||||
//static void CleanUpStatics();
|
||||
// cleans static variables
|
||||
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%init %{
|
||||
|
||||
/* This is a bit cheesy. SWIG happens to call the dictionary d...
|
||||
* I save it here, 'cause I don't know how to get it back later! */
|
||||
mod_dict = d;
|
||||
wxPyThreadState = PyThreadState_Get();
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
/* specifically add our python tag handler; it doesn't seem to
|
||||
* happen by itself... */
|
||||
wxHtmlWinParser::AddModule(new HTML_ModulePythonTag());
|
||||
|
||||
// Until wxFileSystem is wrapped...
|
||||
#if wxUSE_FS_ZIP
|
||||
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||
#endif
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
2
utils/wxPython/modules/html/htmlc.def
Normal file
2
utils/wxPython/modules/html/htmlc.def
Normal file
@@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
inithtmlc
|
59
utils/wxPython/modules/html/htmlhelper.py
Normal file
59
utils/wxPython/modules/html/htmlhelper.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# htmlhelper.py
|
||||
#
|
||||
# A few helper functions for putting wxPython widgets in html pages
|
||||
#
|
||||
# Harm van der Heijden, 11 aug 1999.
|
||||
|
||||
import wx
|
||||
import string
|
||||
import htmlc
|
||||
|
||||
# Function to parse a param string (of the form 'item=value item2="value etc"'
|
||||
# and creates a dictionary
|
||||
def _param2dict(param):
|
||||
i = 0; j = 0; s = len(param); d = {}
|
||||
d['param_str'] = param
|
||||
while 1:
|
||||
while i<s and param[i] == " " : i = i+1
|
||||
if i>=s: break
|
||||
j = i
|
||||
while j<s and param[j] != "=": j=j+1
|
||||
if j+1>=s:
|
||||
break
|
||||
word = param[i:j]
|
||||
i=j+1
|
||||
if (param[i] == '"'):
|
||||
j=i+1
|
||||
while j<s and param[j] != '"' : j=j+1
|
||||
if j == s: break
|
||||
val = param[i+1:j]
|
||||
elif (param[i] != " "):
|
||||
j=i+1
|
||||
while j<s and param[j] != " " : j=j+1
|
||||
val = param[i:j]
|
||||
else:
|
||||
val = ""
|
||||
i=j+1
|
||||
d[string.lower(word)] = val
|
||||
return d
|
||||
|
||||
# This function gets called by the <python> tag handler.
|
||||
# Arguments are the parent (wxHtmlWindow) SWIG pointer (in python, a string)
|
||||
# and a string containing the parameters.
|
||||
# The return value must be the SWIG pointer of the created widget (the 'this'
|
||||
# attribute in python). The widget must be derived from a wxWindow or one
|
||||
# of its descendants.
|
||||
def _WidgetStarter(parentptr, param):
|
||||
# create a python instance of the parent
|
||||
parent = wx.wxWindowPtr(parentptr)
|
||||
# try to find the widget class in the htmlwinc (=htmlwidget) module
|
||||
dict = _param2dict(param)
|
||||
classname = dict['class']
|
||||
obj = htmlc.__dict__[classname]
|
||||
# now create the class with arguments parent, dictionary
|
||||
cls = apply(obj, (parent, dict))
|
||||
# return the class instance's pointer
|
||||
return cls.this
|
||||
|
||||
htmlc.WidgetStarter = _WidgetStarter
|
35
utils/wxPython/modules/html/makefile.vc
Normal file
35
utils/wxPython/modules/html/makefile.vc
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
TARGET = htmlc
|
||||
|
||||
OBJECTS = html.obj
|
||||
|
||||
PYMODULES = $(TARGETDIR)\html.py $(TARGETDIR)\htmlhelper.py
|
||||
|
||||
SOURCES = $(GENCODEDIR)\html.cpp
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
!include ..\makeinc.vc
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
default: $(TARGETDIR)\$(TARGET).pyd pycfiles
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
$(TARGETDIR)\$(TARGET).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) # $(TARGET).res
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS) /def:$(TARGET).def /implib:./$(TARGET).lib
|
||||
$(DUMMYOBJ) $(OBJECTS)
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
77
utils/wxPython/modules/html/test/htmlview.py
Normal file
77
utils/wxPython/modules/html/test/htmlview.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
import sys
|
||||
|
||||
default_page = """
|
||||
<H1>HTML Viewer</H1>Please select <I>File->Open</I>
|
||||
to open a HTML file, or edit this page in the
|
||||
text control below and select <I>File->Update</I>
|
||||
<P>
|
||||
The python source can be seen
|
||||
<a href="%s">here</a>.
|
||||
""" % (sys.argv[0], )
|
||||
|
||||
class HtmlViewer(wxFrame):
|
||||
def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
|
||||
wxFrame.__init__(self, parent, id, title, pos, size)
|
||||
self.CreateStatusBar(1)
|
||||
split = wxSplitterWindow(self, -1)
|
||||
self.html = wxHtmlWindow(split)
|
||||
self.html.SetRelatedFrame(self, "HTML Viewer: \%s")
|
||||
self.html.SetRelatedStatusBar(0)
|
||||
self.txt = wxTextCtrl(split, -1, default_page,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE)
|
||||
split.SplitHorizontally(self.html, self.txt, size.y/2)
|
||||
mbar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(1500, "Open")
|
||||
menu.Append(1501, "Reset")
|
||||
menu.Append(1502, "Update HTML")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1503, "Exit")
|
||||
mbar.Append(menu, "File")
|
||||
menu = wxMenu()
|
||||
menu.Append(1510, "Back")
|
||||
menu.Append(1511, "Forward")
|
||||
mbar.Append(menu, "Go")
|
||||
self.SetMenuBar(mbar)
|
||||
self.filename = ""
|
||||
EVT_MENU(self, 1500, self.OnFileOpen)
|
||||
EVT_MENU(self, 1501, self.OnFileReset)
|
||||
EVT_MENU(self, 1502, self.OnFileUpdate)
|
||||
EVT_MENU(self, 1503, self.OnClose)
|
||||
EVT_MENU(self, 1510, self.OnGoBack)
|
||||
EVT_MENU(self, 1511, self.OnGoForward)
|
||||
# A default opening text
|
||||
self.html.SetPage( default_page )
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxFileDialog(NULL, "Open file")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.filename = dlg.GetPath()
|
||||
self.html.LoadPage(self.filename)
|
||||
def OnFileReset(self, event):
|
||||
self.html.SetPage( default_page )
|
||||
self.txt.SetValue( default_page )
|
||||
def OnFileUpdate(self, event):
|
||||
self.html.SetPage( self.txt.GetValue() )
|
||||
def OnGoBack(self, event):
|
||||
self.html.HistoryBack()
|
||||
def OnGoForward(self, event):
|
||||
self.html.HistoryForward()
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = HtmlViewer(NULL, -1, "HTML Viewer")
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
|
||||
theApp = MyApp(0)
|
||||
theApp.MainLoop()
|
97
utils/wxPython/modules/html/test/htmlwidget.py
Normal file
97
utils/wxPython/modules/html/test/htmlwidget.py
Normal file
@@ -0,0 +1,97 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
import sys,string
|
||||
|
||||
# A bunch of simple widgets, all somehow derived from wxWindow
|
||||
class Widget1(wxWindow):
|
||||
def __init__(self, parent, param):
|
||||
wxWindow.__init__(self, parent, -1)
|
||||
self.text = wxTextCtrl(self, -1, param['param_str'], wxPoint(5,5),
|
||||
wxSize(200,150), wxTE_MULTILINE)
|
||||
but = wxButton(self, 1001, "Click me", wxPoint(50,160), wxSize(100,30))
|
||||
EVT_BUTTON(self, 1001, self.OnButton)
|
||||
self.SetSize(wxSize(210,200))
|
||||
def OnButton(self, event):
|
||||
self.text.AppendText( "Click!\n" )
|
||||
|
||||
class Widget2(wxButton):
|
||||
def __init__(self, parent, param):
|
||||
wxButton.__init__(self, parent, int(param['id']), param['title'])
|
||||
|
||||
class Widget3(wxTextCtrl):
|
||||
def __init__(self, parent, param):
|
||||
wxTextCtrl.__init__(self, parent, -1, "No clicks")
|
||||
self.clicked = 0;
|
||||
EVT_BUTTON(parent, int(param['button_id']), self.OnButton)
|
||||
def OnButton(self, event):
|
||||
self.clicked = self.clicked + 1
|
||||
self.SetValue("%d clicks" % (self.clicked,))
|
||||
|
||||
# make the widgets known in the widget module (aka htmlc)
|
||||
widget.Widget1 = Widget1
|
||||
widget.Widget2 = Widget2
|
||||
widget.Widget3 = Widget3
|
||||
|
||||
# our default page
|
||||
default_page = """
|
||||
<H2>wxPython widgets go HTML</H2>
|
||||
A bunch of wxPython widgets are scattered on this HTML page.
|
||||
Here's one:
|
||||
<center><python class="Widget1" greeting="Hello World"></center>
|
||||
<hr>
|
||||
Here's another:
|
||||
<center><python class="Widget2" float=70 id=1002 title="Button A"></center>
|
||||
It should always take up 70% of the page width.
|
||||
<p>And then there's this, listening to button A:
|
||||
<python class="Widget3" button_id=1002></p>
|
||||
"""
|
||||
|
||||
# our explanation
|
||||
apology = """
|
||||
For some bizarre reason, it takes forever and a day to display the
|
||||
widgets if they are constructed in the frame's constructor. This
|
||||
only happens in MSW, wxGTK works fine.
|
||||
<p>Select <I>File->Show it</I> to draw the widgets."""
|
||||
|
||||
default_page = default_page + "The HTML code for this page is\n <pre>" + default_page + "</pre>"
|
||||
|
||||
|
||||
class HtmlViewer(wxFrame):
|
||||
def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
|
||||
wxFrame.__init__(self, parent, id, title, pos, size)
|
||||
self.CreateStatusBar(1)
|
||||
self.html = wxHtmlWindow(self)
|
||||
self.html.SetRelatedFrame(self, "HTML Viewer: \%s")
|
||||
self.html.SetRelatedStatusBar(0)
|
||||
mbar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(1500, "Show it")
|
||||
menu.Append(1503, "Exit")
|
||||
mbar.Append(menu, "File")
|
||||
EVT_MENU(self, 1500, self.OnShowIt)
|
||||
EVT_MENU(self, 1503, self.OnClose)
|
||||
self.SetMenuBar(mbar)
|
||||
# change apology below to default_page, if you dare!
|
||||
self.html.SetPage( default_page )
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
def OnShowIt(self,event):
|
||||
self.html.SetPage( default_page )
|
||||
# now quickly remove the menu option, to hide that
|
||||
# other bug; namely that widgets aren't removed when the
|
||||
# HTML page is.
|
||||
self.GetMenuBar().Enable(1500, FALSE)
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = HtmlViewer(NULL, -1, "HTML Viewer")
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
|
||||
theApp = MyApp(0)
|
||||
theApp.MainLoop()
|
Reference in New Issue
Block a user