Gobs and gobs of changes, and tons of progress made. Can now create a wx.App, show a wx.Frame, run the MainLoop, bind event handlers and dispatch the events to the handler! YeeHa!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@66393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2010-12-17 08:08:24 +00:00
parent 044a2f2ed1
commit 212f1ff9f0
45 changed files with 1896 additions and 546 deletions

17
b Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
##set -o xtrace
PYVER=2.6
PYVER2=26
if [ "$OSTYPE" = "cygwin" ]; then
$TOOLS/python$PYVER2/python.exe -u build.py "$@"
else
PATH=/usr/local/bin:$PATH
PYTHON=`which python$PYVER`
$PYTHON -u build.py "$@"
fi
exit $?

249
build.py
View File

@@ -10,6 +10,7 @@ import sys
import os import os
import re import re
import glob import glob
import shutil
import subprocess import subprocess
import optparse import optparse
@@ -26,7 +27,11 @@ version2 = "%d.%d" % (version.VER_MAJOR, version.VER_MINOR)
version3 = "%d.%d.%d" % (version.VER_MAJOR, version.VER_MINOR, version.VER_RELEASE) version3 = "%d.%d.%d" % (version.VER_MAJOR, version.VER_MINOR, version.VER_RELEASE)
version2_nodot = version2.replace(".", "") version2_nodot = version2.replace(".", "")
version3_nodot = version3.replace(".", "") version3_nodot = version3.replace(".", "")
unstable_series = (version.VER_MINOR % 2) == 1 # is the minor version odd or even
isWindows = sys.platform.startswith('win')
isDarwin = sys.platform == "darwin"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def usage(): def usage():
@@ -34,23 +39,24 @@ def usage():
Usage: ./build.py [command(s)] [options] Usage: ./build.py [command(s)] [options]
Commands: Commands:
N.N NN Major.Minor version number of the Python to use to run N.N NN Major.Minor version number of the Python to use to run
the other commands. Default is 2.6 the other commands. Default is 2.6
dox Run Doxygen to produce the XML file used by ETG scripts dox Run Doxygen to produce the XML file used by ETG scripts
doxhtml Run Doxygen to create the HTML documetation for wx doxhtml Run Doxygen to create the HTML documetation for wx
touch 'touch' the etg files so they will all get run in the touch 'touch' the etg files so they will all get run in the
next build next build
etg Run the ETG scripts that are out of date to update their etg Run the ETG scripts that are out of date to update their
SIP files SIP files
test Run the unit test suite sip Run sip
test Run the unit test suite
build_wx Do the wxWidgets part of the build build_wx Do the wxWidgets part of the build
build_py Build wxPython only build_py Build wxPython only
build Builds both wxWidgets and wxPython. build Build both wxWidgets and wxPython.
clean_wx clean_wx Clean the wx parts of the build
clean_py clean_py Clean the wxPython parts of the build
cleanall cleanall Clean both wx and wxPython, and a little extra scrubbing
""" """
parser = makeOptionParser() parser = makeOptionParser()
parser.print_help() parser.print_help()
@@ -74,7 +80,7 @@ def main(args):
while commands: while commands:
cmd = commands[0] cmd = commands[0]
commands = commands[1:] commands = commands[1:]
if cmd in ['dox', 'doxhtml', 'etg', 'touch', 'test', if cmd in ['dox', 'doxhtml', 'etg', 'sip', 'touch', 'test',
'build_wx', 'build_py', 'build', 'build_wx', 'build_py', 'build',
'clean_wx', 'clean_py', 'cleanall']: 'clean_wx', 'clean_py', 'cleanall']:
function = globals()[cmd] function = globals()[cmd]
@@ -115,10 +121,6 @@ def runcmd(cmd, getOutput=False, echoCmd=True):
def setPythonVersion(args): def setPythonVersion(args):
# TODO: Should we default to the python that is running this script if a
# version was not given? Probably YES on Windows, but only if TOOLS is not
# set in the environment.
# TODO: Should we have a --option for specifying the path to the python # TODO: Should we have a --option for specifying the path to the python
# executable that should be used? # executable that should be used?
@@ -138,28 +140,48 @@ def setPythonVersion(args):
break break
PYTHON = 'python%s' % PYVER PYTHON = 'python%s' % PYVER
if sys.platform.startswith('win'): if isWindows:
PYTHON = posixjoin(os.environ.get('TOOLS'), if os.environ.get('TOOLS'):
'python%s' % PYSHORTVER, TOOLS = os.environ.get('TOOLS')
'python.exe') if 'cygdrive' in TOOLS:
findPython = runcmd("which %s" % PYTHON, True, False) TOOLS = runcmd('cygpath -w '+TOOLS, True, False)
msg('Found %s at %s' % (PYTHON, findPython)) PYTHON = posixjoin(TOOLS,
'python%s' % PYSHORTVER,
'python.exe')
else:
# if TOOLS is not set then default to the python that invoked
# this script
PYTHON = sys.executable
PYVER = sys.version[:3]
PYSHORTVER = PYVER[0] + PYVER[2]
msg('Using %s' % PYTHON)
else:
findPython = runcmd("which %s" % PYTHON, True, False)
msg('Found %s at %s' % (PYTHON, findPython))
msg(runcmd('%s -c "import sys; print sys.version"' % PYTHON, True, False)) msg(runcmd('%s -c "import sys; print sys.version"' % PYTHON, True, False))
def setDevModeOptions(args): def setDevModeOptions(args):
# Using --dev is a shortcut for setting several build options that I use # Using --dev is a shortcut for setting several build options that
# while working on the code in my local workspaces. Most people will # I use while working on the code in my local workspaces. Most
# probably not use this so it is not part for the documented options and # people will probably not use this so it is not part for the
# is explicitly handled here before the options parser is created. # documented options and is explicitly handled here before the
# options parser is created. If anybody besides Robin is using
# this option do not depend on the options it inserts into the
# args list being consistent. They could change at any update
# from the repository.
myDevModeOptions = [ myDevModeOptions = [
'--sip', '--sip',
'--debug',
'--build_dir=../bld', '--build_dir=../bld',
'--prefix=/opt/wx/2.9', '--prefix=/opt/wx/2.9',
# These will be ignored on the other platforms so it is okay to
# include them here
'--osx_cocoa', '--osx_cocoa',
'--mac_arch=i386', '--mac_arch=i386',
] ]
if not isWindows:
myDevModeOptions.append('--debug')
if '--dev' in args: if '--dev' in args:
idx = args.index('--dev') idx = args.index('--dev')
# replace the --dev item with the items from the list # replace the --dev item with the items from the list
@@ -173,23 +195,32 @@ def phoenixDir():
def wxDir(): def wxDir():
WXWIN = os.environ.get('WXWIN') WXWIN = os.environ.get('WXWIN')
if not WXWIN: if not WXWIN:
for rel in ['../wxWidgets', '..']: for rel in ['../wxWidgets', '../wx', '..']:
path = os.path.join(phoenixDir(), rel) path = os.path.join(phoenixDir(), rel)
if path and os.path.exists(path): if path and os.path.exists(path) and os.path.isdir(path):
WXWIN = os.path.abspath(os.path.join(phoenixDir(), rel)) WXWIN = os.path.abspath(os.path.join(phoenixDir(), rel))
break break
assert WXWIN not in [None, ''] assert WXWIN not in [None, '']
return WXWIN return WXWIN
if sys.platform.startswith("win"): def getMSWSettings(options):
CPU = os.environ.get('CPU') class MSWsettings(object):
if CPU == 'AMD64': pass
dllDir = os.path.join(wxDir(), "lib", "vc_amd64_dll")
else:
dllDir = os.path.join(wxDir(), "lib", "vc_dll")
buildDir = os.path.join(wxDir(), "build", "msw")
msw = MSWsettings()
msw.CPU = os.environ.get('CPU')
if msw.CPU == 'AMD64':
msw.dllDir = posixjoin(wxDir(), "lib", "vc_amd64_dll")
else:
msw.dllDir = posixjoin(wxDir(), "lib", "vc_dll")
msw.buildDir = posixjoin(wxDir(), "build", "msw")
#msw.build_type_ext = "u"
#if options.debug:
# msw.build_type_ext = "ud"
return msw
@@ -211,6 +242,8 @@ def makeOptionParser():
("build_dir", ("", "Directory to store wx build files. (Not used on Windows)")), ("build_dir", ("", "Directory to store wx build files. (Not used on Windows)")),
("extra_setup", ("", "Extra args to pass on setup.py's command line.")), ("extra_setup", ("", "Extra args to pass on setup.py's command line.")),
("extra_make", ("", "Extra args to pass on [n]make's command line.")), ("extra_make", ("", "Extra args to pass on [n]make's command line.")),
("both", (False, "Build both a debug and release version. (Only used on Windows)")),
("unicode", (True, "Build wxPython with unicode support (always on for wx2.9)")),
] ]
parser = optparse.OptionParser("build options:") parser = optparse.OptionParser("build options:")
@@ -245,7 +278,7 @@ def getBuildDir(options):
BUILD_DIR = opj(phoenixDir(), 'bld') BUILD_DIR = opj(phoenixDir(), 'bld')
if options.build_dir: if options.build_dir:
BUILD_DIR = os.path.abspath(options.build_dir) BUILD_DIR = os.path.abspath(options.build_dir)
if sys.platform == 'darwin': if isDarwin:
port = 'cocoa' port = 'cocoa'
if options.osx_carbon: if options.osx_carbon:
port = 'carbon' port = 'carbon'
@@ -275,17 +308,27 @@ def macFixDependencyInstallName(destdir, prefix, extension, buildDir):
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def _doDox(arg):
if isWindows:
d = posixjoin(wxDir(), 'docs/doxygen')
d = d.replace('\\', '/')
cmd = 'c:/cygwin/bin/bash.exe -l -c "cd %s && ./regen.sh %s"' % (d, arg)
else:
pwd = pushDir(posixjoin(wxDir(), 'docs/doxygen'))
cmd = './regen.sh %s' % arg
runcmd(cmd)
def dox(options, args): def dox(options, args):
msg('Running command: dox') msg('Running command: dox')
pwd = pushDir(posixjoin(wxDir(), 'docs/doxygen')) _doDox('xml')
runcmd('./regen.sh xml')
def doxhtml(options, args): def doxhtml(options, args):
msg('Running command: doxhtml') msg('Running command: doxhtml')
pwd = pushDir(posixjoin(wxDir(), 'docs/doxygen')) _doDox('html chm')
runcmd('./regen.sh html chm')
def etg(options, args): def etg(options, args):
msg('Running command: etg') msg('Running command: etg')
@@ -306,6 +349,20 @@ def etg(options, args):
if newer_group(deps, sipfile): if newer_group(deps, sipfile):
runcmd('%s %s --sip' % (PYTHON, script)) runcmd('%s %s --sip' % (PYTHON, script))
def sip(options, args):
msg('Running command: sip')
cfg = Config()
for src_name in glob.glob(opj(cfg.SIPGEN, '_*.sip')):
src_name = src_name.replace('\\', '/')
base = os.path.basename(os.path.splitext(src_name)[0])
sbf = posixjoin(cfg.SIPOUT, base) + '.sbf'
pycode = posixjoin(cfg.PKGDIR, base) + '.py'
pycode = '-X pycode:'+pycode
cmd = '%s %s -c %s -b %s %s %s' % \
(cfg.SIP, cfg.SIPOPTS, cfg.SIPOUT, sbf, pycode, src_name)
runcmd(cmd)
def touch(options, args): def touch(options, args):
msg('Running command: touch') msg('Running command: touch')
@@ -330,19 +387,20 @@ def build(options, args):
def build_wx(options, args): def build_wx(options, args):
msg('Running command: build_wx') msg('Running command: build_wx')
build_options = list() build_options = ['--wxpython', '--unicode']
if sys.platform.startswith('win'): if isWindows:
# TODO: Add Windows specific build stuff here # Windows-specific pre build stuff
pass pass
else: else:
# Platform is something other than MSW
if options.osx_carbon: if options.osx_carbon:
options.osx_cocoa = False options.osx_cocoa = False
BUILD_DIR = getBuildDir(options) BUILD_DIR = getBuildDir(options)
DESTDIR = options.installdir DESTDIR = options.installdir
PREFIX = options.prefix PREFIX = options.prefix
if options.mac_framework and sys.platform.startswith("darwin"): if options.mac_framework and isDarwin:
# TODO: Don't hard-code this path # TODO: Don't hard-code this path
PREFIX = "/Library/Frameworks/wx.framework/Versions/%s" % version2 PREFIX = "/Library/Frameworks/wx.framework/Versions/%s" % version2
build_options.append('--prefix=%s' % PREFIX) build_options.append('--prefix=%s' % PREFIX)
@@ -369,14 +427,14 @@ def build_wx(options, args):
else: else:
build_options.append("--no_config") build_options.append("--no_config")
if sys.platform.startswith("darwin") and options.osx_cocoa: if isDarwin and options.osx_cocoa:
build_options.append("--osx_cocoa") build_options.append("--osx_cocoa")
if options.install: if options.install:
build_options.append('--installdir=%s' % DESTDIR) build_options.append('--installdir=%s' % DESTDIR)
build_options.append("--install") build_options.append("--install")
if options.mac_framework and sys.platform.startswith("darwin"): if options.mac_framework and isDarwin:
build_options.append("--mac_framework") build_options.append("--mac_framework")
# Change to what will be the wxWidgets build folder # Change to what will be the wxWidgets build folder
@@ -384,7 +442,7 @@ def build_wx(options, args):
# because they may be specified as relative paths.) # because they may be specified as relative paths.)
pwd = pushDir(BUILD_DIR) pwd = pushDir(BUILD_DIR)
if options.debug: if options.debug or (isWindows and options.both):
build_options.append('--debug') build_options.append('--debug')
if options.extra_make: if options.extra_make:
@@ -395,8 +453,16 @@ def build_wx(options, args):
wxscript = os.path.join(wxDir(), "build/tools/build-wxwidgets.py") wxscript = os.path.join(wxDir(), "build/tools/build-wxwidgets.py")
sys.path.insert(0, os.path.dirname(wxscript)) sys.path.insert(0, os.path.dirname(wxscript))
wxbuild = __import__('build-wxwidgets') wxbuild = __import__('build-wxwidgets')
print 'wxWidgets build options:', build_options print 'wxWidgets build options:', build_options
wxbuild.main(wxscript, build_options) wxbuild.main(wxscript, build_options)
# build again without the --debug flag?
if isWindows and options.both:
build_options.remove('--debug')
print 'wxWidgets build options:', build_options
wxbuild.main(wxscript, build_options)
except: except:
print "ERROR: failed building wxWidgets" print "ERROR: failed building wxWidgets"
import traceback import traceback
@@ -408,27 +474,16 @@ def build_wx(options, args):
def build_py(options, args): def build_py(options, args):
msg('Running command: build_py') msg('Running command: build_py')
if False: if isWindows:
# For now, just run setup.py.
# This will need more work later, either to call build-wxpython
# or to implement its important parts here
pwd = pushDir(phoenixDir())
runcmd(PYTHON + ' setup.py build_ext '
'--inplace '
'--debug '
'USE_SIP=1 '
'WXPORT=osx_cocoa '
'ARCH=i386 '
'WX_CONFIG=/projects/wx/2.9/bld/osx_cocoa/wx-config'
+ extraArgs)
return
if sys.platform.startswith("win"):
# Copy the wxWidgets DLLs to the wxPython pacakge folder # Copy the wxWidgets DLLs to the wxPython pacakge folder
dlls = glob.glob(os.path.join(dllDir, "wx*" + version2_nodot + dll_type + "*.dll")) + \ msw = getMSWSettings(options)
glob.glob(os.path.join(dllDir, "wx*" + version3_nodot + dll_type + "*.dll")) cfg = Config()
# NOTE: this will copy both debug and release DLLs if they both exist...
ver = version3_nodot if unstable_series else version2_nodot
dlls = glob.glob(os.path.join(msw.dllDir, "wx*%s*.dll" % ver))
for dll in dlls: for dll in dlls:
shutil.copyfile(dll, os.path.join(phoenixDir(), "wxPhoenix", os.path.basename(dll))) shutil.copyfile(dll, posixjoin(phoenixDir(), cfg.PKGDIR, os.path.basename(dll)))
BUILD_DIR = getBuildDir(options) BUILD_DIR = getBuildDir(options)
DESTDIR = options.installdir DESTDIR = options.installdir
@@ -436,20 +491,20 @@ def build_py(options, args):
build_options = list() build_options = list()
if options.debug: if options.debug or (isWindows and options.both):
build_options.append("--debug") build_options.append("--debug")
if options.sip: if options.sip:
build_options.append('USE_SIP=1') build_options.append('USE_SIP=1')
if options.mac_arch: if isDarwin and options.mac_arch:
build_options.append("ARCH=%s" % options.mac_arch) build_options.append("ARCH=%s" % options.mac_arch)
if sys.platform.startswith("darwin") and options.osx_cocoa: if isDarwin and options.osx_cocoa:
build_options.append("WXPORT=osx_cocoa") build_options.append("WXPORT=osx_cocoa")
if sys.platform.startswith("darwin") and options.osx_carbon: if isDarwin and options.osx_carbon:
build_options.append("WXPORT=osx_carbon") build_options.append("WXPORT=osx_carbon")
build_base = 'build' build_base = 'build'
if sys.platform.startswith("darwin"): if isDarwin:
if options.osx_cocoa: if options.osx_cocoa:
build_base += '/cocoa' build_base += '/cocoa'
else: else:
@@ -460,14 +515,9 @@ def build_py(options, args):
if options.install: if options.install:
build_mode = "build" build_mode = "build"
if not sys.platform.startswith("win"): if not isWindows:
if options.install: if options.install:
wxlocation = DESTDIR + PREFIX wxlocation = DESTDIR + PREFIX
#print '-='*20
#print 'DESTDIR:', DESTDIR
#print 'PREFIX:', PREFIX
#print 'wxlocation:', wxlocation
#print '-='*20
build_options.append('WX_CONFIG="%s/bin/wx-config --prefix=%s"' % build_options.append('WX_CONFIG="%s/bin/wx-config --prefix=%s"' %
(wxlocation, wxlocation)) (wxlocation, wxlocation))
else: else:
@@ -479,7 +529,13 @@ def build_py(options, args):
command = PYTHON + " -u ./setup.py %s %s %s" % \ command = PYTHON + " -u ./setup.py %s %s %s" % \
(build_mode, " ".join(build_options), options.extra_setup) (build_mode, " ".join(build_options), options.extra_setup)
runcmd(command) runcmd(command)
if isWindows and options.both:
build_options.remove('--debug')
command = PYTHON + " -u ./setup.py %s %s %s" % \
(build_mode, " ".join(build_options), options.extra_setup)
runcmd(command)
# Do an install? # Do an install?
if options.install: if options.install:
# only add the --prefix flag if we have an explicit request to do # only add the --prefix flag if we have an explicit request to do
@@ -495,7 +551,7 @@ def build_py(options, args):
(WXPY_PREFIX, " ".join(build_options), options.extra_setup) (WXPY_PREFIX, " ".join(build_options), options.extra_setup)
runcmd(command) runcmd(command)
if sys.platform.startswith("darwin") and DESTDIR: if isDarwin and DESTDIR:
# Now that we are finished with the build fix the ids and # Now that we are finished with the build fix the ids and
# names in the wx .dylibs # names in the wx .dylibs
wxbuild.macFixupInstallNames(DESTDIR, PREFIX, BUILD_DIR) wxbuild.macFixupInstallNames(DESTDIR, PREFIX, BUILD_DIR)
@@ -513,12 +569,29 @@ def build_py(options, args):
print "------------ BUILD FINISHED ------------" print "------------ BUILD FINISHED ------------"
print "To run the wxPython demo:" print "To run the wxPython demo:"
print " - Set your PYTHONPATH variable to %s." % phoenixDir() print " - Set your PYTHONPATH variable to %s." % phoenixDir()
if not sys.platform.startswith("win") and not options.install: if not isWindows and not options.install:
print " - Set your (DY)LD_LIBRARY_PATH to %s" % BUILD_DIR + "/lib" print " - Set your (DY)LD_LIBRARY_PATH to %s" % BUILD_DIR + "/lib"
print " - Run python demo/demo.py" print " - Run python demo/demo.py"
print print
def clean_wx(options, args):
msg('Running command: clean_wx')
def clean_py(options, args):
msg('Running command: clean_py')
def cleanall(options, args):
msg('Running command: cleanall')
clean_wx(options, args)
clean_py(options, args)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -61,6 +61,7 @@ INCLUDES = [ 'defs',
'validate', 'validate',
'window', 'window',
'toplevel', 'toplevel',
'frame',
] ]

View File

@@ -49,7 +49,24 @@ def run():
c.find('OnInitCmdLine').ignore() c.find('OnInitCmdLine').ignore()
c.find('HandleEvent').ignore() c.find('HandleEvent').ignore()
c.find('UsesEventLoop').ignore()
# We will use OnAssertFailure, but I don't think we should let it be
# overridden in Python.
c.find('OnAssertFailure').ignore()
# TODO: Decide if these should be visible from Python. They are for
# dealing with C/C++ exceptions, but perhaps we could also add the ability
# to deal with unhandled Python exceptions using these (overridable)
# methods too.
c.find('OnExceptionInMainLoop').ignore()
c.find('OnFatalException').ignore()
c.find('OnUnhandledException').ignore()
c.find('ExitMainLoop').isVirtual = False
c.addProperty('AppDisplayName GetAppDisplayName SetAppDisplayName') c.addProperty('AppDisplayName GetAppDisplayName SetAppDisplayName')
c.addProperty('AppName GetAppName SetAppName') c.addProperty('AppName GetAppName SetAppName')
c.addProperty('ClassName GetClassName SetClassName') c.addProperty('ClassName GetClassName SetClassName')
@@ -57,21 +74,57 @@ def run():
c.addProperty('VendorName GetVendorName SetVendorName') c.addProperty('VendorName GetVendorName SetVendorName')
#-------------------------------------------------------
c = module.find('wxApp') c = module.find('wxApp')
# Add a new C++ wxPyApp class that adds empty Mac* methods for other # Add a new C++ wxPyApp class that adds empty Mac* methods for other
# platforms, and other goodies, then change the c.name so SIP will # platforms, and other goodies, then change the c.name so SIP will
# generate code wrapping this class as if it was the wxApp class seen in # generate code wrapping this class as if it was the wxApp class seen in
# the DoxyXML. # the DoxyXML.
c.insertCppCode('src/app_ex.cpp') c.includeCppCode('src/app_ex.cpp')
for item in c.allItems(): # change the class name, ctors and dtor names # Now change the class name, ctors and dtor names from wxApp to wxPyApp
for item in c.allItems():
if item.name == 'wxApp': if item.name == 'wxApp':
item.name = 'wxPyApp' item.name = 'wxPyApp'
if item.name == '~wxApp': if item.name == '~wxApp':
item.name = '~wxPyApp' item.name = '~wxPyApp'
c.find('ProcessMessage').ignore() c.find('ProcessMessage').ignore()
c.addCppMethod('void', 'MacHideApp', '()',
doc="Hide all application windows just as the user can do with the\nsystem Hide command. Mac only.",
body="""\
#ifdef __WXMAC__
self->MacHideApp();
#endif
""")
# Remove the virtualness from these methods
for m in [ 'GetDisplayMode', 'GetLayoutDirection', 'GetTopWindow', 'IsActive',
'SafeYield', 'SafeYieldFor', 'SendIdleEvents', 'SetDisplayMode',
'SetNativeTheme', ]:
c.find(m).isVirtual = False
# Methods we implement in wxPyApp beyond what are in wxApp, plus some
# overridden virtuals (or at least some that we want the wrapper generator
# to treat as if they are overridden.)
c.addItem(etgtools.WigCode("""\
wxAppAssertMode GetAssertMode();
void SetAssertMode(wxAppAssertMode mode);
void _BootstrapApp();
static bool IsDisplayAvailable();
virtual int MainLoop();
virtual void OnPreInit();
virtual bool OnInit();
virtual bool OnInitGui();
virtual int OnRun();
virtual int OnExit();
"""))
c.addProperty('DisplayMode GetDisplayMode SetDisplayMode') c.addProperty('DisplayMode GetDisplayMode SetDisplayMode')
c.addProperty('ExitOnFrameDelete GetExitOnFrameDelete SetExitOnFrameDelete') c.addProperty('ExitOnFrameDelete GetExitOnFrameDelete SetExitOnFrameDelete')
c.addProperty('LayoutDirection GetLayoutDirection') c.addProperty('LayoutDirection GetLayoutDirection')
@@ -79,26 +132,9 @@ def run():
c.addProperty('TopWindow GetTopWindow SetTopWindow') c.addProperty('TopWindow GetTopWindow SetTopWindow')
c.addCppMethod('void', 'MacHideApp', '()',
doc="Hide all application windows just as the user can do with the\nsystem Hide command. Mac only.",
body="""\
#ifdef __WXMAC__
self->MacHideApp();
#endif
""")
# Methods we implement in wxPyApp beyond what are in wxApp
c.addItem(etgtools.WigCode("""\
wxAppAssertMode GetAssertMode();
void SetAssertMode(wxAppAssertMode mode);
void _BootstrapApp();
virtual void OnPreInit();
virtual bool OnInit();
static bool IsDisplayAvailable();
"""))
appHeaderCode = """\ appHeaderCode = """\
enum wxAppAssertMode{ enum wxAppAssertMode {
wxPYAPP_ASSERT_SUPPRESS = 1, wxPYAPP_ASSERT_SUPPRESS = 1,
wxPYAPP_ASSERT_EXCEPTION = 2, wxPYAPP_ASSERT_EXCEPTION = 2,
wxPYAPP_ASSERT_DIALOG = 4, wxPYAPP_ASSERT_DIALOG = 4,
@@ -131,7 +167,7 @@ def run():
if item.name == 'wxEntry': if item.name == 'wxEntry':
item.ignore() item.ignore()
#----------------------------------------------------------------- #-----------------------------------------------------------------
tools.doCommonTweaks(module) tools.doCommonTweaks(module)

View File

@@ -42,7 +42,7 @@ def run():
return new wxColour(wxMacCreateCGColorFromHITheme(themeBrushID)); return new wxColour(wxMacCreateCGColorFromHITheme(themeBrushID));
#else #else
wxPyRaiseNotImplemented(); wxPyRaiseNotImplemented();
sipIsErr = 1; _isErr = 1;
return NULL; return NULL;
#endif #endif
""", factory=True) """, factory=True)

View File

@@ -46,7 +46,7 @@ def run():
module.find('wxSwap').ignore() module.find('wxSwap').ignore()
module.find('wxVaCopy').ignore() module.find('wxVaCopy').ignore()
# add some typedefs for wxChar, wxUChar # add some typedefs for wxChar, wxUChar, etc.
td = module.find('wxUIntPtr') td = module.find('wxUIntPtr')
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar')) module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxUChar'))
module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar')) module.insertItemAfter(td, etgtools.TypedefDef(type='wchar_t', name='wxChar'))
@@ -69,6 +69,9 @@ def run():
class wxCaret; class wxCaret;
class wxIcon; class wxIcon;
class wxIconBundle; class wxIconBundle;
class wxStatusBar;
class wxToolBar;
class wxMenuBar;
""")) """))

View File

@@ -63,6 +63,11 @@ ITEMS = [
#'wxThreadEvent', #'wxThreadEvent',
] ]
OTHERDEPS = [ 'src/event_ex.py',
'src/event_ex.cpp',
]
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def run(): def run():
@@ -81,22 +86,86 @@ def run():
""") """)
# TODO:
# * PyEventBinder class
# * event binder instances for all the event types implemented here
# * Connect, Bind etc. methods for EvtHandler
#--------------------------------------- #---------------------------------------
# wxEvtHandler # wxEvtHandler
c = module.find('wxEvtHandler') c = module.find('wxEvtHandler')
c.addPrivateCopyCtor() c.addPrivateCopyCtor()
c.addPublic()
# Ignore the Connect/Disconnect and Bind/Unbind methods (and overloads) for now. # Ignore the Connect/Disconnect and Bind/Unbind methods (and overloads) for now.
for item in c.allItems(): for item in c.allItems():
if item.name in ['Connect', 'Disconnect', 'Bind', 'Unbind']: if item.name in ['Connect', 'Disconnect', 'Bind', 'Unbind']:
item.ignore() item.ignore()
c.includeCppCode('src/event_ex.cpp')
module.includePyCode('src/event_ex.py')
# Connect and disconnect methods for wxPython. Hold a reference to the
# event handler function in the event table, so we can fetch it later when
# it is time to handle the event.
c.addCppMethod(
'void', 'Connect', '(int id, int lastId, wxEventType eventType, PyObject* func)',
"""\
if (PyCallable_Check(func)) {
self->Connect(id, lastId, eventType,
(wxObjectEventFunction)(wxEventFunction)
&wxPyCallback::EventThunker,
new wxPyCallback(func));
}
else if (func == Py_None) {
self->Disconnect(id, lastId, eventType,
(wxObjectEventFunction)(wxEventFunction)
&wxPyCallback::EventThunker);
}
else {
_isErr = 1;
PyErr_SetString(PyExc_TypeError, "Expected callable object or None.");
}
""")
c.addCppMethod(
'bool', 'Disconnect', '(int id, int lastId=-1, '
'wxEventType eventType=wxEVT_NULL, '
'PyObject* func=NULL)',
"""\
if (func && func != Py_None) {
// Find the current matching binder that has this function
// pointer and dissconnect that one. Unfortuneatly since we
// wrapped the PyObject function pointer in another object we
// have to do the searching ourselves...
wxList::compatibility_iterator node = self->GetDynamicEventTable()->GetFirst();
while (node)
{
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
if ((entry->m_id == id) &&
((entry->m_lastId == lastId) || (lastId == wxID_ANY)) &&
((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
// FIXME?
//((entry->m_fn->IsMatching((wxObjectEventFunction)(wxEventFunction)&wxPyCallback::EventThunker))) &&
(entry->m_callbackUserData != NULL))
{
wxPyCallback *cb = (wxPyCallback*)entry->m_callbackUserData;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
int result = PyObject_Compare(cb->m_func, func);
wxPyEndBlockThreads(blocked);
if (result == 0) {
delete cb;
self->GetDynamicEventTable()->Erase(node);
delete entry;
return true;
}
}
node = node->GetNext();
}
return false;
}
else {
return self->Disconnect(id, lastId, eventType,
(wxObjectEventFunction)
&wxPyCallback::EventThunker);
}
""")
# wxEventTable is not documented so we have to ignore SearchEventTable. # wxEventTable is not documented so we have to ignore SearchEventTable.
# TODO: Should wxEventTable be available to language bindings? # TODO: Should wxEventTable be available to language bindings?
@@ -109,7 +178,12 @@ def run():
c.find('GetClientData').ignore() c.find('GetClientData').ignore()
c.find('SetClientData').ignore() c.find('SetClientData').ignore()
# The only virtual we care about overriding is ProcessEvent, ignore the rest
tools.removeVirtuals(c)
c.find('ProcessEvent').isVirtual = True
#--------------------------------------- #---------------------------------------
# wxEvent # wxEvent
c = module.find('wxEvent') c = module.find('wxEvent')

65
etg/frame.py Normal file
View File

@@ -0,0 +1,65 @@
#---------------------------------------------------------------------------
# Name: etg/frame.py
# Author: Robin Dunn
#
# Created: 6-Dec-2010
# Copyright: (c) 2010 by Total Control Software
# License: wxWindows License
#---------------------------------------------------------------------------
import etgtools
import etgtools.tweaker_tools as tools
PACKAGE = "wx"
MODULE = "_core"
NAME = "frame" # Base name of the file to generate to for this script
DOCSTRING = ""
# The classes and/or the basename of the Doxygen XML files to be processed by
# this script.
ITEMS = [ 'wxFrame' ]
#---------------------------------------------------------------------------
def run():
# Parse the XML file(s) building a collection of Extractor objects
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
etgtools.parseDoxyXML(module, ITEMS)
#-----------------------------------------------------------------
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
c = module.find('wxFrame')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
c.find('wxFrame.title').default = 'wxEmptyString'
c.find('Create.title').default = 'wxEmptyString'
c.find('SetStatusWidths.n').arraySize = True
c.find('SetStatusWidths.widths_field').array = True
c.addProperty('MenuBar GetMenuBar SetMenuBar')
c.addProperty('StatusBar GetStatusBar SetStatusBar')
c.addProperty('StatusBarPane GetStatusBarPane SetStatusBarPane')
c.addProperty('ToolBar GetToolBar SetToolBar')
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
# TODO: should these go into a tools.addFrameVirtuals function?
c.find('OnCreateStatusBar').isVirtual = True
c.find('OnCreateToolBar').isVirtual = True
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -35,21 +35,27 @@ def run():
# customizing the generated code and docstrings. # customizing the generated code and docstrings.
module.find('wxObject.operator delete').ignore()
module.find('wxObject.operator new').ignore()
module.find('wxCreateDynamicObject').ignore() module.find('wxCreateDynamicObject').ignore()
#module.find('wxClassInfo').abstract = True #module.find('wxClassInfo').abstract = True
#module.find('wxClassInfo.wxClassInfo').ignore() #module.find('wxClassInfo.wxClassInfo').ignore()
module.find('wxObject.GetClassInfo').ignore()
module.find('wxObject.IsKindOf').ignore()
module.find('wxRefCounter.~wxRefCounter').ignore(False) #--------------------------------------------------
c = module.find('wxRefCounter')
c = module.find('wxObject')
assert isinstance(c, etgtools.ClassDef) assert isinstance(c, etgtools.ClassDef)
c.find('~wxRefCounter').ignore(False)
c.addPrivateCopyCtor()
#--------------------------------------------------
c = module.find('wxObject')
c.find('operator delete').ignore()
c.find('operator new').ignore()
c.find('GetClassInfo').ignore()
c.find('IsKindOf').ignore()
c.addCppMethod('const wxChar*', 'GetClassName', '()', c.addCppMethod('const wxChar*', 'GetClassName', '()',
body='return self->GetClassInfo()->GetClassName();', body='return self->GetClassInfo()->GetClassName();',

View File

@@ -40,6 +40,8 @@ def run():
c.addProperty('Tip GetTip SetTip') c.addProperty('Tip GetTip SetTip')
c.addProperty('Window GetWindow') c.addProperty('Window GetWindow')
c.addPrivateCopyCtor()
#----------------------------------------------------------------- #-----------------------------------------------------------------
tools.doCommonTweaks(module) tools.doCommonTweaks(module)

View File

@@ -74,6 +74,10 @@ def run():
c.addProperty('TmpDefaultItem GetTmpDefaultItem SetTmpDefaultItem') c.addProperty('TmpDefaultItem GetTmpDefaultItem SetTmpDefaultItem')
c.addProperty('OSXModified OSXIsModified OSXSetModified') c.addProperty('OSXModified OSXIsModified OSXSetModified')
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
#----------------------------------------------------------------- #-----------------------------------------------------------------
tools.doCommonTweaks(module) tools.doCommonTweaks(module)
tools.runGenerators(module) tools.runGenerators(module)

View File

@@ -36,8 +36,31 @@ def run():
c = module.find('wxWindow') c = module.find('wxWindow')
assert isinstance(c, etgtools.ClassDef) assert isinstance(c, etgtools.ClassDef)
# First we need to let the wrapper generator know about wxWindowBase since
# AddChild and RemoveChild need to use that type in order to be virtualized.
wc = etgtools.WigCode("""\
class wxWindowBase : wxEvtHandler /Abstract/
{
public:
virtual void AddChild( wxWindowBase* child );
virtual void RemoveChild( wxWindowBase* child );
};
""")
module.insertItemBefore(c, wc)
c.insertCppCode('src/window_ex.cpp') # Now change the base class of wxWindow
c.bases = ['wxWindowBase']
# And fix the arg types we get from Doxy
c.find('AddChild.child').type = 'wxWindowBase*'
c.find('RemoveChild.child').type = 'wxWindowBase*'
# We now return you to our regularly scheduled programming...
tools.fixWindowClass(c)
c.includeCppCode('src/window_ex.cpp')
# ignore some overloads that will be ambiguous afer wrapping # ignore some overloads that will be ambiguous afer wrapping
c.find('GetChildren').overloads = [] c.find('GetChildren').overloads = []
@@ -85,7 +108,8 @@ def run():
#endif #endif
""") """)
# Make these be available on Windows, and empty stubs otherwise # Make the Register/UnregisterHotKey functions be available on Windows,
# and empty stubs otherwise
c.find('RegisterHotKey').setCppCode("""\ c.find('RegisterHotKey').setCppCode("""\
#ifdef __WXMSW__ #ifdef __WXMSW__
sipRes = sipCpp->RegisterHotKey(hotkeyId, modifiers, virtualKeyCode); sipRes = sipCpp->RegisterHotKey(hotkeyId, modifiers, virtualKeyCode);
@@ -103,6 +127,7 @@ def run():
c.find('RegisterHotKey').isVirtual = False c.find('RegisterHotKey').isVirtual = False
c.find('UnregisterHotKey').isVirtual = False c.find('UnregisterHotKey').isVirtual = False
c.find('SetDoubleBuffered').setCppCode("""\ c.find('SetDoubleBuffered').setCppCode("""\
#if defined(__WXGTK20__) || defined(__WXMSW__) #if defined(__WXGTK20__) || defined(__WXMSW__)
sipCpp->SetDoubleBuffered(on); sipCpp->SetDoubleBuffered(on);
@@ -117,16 +142,12 @@ def run():
# MSW only. Do we want them wrapped? # MSW only. Do we want them wrapped?
c.find('GetAccessible').ignore() c.find('GetAccessible').ignore()
c.find('SetAccessible').ignore() c.find('SetAccessible').ignore()
# Make some of the protected methods visible and overridable from Python # Make some of the protected methods visible and overridable from Python
c.find('DoCentre').ignore(False)
c.find('DoGetBestSize').ignore(False)
c.find('SetInitialBestSize').ignore(False)
c.find('SendDestroyEvent').ignore(False) c.find('SendDestroyEvent').ignore(False)
c.find('ProcessEvent').ignore(False)
c.find('Destroy').transferThis=True
c.addPyMethod('PostCreate', '()', 'pass') c.addPyMethod('PostCreate', '(self, pre)', 'pass')
# transfer ownership of these parameters to the C++ object # transfer ownership of these parameters to the C++ object
c.find('SetCaret.caret').transfer = True c.find('SetCaret.caret').transfer = True
@@ -191,20 +212,39 @@ def run():
c.addProperty('WindowStyle GetWindowStyle SetWindowStyle') c.addProperty('WindowStyle GetWindowStyle SetWindowStyle')
c.addProperty('WindowStyleFlag GetWindowStyleFlag SetWindowStyleFlag') c.addProperty('WindowStyleFlag GetWindowStyleFlag SetWindowStyleFlag')
c.addProperty('WindowVariant GetWindowVariant SetWindowVariant') c.addProperty('WindowVariant GetWindowVariant SetWindowVariant')
c.addProperty('Shown IsShown Show') c.addProperty('Shown IsShown Show')
c.addProperty('Enabled IsEnabled Enable') c.addProperty('Enabled IsEnabled Enable')
c.addProperty('TopLevel IsTopLevel') c.addProperty('TopLevel IsTopLevel')
##c.addProperty('GtkWidget GetGtkWidget')
c.addProperty('MinClientSize GetMinClientSize SetMinClientSize') c.addProperty('MinClientSize GetMinClientSize SetMinClientSize')
c.addProperty('MaxClientSize GetMaxClientSize SetMaxClientSize') c.addProperty('MaxClientSize GetMaxClientSize SetMaxClientSize')
##c.addProperty('GtkWidget GetGtkWidget')
# We probably won't ever need most of the wxWindow virtuals to be
# overridable in Python, so we'll clear all the virtual flags here and add
# back those that we want to keep in the next step.
tools.removeVirtuals(c)
tools.addWindowVirtuals(c)
module.addPyCode('''\
class FrozenWindow(object):
"""
A context manager to be used with Python 'with' statements
that will freeze the given window for the duration of the
with block.
"""
def __init__(self, window):
self._win = window
def __enter__(self):
self._win.Freeze()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self._win.Thaw()
''')
tools.fixWindowClass(c)
#----------------------------------------------------------------- #-----------------------------------------------------------------
tools.doCommonTweaks(module) tools.doCommonTweaks(module)
tools.runGenerators(module) tools.runGenerators(module)

View File

@@ -86,6 +86,17 @@ class BaseDef(object):
else: # got though all items with no match else: # got though all items with no match
raise ExtractorError("Unable to find item named '%s' within %s named '%s'" % raise ExtractorError("Unable to find item named '%s' within %s named '%s'" %
(head, self.__class__.__name__, self.name)) (head, self.__class__.__name__, self.name))
def findItem(self, name):
"""
Just like find() but does not raise an exception if the item is not found.
"""
try:
item = self.find(name)
return item
except ExtractorError:
return None
def addItem(self, item): def addItem(self, item):
self.items.append(item) self.items.append(item)
@@ -228,9 +239,11 @@ class FunctionDef(BaseDef):
if element is not None: if element is not None:
self.extract(element) self.extract(element)
def releaseGIL(self, release=True): def releaseGIL(self, release=True):
self.pyReleaseGIL = release self.pyReleaseGIL = release
def extract(self, element): def extract(self, element):
super(FunctionDef, self).extract(element) super(FunctionDef, self).extract(element)
self.type = flattenNode(element.find('type')) self.type = flattenNode(element.find('type'))
@@ -422,7 +435,7 @@ class ClassDef(BaseDef):
self.cppCode.append(code) self.cppCode.append(code)
def insertCppCode(self, filename): def includeCppCode(self, filename):
self.addCppCode(file(filename).read()) self.addCppCode(file(filename).read())

View File

@@ -360,7 +360,7 @@ from %s import *
stream.write(')') stream.write(')')
if prop.briefDoc: if prop.briefDoc:
stream.write(' // %s' % prop.briefDoc) stream.write(' // %s' % prop.briefDoc)
stream.write('\n\n') stream.write('\n')
def generateMethod(self, method, stream, indent): def generateMethod(self, method, stream, indent):

View File

@@ -91,10 +91,6 @@ def fixWindowClass(klass):
# give the id param a default value # give the id param a default value
klass.find('%s.id' % klass.name).default = 'wxID_ANY' klass.find('%s.id' % klass.name).default = 'wxID_ANY'
klass.find('Create.id').default = 'wxID_ANY' klass.find('Create.id').default = 'wxID_ANY'
# look for wxByte parameters
#for item in klass.allItems():
# if hasattr(item, 'type') and item.type == 'wxByte':
# item.pyInt = True
def removeVirtuals(klass): def removeVirtuals(klass):
@@ -108,6 +104,80 @@ def removeVirtuals(klass):
if isinstance(item, extractors.MethodDef): if isinstance(item, extractors.MethodDef):
item.isVirtual = item.isPureVirtual = False item.isVirtual = item.isPureVirtual = False
def addWindowVirtuals(klass):
"""
"""
publicWindowVirtuals = [
('GetClientAreaOrigin', 'wxPoint GetClientAreaOrigin() const'),
('Validate', 'bool Validate()'),
('TransferDataToWindow', 'bool TransferDataToWindow()'),
('TransferDataFromWindow', 'bool TransferDataFromWindow()'),
('InitDialog', 'void InitDialog()'),
('AcceptsFocus', 'bool AcceptsFocus() const'),
('AcceptsFocusRecursively', 'bool AcceptsFocusRecursively() const'),
('AcceptsFocusFromKeyboard', 'bool AcceptsFocusFromKeyboard() const'),
('AddChild', 'void AddChild( wxWindowBase *child )'),
('RemoveChild', 'void RemoveChild( wxWindowBase *child )'),
('InheritAttributes', 'void InheritAttributes()'),
('ShouldInheritColours', 'bool ShouldInheritColours() const'),
('HasTransparentBackground', 'bool HasTransparentBackground()'),
('OnInternalIdle', 'void OnInternalIdle()'),
('GetMainWindowOfCompositeControl',
'wxWindow *GetMainWindowOfCompositeControl()'),
#('Enable', ''), We have DoEnable now...
## What about these?
#bool HasMultiplePages() const
#void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
#void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
]
protectedWindowVirtuals = [
('ProcessEvent', 'bool ProcessEvent(wxEvent & event)'),
('DoEnable', 'void DoEnable(bool enable)'),
('OnEnabled', 'void OnEnabled(bool enabled)'),
('DoGetPosition', 'void DoGetPosition(int *x, int *y) const'),
('DoGetSize', 'void DoGetSize(int *width, int *height) const'),
('DoGetClientSize', 'void DoGetClientSize(int *width, int *height) const'),
('DoGetBestSize', 'wxSize DoGetBestSize() const'),
('DoGetBestClientSize', 'wxSize DoGetBestClientSize() const'),
('DoSetSize', 'void DoSetSize(int x, int y, int width, int height, int sizeFlags)'),
('DoSetClientSize', 'void DoSetClientSize(int width, int height)'),
('DoSetSizeHints', 'void DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH )'),
('DoGetBorderSize', 'wxSize DoGetBorderSize() const'),
('DoMoveWindow', 'void DoMoveWindow(int x, int y, int width, int height)'),
('DoSetWindowVariant', 'void DoSetWindowVariant( wxWindowVariant variant)'),
('GetDefaultBorder', 'wxBorder GetDefaultBorder() const'),
('GetDefaultBorderForControl',
'wxBorder GetDefaultBorderForControl() const'),
## What about these?
#('DoGetScreenPosition', 'void DoGetScreenPosition(int *x, int *y) const'),
#('DoSetVirtualSize', 'void DoSetVirtualSize( int x, int y )'),
#('DoGetVirtualSize', 'wxSize DoGetVirtualSize() const'),
]
def _processItems(klass, prot, virtuals):
txt = ''
for name, decl in virtuals:
m = klass.findItem(name)
if m:
m.ignore(False)
m.isVirtual = True
else:
txt += 'virtual %s;\n' % decl
if txt:
txt = prot + txt
return txt
txt = _processItems(klass, 'public:\n', publicWindowVirtuals)
klass.addItem(extractors.WigCode(txt))
txt = _processItems(klass, 'protected:\n', protectedWindowVirtuals)
klass.addItem(extractors.WigCode(txt))
def getEtgFiles(names): def getEtgFiles(names):
""" """

View File

@@ -0,0 +1,6 @@
import wxPhoenix as wx
app = wx.PySimpleApp() # Should see a deprecation warning here
frm = wx.Frame(None)
frm.Show()
app.MainLoop()

16
samples/simple/events.py Normal file
View File

@@ -0,0 +1,16 @@
import wxPhoenix as wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kw):
wx.Frame.__init__(self, *args, **kw)
self.Bind(wx.EVT_SIZE, self.onSize)
def onSize(self, evt):
print repr(evt.Size)
app = wx.App()
frm = MyFrame(None, title="Hello Events", size=(480,360))
frm.Show()
app.MainLoop()

11
samples/simple/hello.py Normal file
View File

@@ -0,0 +1,11 @@
import sys, os
import wxPhoenix as wx
#print 'PID:', os.getpid(); raw_input('Ready to start, press enter...')
app = wx.App()
frm = wx.Frame(None, title="Hello World!")
frm.Show()
app.MainLoop()

View File

@@ -79,6 +79,7 @@ from _core import *
%Include validate.sip %Include validate.sip
%Include window.sip %Include window.sip
%Include toplevel.sip %Include toplevel.sip
%Include frame.sip
%ModuleCode %ModuleCode
@@ -164,7 +165,6 @@ void wxPyCoreModuleInject(PyObject* moduleDict)
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This code block was included from src/core_ex.py # This code block was included from src/core_ex.py
# A little trick to make 'wx' be a reference to this module so wx.Names can # A little trick to make 'wx' be a reference to this module so wx.Names can
# be used in the python code here. # be used in the python code here.
import sys as _sys import sys as _sys
@@ -207,7 +207,7 @@ def deprecated(func):
def new_func(*args, **kwargs): def new_func(*args, **kwargs):
import warnings import warnings
warnings.warn("Call to deprecated item %s." % func.__name__, warnings.warn("Call to deprecated item %s." % func.__name__,
category=DeprecationWarning) DeprecationWarning, stacklevel=2)
return func(*args, **kwargs) return func(*args, **kwargs)
new_func.__name__ = func.__name__ new_func.__name__ = func.__name__
new_func.__doc__ = func.__doc__ new_func.__doc__ = func.__doc__

View File

@@ -9,7 +9,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
%ModuleHeaderCode %ModuleHeaderCode
enum wxAppAssertMode{ enum wxAppAssertMode {
wxPYAPP_ASSERT_SUPPRESS = 1, wxPYAPP_ASSERT_SUPPRESS = 1,
wxPYAPP_ASSERT_EXCEPTION = 2, wxPYAPP_ASSERT_EXCEPTION = 2,
wxPYAPP_ASSERT_DIALOG = 4, wxPYAPP_ASSERT_DIALOG = 4,
@@ -38,7 +38,6 @@ public:
virtual virtual
int MainLoop(); int MainLoop();
virtual
void ExitMainLoop(); void ExitMainLoop();
virtual virtual
@@ -48,9 +47,6 @@ public:
wxEventLoopBase * GetMainLoop(); wxEventLoopBase * GetMainLoop();
virtual
bool UsesEventLoop();
virtual virtual
void ProcessPendingEvents(); void ProcessPendingEvents();
@@ -70,15 +66,6 @@ public:
wxObject * object wxObject * object
); );
virtual
void OnAssertFailure(
const wxChar * file,
int line,
const wxChar * func,
const wxChar * cond,
const wxChar * msg
);
virtual virtual
void OnEventLoopEnter( void OnEventLoopEnter(
wxEventLoopBase * loop wxEventLoopBase * loop
@@ -89,24 +76,15 @@ public:
wxEventLoopBase * loop wxEventLoopBase * loop
); );
virtual
bool OnExceptionInMainLoop();
virtual virtual
int OnExit(); int OnExit();
virtual
void OnFatalException();
virtual virtual
bool OnInit(); bool OnInit();
virtual virtual
int OnRun(); int OnRun();
virtual
void OnUnhandledException();
wxString GetAppDisplayName(); wxString GetAppDisplayName();
wxString GetAppName(); wxString GetAppName();
@@ -151,19 +129,14 @@ public:
bool IsMainLoopRunning(); bool IsMainLoopRunning();
%Property(name=AppDisplayName, get=GetAppDisplayName, set=SetAppDisplayName) %Property(name=AppDisplayName, get=GetAppDisplayName, set=SetAppDisplayName)
%Property(name=AppName, get=GetAppName, set=SetAppName) %Property(name=AppName, get=GetAppName, set=SetAppName)
%Property(name=ClassName, get=GetClassName, set=SetClassName) %Property(name=ClassName, get=GetClassName, set=SetClassName)
%Property(name=VendorDisplayName, get=GetVendorDisplayName, set=SetVendorDisplayName) %Property(name=VendorDisplayName, get=GetVendorDisplayName, set=SetVendorDisplayName)
%Property(name=VendorName, get=GetVendorName, set=SetVendorName) %Property(name=VendorName, get=GetVendorName, set=SetVendorName)
}; // end of class wxAppConsole }; // end of class wxAppConsole
enum wxAppAssertMode{ enum wxAppAssertMode {
wxPYAPP_ASSERT_SUPPRESS = 1, wxPYAPP_ASSERT_SUPPRESS = 1,
wxPYAPP_ASSERT_EXCEPTION = 2, wxPYAPP_ASSERT_EXCEPTION = 2,
wxPYAPP_ASSERT_DIALOG = 4, wxPYAPP_ASSERT_DIALOG = 4,
@@ -249,6 +222,7 @@ class wxPyApp : wxAppConsole
virtual void OnPreInit() { } virtual void OnPreInit() { }
void _BootstrapApp(); void _BootstrapApp();
virtual int MainLoop();
static bool IsDisplayAvailable(); static bool IsDisplayAvailable();
@@ -273,32 +247,32 @@ class wxPyApp : wxAppConsole
static bool haveInitialized = false; static bool haveInitialized = false;
bool result; bool result;
wxPyBlock_t blocked; wxPyBlock_t blocked;
PyObject* retval = NULL;
PyObject* pyint = NULL;
// Only initialize wxWidgets once // Only initialize wxWidgets once
if (! haveInitialized) { if (! haveInitialized) {
// Get any command-line args passed to this program from the sys module
// Copy the values in Python's sys.argv list to a C array of char* to
// be passed to the wxEntryStart function below.
int argc = 0; int argc = 0;
char** argv = NULL; char** argv = NULL;
blocked = wxPyBeginBlockThreads(); blocked = wxPyBeginBlockThreads();
PyObject* sysargv = PySys_GetObject("argv"); PyObject* sysargv = PySys_GetObject("argv");
PyObject* executable = PySys_GetObject("executable"); if (sysargv != NULL) {
argc = PyList_Size(sysargv);
if (sysargv != NULL && executable != NULL) {
argc = PyList_Size(sysargv) + 1;
argv = new char*[argc+1]; argv = new char*[argc+1];
argv[0] = strdup(PyString_AsString(executable));
int x; int x;
for(x=1; x<argc; x++) { for(x=0; x<argc; x++) {
PyObject *pyArg = PyList_GetItem(sysargv, x-1); PyObject *pyArg = PyList_GetItem(sysargv, x); // borrowed reference
// if there isn't anything in sys.argv[0] then set it to the python executable
if (x == 0 && PyObject_Length(pyArg) < 1)
pyArg = PySys_GetObject("executable");
argv[x] = strdup(PyString_AsString(pyArg)); argv[x] = strdup(PyString_AsString(pyArg));
} }
argv[argc] = NULL; argv[argc] = NULL;
} }
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
// Initialize wxWidgets // Initialize wxWidgets
#ifdef __WXOSX__ #ifdef __WXOSX__
wxMacAutoreleasePool autoreleasePool; wxMacAutoreleasePool autoreleasePool;
@@ -339,6 +313,28 @@ class wxPyApp : wxAppConsole
} }
int wxPyApp::MainLoop()
{
int retval = 0;
{
#ifdef __WXOSX__
wxMacAutoreleasePool autoreleasePool;
#endif
DeletePendingObjects();
}
bool initialized = wxTopLevelWindows.GetCount() != 0;
if (initialized) {
if ( m_exitOnFrameDelete == Later ) {
m_exitOnFrameDelete = Yes;
}
retval = wxApp::MainLoop();
OnExit();
}
return retval;
}
// Function to test if the Display (or whatever is the platform equivallent) // Function to test if the Display (or whatever is the platform equivallent)
// can be connected to. This is accessable from wxPython as a staticmethod of // can be connected to. This is accessable from wxPython as a staticmethod of
@@ -459,41 +455,33 @@ public:
const wxString & val const wxString & val
); );
virtual
wxVideoMode GetDisplayMode(); wxVideoMode GetDisplayMode();
bool GetExitOnFrameDelete(); bool GetExitOnFrameDelete();
virtual
wxLayoutDirection GetLayoutDirection(); wxLayoutDirection GetLayoutDirection();
bool GetUseBestVisual(); bool GetUseBestVisual();
virtual
wxWindow * GetTopWindow(); wxWindow * GetTopWindow();
virtual
bool IsActive(); bool IsActive();
virtual
bool SafeYield( bool SafeYield(
wxWindow * win, wxWindow * win,
bool onlyIfNeeded bool onlyIfNeeded
); );
virtual
bool SafeYieldFor( bool SafeYieldFor(
wxWindow * win, wxWindow * win,
long eventsToProcess long eventsToProcess
); );
virtual
bool SendIdleEvents( bool SendIdleEvents(
wxWindow * win, wxWindow * win,
wxIdleEvent & event wxIdleEvent & event
); );
virtual
bool SetDisplayMode( bool SetDisplayMode(
const wxVideoMode & info const wxVideoMode & info
); );
@@ -502,7 +490,6 @@ public:
bool flag bool flag
); );
virtual
bool SetNativeTheme( bool SetNativeTheme(
const wxString & theme const wxString & theme
); );
@@ -516,16 +503,6 @@ public:
bool forceTrueColour = false bool forceTrueColour = false
); );
%Property(name=DisplayMode, get=GetDisplayMode, set=SetDisplayMode)
%Property(name=ExitOnFrameDelete, get=GetExitOnFrameDelete, set=SetExitOnFrameDelete)
%Property(name=LayoutDirection, get=GetLayoutDirection)
%Property(name=UseBestVisual, get=GetUseBestVisual, set=SetUseBestVisual)
%Property(name=TopWindow, get=GetTopWindow, set=SetTopWindow)
%TypeCode %TypeCode
void _wxPyApp_MacHideApp(wxPyApp* self, int& _isErr) void _wxPyApp_MacHideApp(wxPyApp* self, int& _isErr)
{ {
@@ -539,14 +516,24 @@ public:
_wxPyApp_MacHideApp(sipCpp, sipIsErr); _wxPyApp_MacHideApp(sipCpp, sipIsErr);
%End %End
wxAppAssertMode GetAssertMode(); wxAppAssertMode GetAssertMode();
void SetAssertMode(wxAppAssertMode mode); void SetAssertMode(wxAppAssertMode mode);
void _BootstrapApp(); void _BootstrapApp();
static bool IsDisplayAvailable();
virtual int MainLoop();
virtual void OnPreInit(); virtual void OnPreInit();
virtual bool OnInit(); virtual bool OnInit();
static bool IsDisplayAvailable(); virtual bool OnInitGui();
virtual int OnRun();
virtual int OnExit();
%Property(name=DisplayMode, get=GetDisplayMode, set=SetDisplayMode)
%Property(name=ExitOnFrameDelete, get=GetExitOnFrameDelete, set=SetExitOnFrameDelete)
%Property(name=LayoutDirection, get=GetLayoutDirection)
%Property(name=UseBestVisual, get=GetUseBestVisual, set=SetUseBestVisual)
%Property(name=TopWindow, get=GetTopWindow, set=SetTopWindow)
}; // end of class wxPyApp }; // end of class wxPyApp
@@ -761,6 +748,7 @@ logged in on the main display of your Mac."""
def __del__(self): def __del__(self):
self.RestoreStdio() # Just in case the MainLoop was overridden self.RestoreStdio() # Just in case the MainLoop was overridden
def Destroy(self): def Destroy(self):
## self.this.own(False) ## self.this.own(False)
wx.PyApp.Destroy(self) wx.PyApp.Destroy(self)

View File

@@ -152,19 +152,12 @@ public:
) /PyInt/; ) /PyInt/;
%Property(name=Pixel, get=GetPixel) %Property(name=Pixel, get=GetPixel)
%Property(name=RGB, get=GetRGB, set=SetRGB) %Property(name=RGB, get=GetRGB, set=SetRGB)
%Property(name=RGBA, get=GetRGBA, set=SetRGBA) %Property(name=RGBA, get=GetRGBA, set=SetRGBA)
%Property(name=red, get=Red) %Property(name=red, get=Red)
%Property(name=green, get=Green) %Property(name=green, get=Green)
%Property(name=blue, get=Blue) %Property(name=blue, get=Blue)
%Property(name=alpha, get=Alpha) %Property(name=alpha, get=Alpha)
%TypeCode %TypeCode
wxIntPtr _wxColour_GetPixel(wxColour* self, int& _isErr) wxIntPtr _wxColour_GetPixel(wxColour* self, int& _isErr)
{ {
@@ -381,7 +374,7 @@ wxColour* _MacThemeColour_function(int& _isErr, int themeBrushID)
return new wxColour(wxMacCreateCGColorFromHITheme(themeBrushID)); return new wxColour(wxMacCreateCGColorFromHITheme(themeBrushID));
#else #else
wxPyRaiseNotImplemented(); wxPyRaiseNotImplemented();
sipIsErr = 1; _isErr = 1;
return NULL; return NULL;
#endif #endif
} }

View File

@@ -32,6 +32,9 @@
class wxCaret; class wxCaret;
class wxIcon; class wxIcon;
class wxIconBundle; class wxIconBundle;
class wxStatusBar;
class wxToolBar;
class wxMenuBar;
typedef signed char wxInt8 /PyInt/; typedef signed char wxInt8 /PyInt/;

View File

@@ -65,13 +65,9 @@ public:
%Property(name=ClientArea, get=GetClientArea) %Property(name=ClientArea, get=GetClientArea)
%Property(name=CurrentMode, get=GetCurrentMode) %Property(name=CurrentMode, get=GetCurrentMode)
%Property(name=Geometry, get=GetGeometry) %Property(name=Geometry, get=GetGeometry)
%Property(name=Name, get=GetName) %Property(name=Name, get=GetName)
}; // end of class wxDisplay }; // end of class wxDisplay

View File

@@ -23,19 +23,142 @@ class wxEvtHandler : wxObject, wxTrackable
#include <wx/event.h> #include <wx/event.h>
%End %End
%TypeCode
class wxPyCallback : public wxEvtHandler {
DECLARE_ABSTRACT_CLASS(wxPyCallback)
public:
wxPyCallback(PyObject* func);
wxPyCallback(const wxPyCallback& other);
~wxPyCallback();
void EventThunker(wxEvent& event);
PyObject* m_func;
};
IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxEvtHandler);
wxPyCallback::wxPyCallback(PyObject* func) {
m_func = func;
Py_INCREF(m_func);
}
wxPyCallback::wxPyCallback(const wxPyCallback& other) {
m_func = other.m_func;
Py_INCREF(m_func);
}
wxPyCallback::~wxPyCallback() {
wxPyBlock_t blocked = wxPyBeginBlockThreads();
Py_DECREF(m_func);
wxPyEndBlockThreads(blocked);
}
// #define wxPy_PRECALLINIT "_preCallInit"
// #define wxPy_POSTCALLCLEANUP "_postCallCleanup"
// This function is used for all events destined for Python event handlers.
void wxPyCallback::EventThunker(wxEvent& event) {
wxPyCallback* cb = (wxPyCallback*)event.m_callbackUserData;
PyObject* func = cb->m_func;
PyObject* result;
PyObject* arg;
PyObject* tuple;
bool checkSkip = false;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
wxString className = event.GetClassInfo()->GetClassName();
// // If the event is one of these types then pass the original
// // event object instead of the one passed to us.
// if ( className == wxT("wxPyEvent") ) {
// arg = ((wxPyEvent*)&event)->GetSelf();
// checkSkip = ((wxPyEvent*)&event)->GetCloned();
// }
// else if ( className == wxT("wxPyCommandEvent") ) {
// arg = ((wxPyCommandEvent*)&event)->GetSelf();
// checkSkip = ((wxPyCommandEvent*)&event)->GetCloned();
// }
// else {
arg = wxPyConstructObject((void*)&event, className);
// }
if (!arg) {
PyErr_Print();
} else {
// // "intern" the pre/post method names to speed up the HasAttr
// static PyObject* s_preName = NULL;
// static PyObject* s_postName = NULL;
// if (s_preName == NULL) {
// s_preName = PyString_FromString(wxPy_PRECALLINIT);
// s_postName = PyString_FromString(wxPy_POSTCALLCLEANUP);
// }
// // Check if the event object needs some preinitialization
// if (PyObject_HasAttr(arg, s_preName)) {
// result = PyObject_CallMethodObjArgs(arg, s_preName, arg, NULL);
// if ( result ) {
// Py_DECREF(result); // result is ignored, but we still need to decref it
// PyErr_Clear(); // Just in case...
// } else {
// PyErr_Print();
// }
// }
// Call the event handler, passing the event object
tuple = PyTuple_New(1);
PyTuple_SET_ITEM(tuple, 0, arg); // steals ref to arg
result = PyEval_CallObject(func, tuple);
if ( result ) {
Py_DECREF(result); // result is ignored, but we still need to decref it
PyErr_Clear(); // Just in case...
} else {
PyErr_Print();
}
// // Check if the event object needs some post cleanup
// if (PyObject_HasAttr(arg, s_postName)) {
// result = PyObject_CallMethodObjArgs(arg, s_postName, arg, NULL);
// if ( result ) {
// Py_DECREF(result); // result is ignored, but we still need to decref it
// PyErr_Clear(); // Just in case...
// } else {
// PyErr_Print();
// }
// }
// if ( checkSkip ) {
// // if the event object was one of our special types and
// // it had been cloned, then we need to extract the Skipped
// // value from the original and set it in the clone.
// result = PyObject_CallMethod(arg, "GetSkipped", "");
// if ( result ) {
// event.Skip(PyInt_AsLong(result));
// Py_DECREF(result);
// } else {
// PyErr_Print();
// }
// }
Py_DECREF(tuple);
}
wxPyEndBlockThreads(blocked);
}
%End
public: public:
wxEvtHandler(); wxEvtHandler();
virtual
~wxEvtHandler(); ~wxEvtHandler();
virtual
void QueueEvent( void QueueEvent(
wxEvent * event wxEvent * event
); );
virtual
void AddPendingEvent( void AddPendingEvent(
const wxEvent & event const wxEvent & event
); );
@@ -67,12 +190,10 @@ public:
bool enabled bool enabled
); );
virtual
void SetNextHandler( void SetNextHandler(
wxEvtHandler * handler wxEvtHandler * handler
); );
virtual
void SetPreviousHandler( void SetPreviousHandler(
wxEvtHandler * handler wxEvtHandler * handler
); );
@@ -85,6 +206,80 @@ public:
wxEvtHandler(const wxEvtHandler&); wxEvtHandler(const wxEvtHandler&);
public:
%TypeCode
void _wxEvtHandler_Connect(wxEvtHandler* self, int& _isErr, int id, int lastId, wxEventType eventType, PyObject* func)
{
if (PyCallable_Check(func)) {
self->Connect(id, lastId, eventType,
(wxObjectEventFunction)(wxEventFunction)
&wxPyCallback::EventThunker,
new wxPyCallback(func));
}
else if (func == Py_None) {
self->Disconnect(id, lastId, eventType,
(wxObjectEventFunction)(wxEventFunction)
&wxPyCallback::EventThunker);
}
else {
_isErr = 1;
PyErr_SetString(PyExc_TypeError, "Expected callable object or None.");
}
}
%End
void Connect(int id, int lastId, wxEventType eventType, SIP_PYOBJECT func);
%MethodCode
_wxEvtHandler_Connect(sipCpp, sipIsErr, id, lastId, eventType, func);
%End
%TypeCode
bool _wxEvtHandler_Disconnect(wxEvtHandler* self, int& _isErr, int id, int lastId, wxEventType eventType, PyObject* func)
{
if (func && func != Py_None) {
// Find the current matching binder that has this function
// pointer and dissconnect that one. Unfortuneatly since we
// wrapped the PyObject function pointer in another object we
// have to do the searching ourselves...
wxList::compatibility_iterator node = self->GetDynamicEventTable()->GetFirst();
while (node)
{
wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)node->GetData();
if ((entry->m_id == id) &&
((entry->m_lastId == lastId) || (lastId == wxID_ANY)) &&
((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
// FIXME?
//((entry->m_fn->IsMatching((wxObjectEventFunction)(wxEventFunction)&wxPyCallback::EventThunker))) &&
(entry->m_callbackUserData != NULL))
{
wxPyCallback *cb = (wxPyCallback*)entry->m_callbackUserData;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
int result = PyObject_Compare(cb->m_func, func);
wxPyEndBlockThreads(blocked);
if (result == 0) {
delete cb;
self->GetDynamicEventTable()->Erase(node);
delete entry;
return true;
}
}
node = node->GetNext();
}
return false;
}
else {
return self->Disconnect(id, lastId, eventType,
(wxObjectEventFunction)
&wxPyCallback::EventThunker);
}
}
%End
bool Disconnect(int id, int lastId=-1, wxEventType eventType=wxEVT_NULL, SIP_PYOBJECT func=NULL);
%MethodCode
sipRes = _wxEvtHandler_Disconnect(sipCpp, sipIsErr, id, lastId, eventType, func);
%End
}; // end of class wxEvtHandler }; // end of class wxEvtHandler
@@ -171,15 +366,10 @@ public:
int StopPropagation(); int StopPropagation();
%Property(name=EventObject, get=GetEventObject, set=SetEventObject) %Property(name=EventObject, get=GetEventObject, set=SetEventObject)
%Property(name=EventType, get=GetEventType, set=SetEventType) %Property(name=EventType, get=GetEventType, set=SetEventType)
%Property(name=Id, get=GetId, set=SetId) %Property(name=Id, get=GetId, set=SetId)
%Property(name=Skipped, get=GetSkipped) %Property(name=Skipped, get=GetSkipped)
%Property(name=Timestamp, get=GetTimestamp, set=SetTimestamp) %Property(name=Timestamp, get=GetTimestamp, set=SetTimestamp)
private: private:
wxEvent& operator=(const wxEvent&); wxEvent& operator=(const wxEvent&);
@@ -255,15 +445,10 @@ public:
%End %End
%Property(name=ClientData, get=GetClientData, set=SetClientData) %Property(name=ClientData, get=GetClientData, set=SetClientData)
%Property(name=ExtraLong, get=GetExtraLong, set=SetExtraLong) %Property(name=ExtraLong, get=GetExtraLong, set=SetExtraLong)
%Property(name=Int, get=GetInt, set=SetInt) %Property(name=Int, get=GetInt, set=SetInt)
%Property(name=Selection, get=GetSelection) %Property(name=Selection, get=GetSelection)
%Property(name=String, get=GetString, set=SetString) %Property(name=String, get=GetString, set=SetString)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -291,7 +476,6 @@ public:
bool GetActive(); bool GetActive();
%Property(name=Active, get=GetActive) %Property(name=Active, get=GetActive)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -317,7 +501,6 @@ public:
wxWindow * GetWindow(); wxWindow * GetWindow();
%Property(name=Window, get=GetWindow) %Property(name=Window, get=GetWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -411,7 +594,6 @@ public:
); );
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -463,11 +645,8 @@ public:
wxPoint GetPosition(); wxPoint GetPosition();
%Property(name=Files, get=GetFiles) %Property(name=Files, get=GetFiles)
%Property(name=NumberOfFiles, get=GetNumberOfFiles) %Property(name=NumberOfFiles, get=GetNumberOfFiles)
%Property(name=Position, get=GetPosition) %Property(name=Position, get=GetPosition)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -494,7 +673,6 @@ public:
wxDC * GetDC(); wxDC * GetDC();
%Property(name=DC, get=GetDC) %Property(name=DC, get=GetDC)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -525,7 +703,6 @@ public:
); );
%Property(name=Window, get=GetWindow, set=SetWindow) %Property(name=Window, get=GetWindow, set=SetWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -747,19 +924,12 @@ public:
wxCoord GetY(); wxCoord GetY();
%Property(name=X, get=GetX) %Property(name=X, get=GetX)
%Property(name=Y, get=GetY) %Property(name=Y, get=GetY)
%Property(name=KeyCode, get=GetKeyCode) %Property(name=KeyCode, get=GetKeyCode)
%Property(name=Position, get=GetPosition) %Property(name=Position, get=GetPosition)
%Property(name=RawKeyCode, get=GetRawKeyCode) %Property(name=RawKeyCode, get=GetRawKeyCode)
%Property(name=RawKeyFlags, get=GetRawKeyFlags) %Property(name=RawKeyFlags, get=GetRawKeyFlags)
%Property(name=UnicodeKey, get=GetUnicodeKey) %Property(name=UnicodeKey, get=GetUnicodeKey)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -813,9 +983,7 @@ public:
bool IsPopup(); bool IsPopup();
%Property(name=Menu, get=GetMenu) %Property(name=Menu, get=GetMenu)
%Property(name=MenuId, get=GetMenuId) %Property(name=MenuId, get=GetMenuId)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -842,7 +1010,6 @@ public:
wxWindow * GetCapturedWindow(); wxWindow * GetCapturedWindow();
%Property(name=CapturedWindow, get=GetCapturedWindow) %Property(name=CapturedWindow, get=GetCapturedWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -964,13 +1131,9 @@ public:
bool RightUp(); bool RightUp();
%Property(name=LinesPerAction, get=GetLinesPerAction) %Property(name=LinesPerAction, get=GetLinesPerAction)
%Property(name=LogicalPosition, get=GetLogicalPosition) %Property(name=LogicalPosition, get=GetLogicalPosition)
%Property(name=WheelDelta, get=GetWheelDelta) %Property(name=WheelDelta, get=GetWheelDelta)
%Property(name=WheelRotation, get=GetWheelRotation) %Property(name=WheelRotation, get=GetWheelRotation)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1007,9 +1170,7 @@ public:
); );
%Property(name=Rect, get=GetRect, set=SetRect) %Property(name=Rect, get=GetRect, set=SetRect)
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1071,9 +1232,7 @@ public:
); );
%Property(name=CurrentFocus, get=GetCurrentFocus, set=SetCurrentFocus) %Property(name=CurrentFocus, get=GetCurrentFocus, set=SetCurrentFocus)
%Property(name=Direction, get=GetDirection, set=SetDirection) %Property(name=Direction, get=GetDirection, set=SetDirection)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1154,7 +1313,6 @@ public:
wxWindow * GetChangedWindow(); wxWindow * GetChangedWindow();
%Property(name=ChangedWindow, get=GetChangedWindow, set=SetChangedWindow) %Property(name=ChangedWindow, get=GetChangedWindow, set=SetChangedWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1184,7 +1342,6 @@ public:
bool GetPaletteRealized(); bool GetPaletteRealized();
%Property(name=PaletteRealized, get=GetPaletteRealized, set=SetPaletteRealized) %Property(name=PaletteRealized, get=GetPaletteRealized, set=SetPaletteRealized)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1223,9 +1380,7 @@ public:
); );
%Property(name=Orientation, get=GetOrientation, set=SetOrientation) %Property(name=Orientation, get=GetOrientation, set=SetOrientation)
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1263,9 +1418,7 @@ public:
); );
%Property(name=Orientation, get=GetOrientation, set=SetOrientation) %Property(name=Orientation, get=GetOrientation, set=SetOrientation)
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1302,11 +1455,8 @@ public:
); );
%Property(name=Cursor, get=GetCursor, set=SetCursor) %Property(name=Cursor, get=GetCursor, set=SetCursor)
%Property(name=X, get=GetX) %Property(name=X, get=GetX)
%Property(name=Y, get=GetY) %Property(name=Y, get=GetY)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1337,7 +1487,6 @@ public:
bool IsShown(); bool IsShown();
%Property(name=Show, get=IsShown, set=SetShow) %Property(name=Show, get=IsShown, set=SetShow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1374,9 +1523,7 @@ public:
); );
%Property(name=Rect, get=GetRect, set=SetRect) %Property(name=Rect, get=GetRect, set=SetRect)
%Property(name=Size, get=GetSize, set=SetSize) %Property(name=Size, get=GetSize, set=SetSize)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1476,13 +1623,9 @@ public:
); );
%Property(name=Checked, get=GetChecked, set=Check) %Property(name=Checked, get=GetChecked, set=Check)
%Property(name=Enabled, get=GetEnabled, set=Enable) %Property(name=Enabled, get=GetEnabled, set=Enable)
%Property(name=Shown, get=GetShown, set=Show) %Property(name=Shown, get=GetShown, set=Show)
%Property(name=Text, get=GetText, set=SetText) %Property(name=Text, get=GetText, set=SetText)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1508,7 +1651,6 @@ public:
wxWindow * GetWindow(); wxWindow * GetWindow();
%Property(name=Window, get=GetWindow) %Property(name=Window, get=GetWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1534,7 +1676,6 @@ public:
wxWindow * GetWindow(); wxWindow * GetWindow();
%Property(name=Window, get=GetWindow) %Property(name=Window, get=GetWindow)
virtual wxEvent* Clone(); virtual wxEvent* Clone();
@@ -1841,6 +1982,300 @@ void wxQueueEvent(
wxEvent * event wxEvent * event
); );
%Extract(id=pycode)
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This code block was included from src/event_ex.py
class PyEventBinder(object):
"""
Instances of this class are used to bind specific events to event
handlers.
"""
def __init__(self, evtType, expectedIDs=0):
if expectedIDs not in [0, 1, 2]:
raise ValueError, "Invalid number of expectedIDs"
self.expectedIDs = expectedIDs
if isinstance(evtType, (list, tuple)):
self.evtType = list(evtType)
else:
self.evtType = [evtType]
def Bind(self, target, id1, id2, function):
"""Bind this set of event types to target using its COnnect() method."""
for et in self.evtType:
target.Connect(id1, id2, et, function)
def Unbind(self, target, id1, id2, handler=None):
"""Remove an event binding."""
success = 0
for et in self.evtType:
success += target.Disconnect(id1, id2, et, handler)
return success != 0
def _getEvtType(self):
"""
Make it easy to get to the default wxEventType typeID for this
event binder.
"""
return self.evtType[0]
typeId = property(_getEvtType)
def _EvtHandler_Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
"""
Bind an event to an event handler.
:param event: One of the EVT_* objects that specifies the
type of event to bind,
:param handler: A callable object to be invoked when the
event is delivered to self. Pass None to
disconnect an event handler.
:param source: Sometimes the event originates from a
different window than self, but you still
want to catch it in self. (For example, a
button event delivered to a frame.) By
passing the source of the event, the event
handling system is able to differentiate
between the same event type from different
controls.
:param id: Used to spcify the event source by ID instead
of instance.
:param id2: Used when it is desirable to bind a handler
to a range of IDs, such as with EVT_MENU_RANGE.
"""
if source is not None:
id = source.GetId()
event.Bind(self, id, id2, handler)
def _EvtHandler_Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY, handler=None):
"""
Disconnects the event handler binding for event from self.
Returns True if successful.
"""
if source is not None:
id = source.GetId()
return event.Unbind(self, id, id2, handler)
EvtHandler.Bind = _EvtHandler_Bind
EvtHandler.Unbind = _EvtHandler_Unbind
del _EvtHandler_Bind, _EvtHandler_Unbind
# Create some event binders
EVT_SIZE = wx.PyEventBinder( wxEVT_SIZE )
EVT_SIZING = wx.PyEventBinder( wxEVT_SIZING )
EVT_MOVE = wx.PyEventBinder( wxEVT_MOVE )
EVT_MOVING = wx.PyEventBinder( wxEVT_MOVING )
EVT_MOVE_START = wx.PyEventBinder( wxEVT_MOVE_START )
EVT_MOVE_END = wx.PyEventBinder( wxEVT_MOVE_END )
EVT_CLOSE = wx.PyEventBinder( wxEVT_CLOSE_WINDOW )
EVT_END_SESSION = wx.PyEventBinder( wxEVT_END_SESSION )
EVT_QUERY_END_SESSION = wx.PyEventBinder( wxEVT_QUERY_END_SESSION )
EVT_PAINT = wx.PyEventBinder( wxEVT_PAINT )
EVT_NC_PAINT = wx.PyEventBinder( wxEVT_NC_PAINT )
EVT_ERASE_BACKGROUND = wx.PyEventBinder( wxEVT_ERASE_BACKGROUND )
EVT_CHAR = wx.PyEventBinder( wxEVT_CHAR )
EVT_KEY_DOWN = wx.PyEventBinder( wxEVT_KEY_DOWN )
EVT_KEY_UP = wx.PyEventBinder( wxEVT_KEY_UP )
EVT_HOTKEY = wx.PyEventBinder( wxEVT_HOTKEY, 1)
EVT_CHAR_HOOK = wx.PyEventBinder( wxEVT_CHAR_HOOK )
EVT_MENU_OPEN = wx.PyEventBinder( wxEVT_MENU_OPEN )
EVT_MENU_CLOSE = wx.PyEventBinder( wxEVT_MENU_CLOSE )
EVT_MENU_HIGHLIGHT = wx.PyEventBinder( wxEVT_MENU_HIGHLIGHT, 1)
EVT_MENU_HIGHLIGHT_ALL = wx.PyEventBinder( wxEVT_MENU_HIGHLIGHT )
EVT_SET_FOCUS = wx.PyEventBinder( wxEVT_SET_FOCUS )
EVT_KILL_FOCUS = wx.PyEventBinder( wxEVT_KILL_FOCUS )
EVT_CHILD_FOCUS = wx.PyEventBinder( wxEVT_CHILD_FOCUS )
EVT_ACTIVATE = wx.PyEventBinder( wxEVT_ACTIVATE )
EVT_ACTIVATE_APP = wx.PyEventBinder( wxEVT_ACTIVATE_APP )
EVT_HIBERNATE = wx.PyEventBinder( wxEVT_HIBERNATE )
EVT_END_SESSION = wx.PyEventBinder( wxEVT_END_SESSION )
EVT_QUERY_END_SESSION = wx.PyEventBinder( wxEVT_QUERY_END_SESSION )
EVT_DROP_FILES = wx.PyEventBinder( wxEVT_DROP_FILES )
EVT_INIT_DIALOG = wx.PyEventBinder( wxEVT_INIT_DIALOG )
EVT_SYS_COLOUR_CHANGED = wx.PyEventBinder( wxEVT_SYS_COLOUR_CHANGED )
EVT_DISPLAY_CHANGED = wx.PyEventBinder( wxEVT_DISPLAY_CHANGED )
EVT_SHOW = wx.PyEventBinder( wxEVT_SHOW )
EVT_MAXIMIZE = wx.PyEventBinder( wxEVT_MAXIMIZE )
EVT_ICONIZE = wx.PyEventBinder( wxEVT_ICONIZE )
EVT_NAVIGATION_KEY = wx.PyEventBinder( wxEVT_NAVIGATION_KEY )
EVT_PALETTE_CHANGED = wx.PyEventBinder( wxEVT_PALETTE_CHANGED )
EVT_QUERY_NEW_PALETTE = wx.PyEventBinder( wxEVT_QUERY_NEW_PALETTE )
EVT_WINDOW_CREATE = wx.PyEventBinder( wxEVT_CREATE )
EVT_WINDOW_DESTROY = wx.PyEventBinder( wxEVT_DESTROY )
EVT_SET_CURSOR = wx.PyEventBinder( wxEVT_SET_CURSOR )
EVT_MOUSE_CAPTURE_CHANGED = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_CHANGED )
EVT_MOUSE_CAPTURE_LOST = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_LOST )
EVT_LEFT_DOWN = wx.PyEventBinder( wxEVT_LEFT_DOWN )
EVT_LEFT_UP = wx.PyEventBinder( wxEVT_LEFT_UP )
EVT_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_MIDDLE_DOWN )
EVT_MIDDLE_UP = wx.PyEventBinder( wxEVT_MIDDLE_UP )
EVT_RIGHT_DOWN = wx.PyEventBinder( wxEVT_RIGHT_DOWN )
EVT_RIGHT_UP = wx.PyEventBinder( wxEVT_RIGHT_UP )
EVT_MOTION = wx.PyEventBinder( wxEVT_MOTION )
EVT_LEFT_DCLICK = wx.PyEventBinder( wxEVT_LEFT_DCLICK )
EVT_MIDDLE_DCLICK = wx.PyEventBinder( wxEVT_MIDDLE_DCLICK )
EVT_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_RIGHT_DCLICK )
EVT_LEAVE_WINDOW = wx.PyEventBinder( wxEVT_LEAVE_WINDOW )
EVT_ENTER_WINDOW = wx.PyEventBinder( wxEVT_ENTER_WINDOW )
EVT_MOUSEWHEEL = wx.PyEventBinder( wxEVT_MOUSEWHEEL )
EVT_MOUSE_AUX1_DOWN = wx.PyEventBinder( wxEVT_AUX1_DOWN )
EVT_MOUSE_AUX1_UP = wx.PyEventBinder( wxEVT_AUX1_UP )
EVT_MOUSE_AUX1_DCLICK = wx.PyEventBinder( wxEVT_AUX1_DCLICK )
EVT_MOUSE_AUX2_DOWN = wx.PyEventBinder( wxEVT_AUX2_DOWN )
EVT_MOUSE_AUX2_UP = wx.PyEventBinder( wxEVT_AUX2_UP )
EVT_MOUSE_AUX2_DCLICK = wx.PyEventBinder( wxEVT_AUX2_DCLICK )
EVT_MOUSE_EVENTS = wx.PyEventBinder([ wxEVT_LEFT_DOWN,
wxEVT_LEFT_UP,
wxEVT_MIDDLE_DOWN,
wxEVT_MIDDLE_UP,
wxEVT_RIGHT_DOWN,
wxEVT_RIGHT_UP,
wxEVT_MOTION,
wxEVT_LEFT_DCLICK,
wxEVT_MIDDLE_DCLICK,
wxEVT_RIGHT_DCLICK,
wxEVT_ENTER_WINDOW,
wxEVT_LEAVE_WINDOW,
wxEVT_MOUSEWHEEL,
wxEVT_AUX1_DOWN,
wxEVT_AUX1_UP,
wxEVT_AUX1_DCLICK,
wxEVT_AUX2_DOWN,
wxEVT_AUX2_UP,
wxEVT_AUX2_DCLICK,
])
# Scrolling from wxWindow (sent to wxScrolledWindow)
EVT_SCROLLWIN = wx.PyEventBinder([ wxEVT_SCROLLWIN_TOP,
wxEVT_SCROLLWIN_BOTTOM,
wxEVT_SCROLLWIN_LINEUP,
wxEVT_SCROLLWIN_LINEDOWN,
wxEVT_SCROLLWIN_PAGEUP,
wxEVT_SCROLLWIN_PAGEDOWN,
wxEVT_SCROLLWIN_THUMBTRACK,
wxEVT_SCROLLWIN_THUMBRELEASE,
])
EVT_SCROLLWIN_TOP = wx.PyEventBinder( wxEVT_SCROLLWIN_TOP )
EVT_SCROLLWIN_BOTTOM = wx.PyEventBinder( wxEVT_SCROLLWIN_BOTTOM )
EVT_SCROLLWIN_LINEUP = wx.PyEventBinder( wxEVT_SCROLLWIN_LINEUP )
EVT_SCROLLWIN_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLLWIN_LINEDOWN )
EVT_SCROLLWIN_PAGEUP = wx.PyEventBinder( wxEVT_SCROLLWIN_PAGEUP )
EVT_SCROLLWIN_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLLWIN_PAGEDOWN )
EVT_SCROLLWIN_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLLWIN_THUMBTRACK )
EVT_SCROLLWIN_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLLWIN_THUMBRELEASE )
# Scrolling from wx.Slider and wx.ScrollBar
EVT_SCROLL = wx.PyEventBinder([ wxEVT_SCROLL_TOP,
wxEVT_SCROLL_BOTTOM,
wxEVT_SCROLL_LINEUP,
wxEVT_SCROLL_LINEDOWN,
wxEVT_SCROLL_PAGEUP,
wxEVT_SCROLL_PAGEDOWN,
wxEVT_SCROLL_THUMBTRACK,
wxEVT_SCROLL_THUMBRELEASE,
wxEVT_SCROLL_CHANGED,
])
EVT_SCROLL_TOP = wx.PyEventBinder( wxEVT_SCROLL_TOP )
EVT_SCROLL_BOTTOM = wx.PyEventBinder( wxEVT_SCROLL_BOTTOM )
EVT_SCROLL_LINEUP = wx.PyEventBinder( wxEVT_SCROLL_LINEUP )
EVT_SCROLL_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLL_LINEDOWN )
EVT_SCROLL_PAGEUP = wx.PyEventBinder( wxEVT_SCROLL_PAGEUP )
EVT_SCROLL_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLL_PAGEDOWN )
EVT_SCROLL_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLL_THUMBTRACK )
EVT_SCROLL_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLL_THUMBRELEASE )
EVT_SCROLL_CHANGED = wx.PyEventBinder( wxEVT_SCROLL_CHANGED )
EVT_SCROLL_ENDSCROLL = EVT_SCROLL_CHANGED
# Scrolling from wx.Slider and wx.ScrollBar, with an id
EVT_COMMAND_SCROLL = wx.PyEventBinder([ wxEVT_SCROLL_TOP,
wxEVT_SCROLL_BOTTOM,
wxEVT_SCROLL_LINEUP,
wxEVT_SCROLL_LINEDOWN,
wxEVT_SCROLL_PAGEUP,
wxEVT_SCROLL_PAGEDOWN,
wxEVT_SCROLL_THUMBTRACK,
wxEVT_SCROLL_THUMBRELEASE,
wxEVT_SCROLL_CHANGED,
], 1)
EVT_COMMAND_SCROLL_TOP = wx.PyEventBinder( wxEVT_SCROLL_TOP, 1)
EVT_COMMAND_SCROLL_BOTTOM = wx.PyEventBinder( wxEVT_SCROLL_BOTTOM, 1)
EVT_COMMAND_SCROLL_LINEUP = wx.PyEventBinder( wxEVT_SCROLL_LINEUP, 1)
EVT_COMMAND_SCROLL_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLL_LINEDOWN, 1)
EVT_COMMAND_SCROLL_PAGEUP = wx.PyEventBinder( wxEVT_SCROLL_PAGEUP, 1)
EVT_COMMAND_SCROLL_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLL_PAGEDOWN, 1)
EVT_COMMAND_SCROLL_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLL_THUMBTRACK, 1)
EVT_COMMAND_SCROLL_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLL_THUMBRELEASE, 1)
EVT_COMMAND_SCROLL_CHANGED = wx.PyEventBinder( wxEVT_SCROLL_CHANGED, 1)
EVT_COMMAND_SCROLL_ENDSCROLL = EVT_COMMAND_SCROLL_CHANGED
EVT_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_BUTTON_CLICKED, 1)
EVT_CHECKBOX = wx.PyEventBinder( wxEVT_COMMAND_CHECKBOX_CLICKED, 1)
EVT_CHOICE = wx.PyEventBinder( wxEVT_COMMAND_CHOICE_SELECTED, 1)
EVT_LISTBOX = wx.PyEventBinder( wxEVT_COMMAND_LISTBOX_SELECTED, 1)
EVT_LISTBOX_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 1)
EVT_MENU = wx.PyEventBinder( wxEVT_COMMAND_MENU_SELECTED, 1)
EVT_MENU_RANGE = wx.PyEventBinder( wxEVT_COMMAND_MENU_SELECTED, 2)
EVT_SLIDER = wx.PyEventBinder( wxEVT_COMMAND_SLIDER_UPDATED, 1)
EVT_RADIOBOX = wx.PyEventBinder( wxEVT_COMMAND_RADIOBOX_SELECTED, 1)
EVT_RADIOBUTTON = wx.PyEventBinder( wxEVT_COMMAND_RADIOBUTTON_SELECTED, 1)
EVT_SCROLLBAR = wx.PyEventBinder( wxEVT_COMMAND_SCROLLBAR_UPDATED, 1)
EVT_VLBOX = wx.PyEventBinder( wxEVT_COMMAND_VLBOX_SELECTED, 1)
EVT_COMBOBOX = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_SELECTED, 1)
EVT_TOOL = wx.PyEventBinder( wxEVT_COMMAND_TOOL_CLICKED, 1)
EVT_TOOL_RANGE = wx.PyEventBinder( wxEVT_COMMAND_TOOL_CLICKED, 2)
EVT_TOOL_RCLICKED = wx.PyEventBinder( wxEVT_COMMAND_TOOL_RCLICKED, 1)
EVT_TOOL_RCLICKED_RANGE = wx.PyEventBinder( wxEVT_COMMAND_TOOL_RCLICKED, 2)
EVT_TOOL_ENTER = wx.PyEventBinder( wxEVT_COMMAND_TOOL_ENTER, 1)
EVT_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, 1)
EVT_CHECKLISTBOX = wx.PyEventBinder( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 1)
EVT_COMBOBOX_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_DROPDOWN , 1)
EVT_COMBOBOX_CLOSEUP = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_CLOSEUP , 1)
EVT_COMMAND_LEFT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_CLICK, 1)
EVT_COMMAND_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_DCLICK, 1)
EVT_COMMAND_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_RIGHT_CLICK, 1)
EVT_COMMAND_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIGHT_DCLICK, 1)
EVT_COMMAND_SET_FOCUS = wx.PyEventBinder( wxEVT_COMMAND_SET_FOCUS, 1)
EVT_COMMAND_KILL_FOCUS = wx.PyEventBinder( wxEVT_COMMAND_KILL_FOCUS, 1)
EVT_COMMAND_ENTER = wx.PyEventBinder( wxEVT_COMMAND_ENTER, 1)
EVT_IDLE = wx.PyEventBinder( wxEVT_IDLE )
EVT_UPDATE_UI = wx.PyEventBinder( wxEVT_UPDATE_UI, 1)
EVT_UPDATE_UI_RANGE = wx.PyEventBinder( wxEVT_UPDATE_UI, 2)
EVT_CONTEXT_MENU = wx.PyEventBinder( wxEVT_CONTEXT_MENU )
EVT_TEXT_CUT = wx.PyEventBinder( wxEVT_COMMAND_TEXT_CUT )
EVT_TEXT_COPY = wx.PyEventBinder( wxEVT_COMMAND_TEXT_COPY )
EVT_TEXT_PASTE = wx.PyEventBinder( wxEVT_COMMAND_TEXT_PASTE )
EVT_THREAD = wx.PyEventBinder( wxEVT_COMMAND_THREAD )
# End of included code block
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
%End
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -207,25 +207,15 @@ public:
); );
%Property(name=Encoding, get=GetEncoding, set=SetEncoding) %Property(name=Encoding, get=GetEncoding, set=SetEncoding)
%Property(name=FaceName, get=GetFaceName, set=SetFaceName) %Property(name=FaceName, get=GetFaceName, set=SetFaceName)
%Property(name=Family, get=GetFamily, set=SetFamily) %Property(name=Family, get=GetFamily, set=SetFamily)
%Property(name=NativeFontInfoDesc, get=GetNativeFontInfoDesc, set=SetNativeFontInfo) %Property(name=NativeFontInfoDesc, get=GetNativeFontInfoDesc, set=SetNativeFontInfo)
%Property(name=NativeFontInfoUserDesc, get=GetNativeFontInfoUserDesc, set=SetNativeFontInfoUserDesc) %Property(name=NativeFontInfoUserDesc, get=GetNativeFontInfoUserDesc, set=SetNativeFontInfoUserDesc)
%Property(name=PointSize, get=GetPointSize, set=SetPointSize) %Property(name=PointSize, get=GetPointSize, set=SetPointSize)
%Property(name=PixelSize, get=GetPixelSize, set=SetPixelSize) %Property(name=PixelSize, get=GetPixelSize, set=SetPixelSize)
%Property(name=Style, get=GetStyle, set=SetStyle) %Property(name=Style, get=GetStyle, set=SetStyle)
%Property(name=Underlined, get=GetUnderlined, set=SetUnderlined) %Property(name=Underlined, get=GetUnderlined, set=SetUnderlined)
%Property(name=Weight, get=GetWeight, set=SetWeight) %Property(name=Weight, get=GetWeight, set=SetWeight)
}; // end of class wxFont }; // end of class wxFont

172
sip/gen/frame.sip Normal file
View File

@@ -0,0 +1,172 @@
//---------------------------------------------------------------------------
// This file is generated by wxPython's SIP generator. Do not edit by hand.
//
// Copyright: (c) 2010 by Total Control Software
// License: wxWindows License
//
// This file will be included by _core.sip
//
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class wxFrame : wxTopLevelWindow
{
%TypeHeaderCode
#include <wx/frame.h>
%End
public:
wxFrame();
wxFrame(
wxWindow * parent /TranserThis/,
wxWindowID id = wxID_ANY,
const wxString & title = wxEmptyString,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString & name = wxFrameNameStr
);
~wxFrame();
void Centre(
int direction = wxBOTH
);
bool Create(
wxWindow * parent /TranserThis/,
wxWindowID id = wxID_ANY,
const wxString & title = wxEmptyString,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString & name = wxFrameNameStr
);
wxStatusBar * CreateStatusBar(
int number = 1,
long style = wxSTB_DEFAULT_STYLE,
wxWindowID id = 0,
const wxString & name = wxStatusLineNameStr
);
wxToolBar * CreateToolBar(
long style = wxBORDER_NONE|wxTB_HORIZONTAL,
wxWindowID id = wxID_ANY,
const wxString & name = wxToolBarNameStr
);
virtual
wxPoint GetClientAreaOrigin();
wxMenuBar * GetMenuBar();
wxStatusBar * GetStatusBar();
int GetStatusBarPane();
wxToolBar * GetToolBar();
virtual
wxStatusBar * OnCreateStatusBar(
int number,
long style,
wxWindowID id,
const wxString & name
);
virtual
wxToolBar * OnCreateToolBar(
long style,
wxWindowID id,
const wxString & name
);
bool ProcessCommand(
int id
);
void SetMenuBar(
wxMenuBar * menuBar
);
void SetStatusBar(
wxStatusBar * statusBar
);
void SetStatusBarPane(
int n
);
void SetStatusText(
const wxString & text,
int number = 0
);
void SetStatusWidths(
int n /ArraySize/,
const int * widths_field /Array/
);
void SetToolBar(
wxToolBar * toolBar
);
void PushStatusText(
const wxString & text,
int number = 0
);
void PopStatusText(
int number = 0
);
%Property(name=MenuBar, get=GetMenuBar, set=SetMenuBar)
%Property(name=StatusBar, get=GetStatusBar, set=SetStatusBar)
%Property(name=StatusBarPane, get=GetStatusBarPane, set=SetStatusBarPane)
%Property(name=ToolBar, get=GetToolBar, set=SetToolBar)
public:
virtual bool Validate();
virtual bool TransferDataToWindow();
virtual bool TransferDataFromWindow();
virtual void InitDialog();
virtual bool AcceptsFocus() const;
virtual bool AcceptsFocusRecursively() const;
virtual bool AcceptsFocusFromKeyboard() const;
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
virtual void InheritAttributes();
virtual bool ShouldInheritColours() const;
virtual bool HasTransparentBackground();
virtual void OnInternalIdle();
virtual wxWindow *GetMainWindowOfCompositeControl();
protected:
virtual bool ProcessEvent(wxEvent & event);
virtual void DoEnable(bool enable);
virtual void OnEnabled(bool enabled);
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetClientSize(int *width, int *height) const;
virtual wxSize DoGetBestSize() const;
virtual wxSize DoGetBestClientSize() const;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
virtual void DoSetClientSize(int width, int height);
virtual void DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH );
virtual wxSize DoGetBorderSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoSetWindowVariant( wxWindowVariant variant);
virtual wxBorder GetDefaultBorder() const;
virtual wxBorder GetDefaultBorderForControl() const;
}; // end of class wxFrame
//---------------------------------------------------------------------------

View File

@@ -286,9 +286,7 @@ public:
); );
%Property(name=width, get=GetWidth, set=SetWidth) %Property(name=width, get=GetWidth, set=SetWidth)
%Property(name=height, get=GetHeight, set=SetHeight) %Property(name=height, get=GetHeight, set=SetHeight)
%TypeCode %TypeCode
PyObject* _wxSize_Get(wxSize* self, int& _isErr) PyObject* _wxSize_Get(wxSize* self, int& _isErr)
{ {
@@ -575,21 +573,13 @@ public:
); );
%Property(name=left, get=GetLeft) %Property(name=left, get=GetLeft)
%Property(name=top, get=GetTop) %Property(name=top, get=GetTop)
%Property(name=right, get=GetRight) %Property(name=right, get=GetRight)
%Property(name=bottom, get=GetBottom) %Property(name=bottom, get=GetBottom)
%Property(name=bottomLeft, get=GetBottomLeft) %Property(name=bottomLeft, get=GetBottomLeft)
%Property(name=bottomRight, get=GetBottomRight) %Property(name=bottomRight, get=GetBottomRight)
%Property(name=topLeft, get=GetTopLeft) %Property(name=topLeft, get=GetTopLeft)
%Property(name=topRight, get=GetTopRight) %Property(name=topRight, get=GetTopRight)
%TypeCode %TypeCode
PyObject* _wxRect_Get(wxRect* self, int& _isErr) PyObject* _wxRect_Get(wxRect* self, int& _isErr)
{ {

View File

@@ -56,15 +56,10 @@ public:
); );
%Property(name=controlDown, get=ControlDown, set=SetControlDown) %Property(name=controlDown, get=ControlDown, set=SetControlDown)
%Property(name=shiftDown, get=ShiftDown, set=SetShiftDown) %Property(name=shiftDown, get=ShiftDown, set=SetShiftDown)
%Property(name=altDown, get=AltDown, set=SetAltDown) %Property(name=altDown, get=AltDown, set=SetAltDown)
%Property(name=metaDown, get=MetaDown, set=SetMetaDown) %Property(name=metaDown, get=MetaDown, set=SetMetaDown)
%Property(name=cmdDown, get=CmdDown) %Property(name=cmdDown, get=CmdDown)
}; // end of class wxKeyboardState }; // end of class wxKeyboardState

View File

@@ -126,21 +126,13 @@ public:
); );
%Property(name=Done, get=GetDone, set=SetDone) %Property(name=Done, get=GetDone, set=SetDone)
%Property(name=Margin, get=GetMargin, set=SetMargin) %Property(name=Margin, get=GetMargin, set=SetMargin)
%Property(name=MyEdge, get=GetMyEdge) %Property(name=MyEdge, get=GetMyEdge)
%Property(name=OtherEdge, get=GetOtherEdge) %Property(name=OtherEdge, get=GetOtherEdge)
%Property(name=OtherWindow, get=GetOtherWindow) %Property(name=OtherWindow, get=GetOtherWindow)
%Property(name=Percent, get=GetPercent) %Property(name=Percent, get=GetPercent)
%Property(name=Relationship, get=GetRelationship, set=SetRelationship) %Property(name=Relationship, get=GetRelationship, set=SetRelationship)
%Property(name=Value, get=GetValue, set=SetValue) %Property(name=Value, get=GetValue, set=SetValue)
}; // end of class wxIndividualLayoutConstraint }; // end of class wxIndividualLayoutConstraint

View File

@@ -73,21 +73,13 @@ public:
); );
%Property(name=x, get=GetX, set=SetX) %Property(name=x, get=GetX, set=SetX)
%Property(name=y, get=GetY, set=SetY) %Property(name=y, get=GetY, set=SetY)
%Property(name=leftIsDown, get=LeftIsDown, set=SetLeftDown) %Property(name=leftIsDown, get=LeftIsDown, set=SetLeftDown)
%Property(name=middleIsDown, get=MiddleIsDown, set=SetMiddleDown) %Property(name=middleIsDown, get=MiddleIsDown, set=SetMiddleDown)
%Property(name=rightIsDown, get=RightIsDown, set=SetRightDown) %Property(name=rightIsDown, get=RightIsDown, set=SetRightDown)
%Property(name=aux1IsDown, get=Aux1IsDown, set=SetAux1Down) %Property(name=aux1IsDown, get=Aux1IsDown, set=SetAux1Down)
%Property(name=aux2IsDown, get=Aux2IsDown, set=SetAux2Down) %Property(name=aux2IsDown, get=Aux2IsDown, set=SetAux2Down)
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
}; // end of class wxMouseState }; // end of class wxMouseState

View File

@@ -26,6 +26,10 @@ public:
void IncRef(); void IncRef();
private:
wxRefCounter(const wxRefCounter&);
protected: protected:
virtual virtual

View File

@@ -71,19 +71,12 @@ public:
%End %End
%Property(name=H, get=GetH) %Property(name=H, get=GetH)
%Property(name=Height, get=GetHeight) %Property(name=Height, get=GetHeight)
%Property(name=Rect, get=GetRect) %Property(name=Rect, get=GetRect)
%Property(name=W, get=GetW) %Property(name=W, get=GetW)
%Property(name=Width, get=GetWidth) %Property(name=Width, get=GetWidth)
%Property(name=X, get=GetX) %Property(name=X, get=GetX)
%Property(name=Y, get=GetY) %Property(name=Y, get=GetY)
}; // end of class wxRegionIterator }; // end of class wxRegionIterator
@@ -240,7 +233,6 @@ public:
); );
%Property(name=Box, get=GetBox) %Property(name=Box, get=GetBox)
}; // end of class wxRegion }; // end of class wxRegion

View File

@@ -51,8 +51,10 @@ public:
); );
%Property(name=Tip, get=GetTip, set=SetTip) %Property(name=Tip, get=GetTip, set=SetTip)
%Property(name=Window, get=GetWindow) %Property(name=Window, get=GetWindow)
private:
wxToolTip(const wxToolTip&);
}; // end of class wxToolTip }; // end of class wxToolTip

View File

@@ -30,7 +30,6 @@ public:
const wxString & name = wxFrameNameStr const wxString & name = wxFrameNameStr
); );
virtual
~wxTopLevelWindow(); ~wxTopLevelWindow();
bool Create( bool Create(
@@ -43,7 +42,6 @@ public:
const wxString & name = wxFrameNameStr const wxString & name = wxFrameNameStr
); );
virtual
bool CanSetTransparent(); bool CanSetTransparent();
void CenterOnScreen( void CenterOnScreen(
@@ -54,7 +52,6 @@ public:
int direction = wxBOTH int direction = wxBOTH
); );
virtual
bool EnableCloseButton( bool EnableCloseButton(
bool enable = true bool enable = true
); );
@@ -65,38 +62,28 @@ public:
const wxIconBundle & GetIcons(); const wxIconBundle & GetIcons();
virtual
wxString GetTitle(); wxString GetTitle();
virtual
void Iconize( void Iconize(
bool iconize = true bool iconize = true
); );
virtual
bool IsActive(); bool IsActive();
virtual
bool IsAlwaysMaximized(); bool IsAlwaysMaximized();
virtual
bool IsFullScreen(); bool IsFullScreen();
virtual
bool IsIconized(); bool IsIconized();
virtual
bool IsMaximized(); bool IsMaximized();
virtual
bool Layout(); bool Layout();
virtual
void Maximize( void Maximize(
bool maximize = true bool maximize = true
); );
virtual
void RequestUserAttention( void RequestUserAttention(
int flags = wxUSER_ATTENTION_INFO int flags = wxUSER_ATTENTION_INFO
); );
@@ -115,27 +102,22 @@ public:
const wxIcon & icon const wxIcon & icon
); );
virtual
void SetIcons( void SetIcons(
const wxIconBundle & icons const wxIconBundle & icons
); );
virtual
void SetMaxSize( void SetMaxSize(
const wxSize & size const wxSize & size
); );
virtual
void SetMinSize( void SetMinSize(
const wxSize & size const wxSize & size
); );
virtual
bool SetShape( bool SetShape(
const wxRegion & region const wxRegion & region
); );
virtual
void SetSizeHints( void SetSizeHints(
int minW, int minW,
int minH, int minH,
@@ -145,35 +127,28 @@ public:
int incH = -1 int incH = -1
); );
virtual
void SetSizeHints( void SetSizeHints(
const wxSize & minSize, const wxSize & minSize,
const wxSize & maxSize = wxDefaultSize, const wxSize & maxSize = wxDefaultSize,
const wxSize & incSize = wxDefaultSize const wxSize & incSize = wxDefaultSize
); );
virtual
void SetTitle( void SetTitle(
const wxString & title const wxString & title
); );
virtual
bool SetTransparent( bool SetTransparent(
wxByte alpha wxByte alpha
); );
virtual
bool ShouldPreventAppExit(); bool ShouldPreventAppExit();
virtual
void OSXSetModified( void OSXSetModified(
bool modified bool modified
); );
virtual
bool OSXIsModified(); bool OSXIsModified();
virtual
bool ShowFullScreen( bool ShowFullScreen(
bool show, bool show,
long style = wxFULLSCREEN_ALL long style = wxFULLSCREEN_ALL
@@ -236,14 +211,46 @@ public:
%End %End
%Property(name=DefaultItem, get=GetDefaultItem, set=SetDefaultItem) %Property(name=DefaultItem, get=GetDefaultItem, set=SetDefaultItem)
%Property(name=Icon, get=GetIcon, set=SetIcon) %Property(name=Icon, get=GetIcon, set=SetIcon)
%Property(name=Title, get=GetTitle, set=SetTitle) %Property(name=Title, get=GetTitle, set=SetTitle)
%Property(name=TmpDefaultItem, get=GetTmpDefaultItem, set=SetTmpDefaultItem) %Property(name=TmpDefaultItem, get=GetTmpDefaultItem, set=SetTmpDefaultItem)
%Property(name=OSXModified, get=OSXIsModified, set=OSXSetModified) %Property(name=OSXModified, get=OSXIsModified, set=OSXSetModified)
public:
virtual wxPoint GetClientAreaOrigin() const;
virtual bool Validate();
virtual bool TransferDataToWindow();
virtual bool TransferDataFromWindow();
virtual void InitDialog();
virtual bool AcceptsFocus() const;
virtual bool AcceptsFocusRecursively() const;
virtual bool AcceptsFocusFromKeyboard() const;
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
virtual void InheritAttributes();
virtual bool ShouldInheritColours() const;
virtual bool HasTransparentBackground();
virtual void OnInternalIdle();
virtual wxWindow *GetMainWindowOfCompositeControl();
protected:
virtual bool ProcessEvent(wxEvent & event);
virtual void DoEnable(bool enable);
virtual void OnEnabled(bool enabled);
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetClientSize(int *width, int *height) const;
virtual wxSize DoGetBestSize() const;
virtual wxSize DoGetBestClientSize() const;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
virtual void DoSetClientSize(int width, int height);
virtual void DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH );
virtual wxSize DoGetBorderSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoSetWindowVariant( wxWindowVariant variant);
virtual wxBorder GetDefaultBorder() const;
virtual wxBorder GetDefaultBorderForControl() const;
}; // end of class wxTopLevelWindow }; // end of class wxTopLevelWindow

View File

@@ -25,7 +25,15 @@ struct wxVisualAttributes
}; // end of class wxVisualAttributes }; // end of class wxVisualAttributes
class wxWindow : wxEvtHandler class wxWindowBase : wxEvtHandler /Abstract/
{
public:
virtual void AddChild( wxWindowBase* child );
virtual void RemoveChild( wxWindowBase* child );
};
class wxWindow : wxWindowBase
{ {
%TypeHeaderCode %TypeHeaderCode
#include <wx/window.h> #include <wx/window.h>
@@ -76,7 +84,6 @@ public:
const wxString & name = wxPanelNameStr const wxString & name = wxPanelNameStr
); );
virtual
~wxWindow(); ~wxWindow();
virtual virtual
@@ -88,23 +95,19 @@ public:
virtual virtual
bool AcceptsFocusRecursively(); bool AcceptsFocusRecursively();
virtual
bool HasFocus(); bool HasFocus();
virtual
void SetCanFocus( void SetCanFocus(
bool canFocus bool canFocus
); );
virtual
void SetFocus(); void SetFocus();
virtual
void SetFocusFromKbd(); void SetFocusFromKbd();
virtual virtual
void AddChild( void AddChild(
wxWindow * child wxWindowBase* child
); );
bool DestroyChildren(); bool DestroyChildren();
@@ -121,7 +124,7 @@ public:
virtual virtual
void RemoveChild( void RemoveChild(
wxWindow * child wxWindowBase* child
); );
wxWindow * GetGrandParent(); wxWindow * GetGrandParent();
@@ -132,28 +135,23 @@ public:
wxWindow * GetPrevSibling(); wxWindow * GetPrevSibling();
virtual
bool Reparent( bool Reparent(
wxWindow * newParent wxWindow * newParent
); );
virtual
void AlwaysShowScrollbars( void AlwaysShowScrollbars(
bool hflag = true, bool hflag = true,
bool vflag = true bool vflag = true
); );
virtual
int GetScrollPos( int GetScrollPos(
int orientation int orientation
); );
virtual
int GetScrollRange( int GetScrollRange(
int orientation int orientation
); );
virtual
int GetScrollThumb( int GetScrollThumb(
int orientation int orientation
); );
@@ -166,22 +164,18 @@ public:
int orient int orient
); );
virtual
bool IsScrollbarAlwaysShown( bool IsScrollbarAlwaysShown(
int orient int orient
); );
virtual
bool ScrollLines( bool ScrollLines(
int lines int lines
); );
virtual
bool ScrollPages( bool ScrollPages(
int pages int pages
); );
virtual
void ScrollWindow( void ScrollWindow(
int dx, int dx,
int dy, int dy,
@@ -196,14 +190,12 @@ public:
bool PageDown(); bool PageDown();
virtual
void SetScrollPos( void SetScrollPos(
int orientation, int orientation,
int pos, int pos,
bool refresh = true bool refresh = true
); );
virtual
void SetScrollbar( void SetScrollbar(
int orientation, int orientation,
int position, int position,
@@ -216,39 +208,30 @@ public:
const wxSize & size const wxSize & size
); );
virtual
wxSize ClientToWindowSize( wxSize ClientToWindowSize(
const wxSize & size const wxSize & size
); );
virtual
wxSize WindowToClientSize( wxSize WindowToClientSize(
const wxSize & size const wxSize & size
); );
virtual
void Fit(); void Fit();
virtual
void FitInside(); void FitInside();
wxSize GetBestSize(); wxSize GetBestSize();
wxSize GetClientSize(); wxSize GetClientSize();
virtual
wxSize GetEffectiveMinSize(); wxSize GetEffectiveMinSize();
virtual
wxSize GetMaxClientSize(); wxSize GetMaxClientSize();
virtual
wxSize GetMaxSize(); wxSize GetMaxSize();
virtual
wxSize GetMinClientSize(); wxSize GetMinClientSize();
virtual
wxSize GetMinSize(); wxSize GetMinSize();
int GetMinWidth(); int GetMinWidth();
@@ -263,13 +246,10 @@ public:
wxSize GetVirtualSize(); wxSize GetVirtualSize();
virtual
wxSize GetBestVirtualSize(); wxSize GetBestVirtualSize();
virtual
wxSize GetWindowBorderSize(); wxSize GetWindowBorderSize();
virtual
bool InformFirstDirection( bool InformFirstDirection(
int direction, int direction,
int size, int size,
@@ -282,7 +262,6 @@ public:
void PostSizeEventToParent(); void PostSizeEventToParent();
virtual
void SendSizeEvent( void SendSizeEvent(
int flags = 0 int flags = 0
); );
@@ -312,22 +291,18 @@ public:
const wxSize & size = wxDefaultSize const wxSize & size = wxDefaultSize
); );
virtual
void SetMaxClientSize( void SetMaxClientSize(
const wxSize & size const wxSize & size
); );
virtual
void SetMaxSize( void SetMaxSize(
const wxSize & size const wxSize & size
); );
virtual
void SetMinClientSize( void SetMinClientSize(
const wxSize & size const wxSize & size
); );
virtual
void SetMinSize( void SetMinSize(
const wxSize & size const wxSize & size
); );
@@ -353,14 +328,12 @@ public:
int height int height
); );
virtual
void SetSizeHints( void SetSizeHints(
const wxSize & minSize, const wxSize & minSize,
const wxSize & maxSize = wxDefaultSize, const wxSize & maxSize = wxDefaultSize,
const wxSize & incSize = wxDefaultSize const wxSize & incSize = wxDefaultSize
); );
virtual
void SetSizeHints( void SetSizeHints(
int minW, int minW,
int minH, int minH,
@@ -447,7 +420,6 @@ public:
const wxPoint & pt const wxPoint & pt
); );
virtual
void ClearBackground(); void ClearBackground();
void Freeze(); void Freeze();
@@ -458,16 +430,12 @@ public:
wxColour GetBackgroundColour(); wxColour GetBackgroundColour();
virtual
wxBackgroundStyle GetBackgroundStyle(); wxBackgroundStyle GetBackgroundStyle();
virtual
int GetCharHeight(); int GetCharHeight();
virtual
int GetCharWidth(); int GetCharWidth();
virtual
wxVisualAttributes GetDefaultAttributes(); wxVisualAttributes GetDefaultAttributes();
wxFont GetFont(); wxFont GetFont();
@@ -494,7 +462,6 @@ public:
virtual virtual
bool HasTransparentBackground(); bool HasTransparentBackground();
virtual
void Refresh( void Refresh(
bool eraseBackground = true, bool eraseBackground = true,
const wxRect * rect = NULL const wxRect * rect = NULL
@@ -505,25 +472,20 @@ public:
bool eraseBackground = true bool eraseBackground = true
); );
virtual
void Update(); void Update();
virtual
bool SetBackgroundColour( bool SetBackgroundColour(
const wxColour & colour const wxColour & colour
); );
virtual
bool SetBackgroundStyle( bool SetBackgroundStyle(
wxBackgroundStyle style wxBackgroundStyle style
); );
virtual
bool SetFont( bool SetFont(
const wxFont & font const wxFont & font
); );
virtual
bool SetForegroundColour( bool SetForegroundColour(
const wxColour & colour const wxColour & colour
); );
@@ -547,18 +509,14 @@ public:
virtual virtual
bool ShouldInheritColours(); bool ShouldInheritColours();
virtual
void SetThemeEnabled( void SetThemeEnabled(
bool enable bool enable
); );
virtual
bool GetThemeEnabled(); bool GetThemeEnabled();
virtual
bool CanSetTransparent(); bool CanSetTransparent();
virtual
bool SetTransparent( bool SetTransparent(
wxByte alpha wxByte alpha
); );
@@ -597,19 +555,16 @@ public:
wxEvtHandler * handler wxEvtHandler * handler
); );
virtual
void SetNextHandler( void SetNextHandler(
wxEvtHandler * handler wxEvtHandler * handler
); );
virtual
void SetPreviousHandler( void SetPreviousHandler(
wxEvtHandler * handler wxEvtHandler * handler
); );
long GetExtraStyle(); long GetExtraStyle();
virtual
long GetWindowStyleFlag(); long GetWindowStyleFlag();
long GetWindowStyle(); long GetWindowStyle();
@@ -622,12 +577,10 @@ public:
int flag int flag
); );
virtual
void SetExtraStyle( void SetExtraStyle(
long exStyle long exStyle
); );
virtual
void SetWindowStyleFlag( void SetWindowStyleFlag(
long style long style
); );
@@ -656,15 +609,12 @@ public:
int flags = wxNavigationKeyEvent::IsForward int flags = wxNavigationKeyEvent::IsForward
); );
virtual
void Lower(); void Lower();
virtual
void Raise(); void Raise();
bool Hide(); bool Hide();
virtual
bool HideWithEffect( bool HideWithEffect(
wxShowEffect effect, wxShowEffect effect,
unsigned int timeout = 0 unsigned int timeout = 0
@@ -692,25 +642,20 @@ public:
wxRect & rect wxRect & rect
); );
virtual
bool IsShown(); bool IsShown();
virtual
bool IsShownOnScreen(); bool IsShownOnScreen();
bool Disable(); bool Disable();
virtual
bool Enable( bool Enable(
bool enable = true bool enable = true
); );
virtual
bool Show( bool Show(
bool show = true bool show = true
); );
virtual
bool ShowWithEffect( bool ShowWithEffect(
wxShowEffect effect, wxShowEffect effect,
unsigned int timeout = 0 unsigned int timeout = 0
@@ -722,7 +667,6 @@ public:
const wxString & helpText const wxString & helpText
); );
virtual
wxString GetHelpTextAtPoint( wxString GetHelpTextAtPoint(
const wxPoint & point, const wxPoint & point,
wxHelpEvent::Origin origin wxHelpEvent::Origin origin
@@ -764,10 +708,8 @@ public:
int y int y
); );
virtual
wxValidator * GetValidator(); wxValidator * GetValidator();
virtual
void SetValidator( void SetValidator(
const wxValidator & validator const wxValidator & validator
); );
@@ -783,13 +725,10 @@ public:
wxWindowID GetId(); wxWindowID GetId();
virtual
wxString GetLabel(); wxString GetLabel();
virtual
wxLayoutDirection GetLayoutDirection(); wxLayoutDirection GetLayoutDirection();
virtual
wxString GetName(); wxString GetName();
wxWindowVariant GetWindowVariant(); wxWindowVariant GetWindowVariant();
@@ -798,17 +737,14 @@ public:
wxWindowID winid wxWindowID winid
); );
virtual
void SetLabel( void SetLabel(
const wxString & label const wxString & label
); );
virtual
void SetLayoutDirection( void SetLayoutDirection(
wxLayoutDirection dir wxLayoutDirection dir
); );
virtual
void SetName( void SetName(
const wxString & name const wxString & name
); );
@@ -819,7 +755,6 @@ public:
wxAcceleratorTable * GetAcceleratorTable(); wxAcceleratorTable * GetAcceleratorTable();
virtual
void SetAcceleratorTable( void SetAcceleratorTable(
const wxAcceleratorTable & accel const wxAcceleratorTable & accel
); );
@@ -828,20 +763,16 @@ public:
bool force = false bool force = false
); );
virtual bool Destroy() /TranserThis/;
bool Destroy();
bool IsBeingDeleted(); bool IsBeingDeleted();
virtual
wxDropTarget * GetDropTarget(); wxDropTarget * GetDropTarget();
virtual
void SetDropTarget( void SetDropTarget(
wxDropTarget * target /Transfer/ wxDropTarget * target /Transfer/
); );
virtual
void DragAcceptFiles( void DragAcceptFiles(
bool accept bool accept
); );
@@ -866,7 +797,6 @@ public:
wxLayoutConstraints * constraints /Transfer/ wxLayoutConstraints * constraints /Transfer/
); );
virtual
bool Layout(); bool Layout();
void SetAutoLayout( void SetAutoLayout(
@@ -881,7 +811,6 @@ public:
const wxCursor & GetCursor(); const wxCursor & GetCursor();
virtual
bool HasCapture(); bool HasCapture();
void ReleaseMouse(); void ReleaseMouse();
@@ -890,12 +819,10 @@ public:
wxCaret * caret /Transfer/ wxCaret * caret /Transfer/
); );
virtual
bool SetCursor( bool SetCursor(
const wxCursor & cursor const wxCursor & cursor
); );
virtual
void WarpPointer( void WarpPointer(
int x, int x,
int y int y
@@ -916,18 +843,15 @@ public:
wxBorder GetBorder(); wxBorder GetBorder();
virtual
void DoUpdateWindowUI( void DoUpdateWindowUI(
wxUpdateUIEvent & event wxUpdateUIEvent & event
); );
virtual
void* GetHandle(); void* GetHandle();
%MethodCode %MethodCode
sipRes = wxPyGetWinHandle(sipCpp); sipRes = wxPyGetWinHandle(sipCpp);
%End %End
virtual
bool HasMultiplePages(); bool HasMultiplePages();
virtual virtual
@@ -936,7 +860,6 @@ public:
virtual virtual
void InitDialog(); void InitDialog();
virtual
bool IsDoubleBuffered(); bool IsDoubleBuffered();
void SetDoubleBuffered( void SetDoubleBuffered(
@@ -948,15 +871,12 @@ public:
#endif #endif
%End %End
virtual
bool IsRetained(); bool IsRetained();
bool IsThisEnabled(); bool IsThisEnabled();
virtual
bool IsTopLevel(); bool IsTopLevel();
virtual
void MakeModal( void MakeModal(
bool modal = true bool modal = true
); );
@@ -988,7 +908,6 @@ public:
#endif #endif
%End %End
virtual
void UpdateWindowUI( void UpdateWindowUI(
long flags = wxUPDATE_UI_NONE long flags = wxUPDATE_UI_NONE
); );
@@ -1084,138 +1003,90 @@ public:
%End %End
%Property(name=AcceleratorTable, get=GetAcceleratorTable, set=SetAcceleratorTable) %Property(name=AcceleratorTable, get=GetAcceleratorTable, set=SetAcceleratorTable)
%Property(name=AutoLayout, get=GetAutoLayout, set=SetAutoLayout) %Property(name=AutoLayout, get=GetAutoLayout, set=SetAutoLayout)
%Property(name=BackgroundColour, get=GetBackgroundColour, set=SetBackgroundColour) %Property(name=BackgroundColour, get=GetBackgroundColour, set=SetBackgroundColour)
%Property(name=BackgroundStyle, get=GetBackgroundStyle, set=SetBackgroundStyle) %Property(name=BackgroundStyle, get=GetBackgroundStyle, set=SetBackgroundStyle)
%Property(name=EffectiveMinSize, get=GetEffectiveMinSize) %Property(name=EffectiveMinSize, get=GetEffectiveMinSize)
%Property(name=BestSize, get=GetBestSize) %Property(name=BestSize, get=GetBestSize)
%Property(name=BestVirtualSize, get=GetBestVirtualSize) %Property(name=BestVirtualSize, get=GetBestVirtualSize)
%Property(name=Border, get=GetBorder) %Property(name=Border, get=GetBorder)
%Property(name=Caret, get=GetCaret, set=SetCaret) %Property(name=Caret, get=GetCaret, set=SetCaret)
%Property(name=CharHeight, get=GetCharHeight) %Property(name=CharHeight, get=GetCharHeight)
%Property(name=CharWidth, get=GetCharWidth) %Property(name=CharWidth, get=GetCharWidth)
%Property(name=Children, get=GetChildren) %Property(name=Children, get=GetChildren)
%Property(name=ClientAreaOrigin, get=GetClientAreaOrigin) %Property(name=ClientAreaOrigin, get=GetClientAreaOrigin)
%Property(name=ClientRect, get=GetClientRect, set=SetClientRect) %Property(name=ClientRect, get=GetClientRect, set=SetClientRect)
%Property(name=ClientSize, get=GetClientSize, set=SetClientSize) %Property(name=ClientSize, get=GetClientSize, set=SetClientSize)
%Property(name=Constraints, get=GetConstraints, set=SetConstraints) %Property(name=Constraints, get=GetConstraints, set=SetConstraints)
%Property(name=ContainingSizer, get=GetContainingSizer, set=SetContainingSizer) %Property(name=ContainingSizer, get=GetContainingSizer, set=SetContainingSizer)
%Property(name=Cursor, get=GetCursor, set=SetCursor) %Property(name=Cursor, get=GetCursor, set=SetCursor)
%Property(name=DefaultAttributes, get=GetDefaultAttributes) %Property(name=DefaultAttributes, get=GetDefaultAttributes)
%Property(name=DropTarget, get=GetDropTarget, set=SetDropTarget) %Property(name=DropTarget, get=GetDropTarget, set=SetDropTarget)
%Property(name=EventHandler, get=GetEventHandler, set=SetEventHandler) %Property(name=EventHandler, get=GetEventHandler, set=SetEventHandler)
%Property(name=ExtraStyle, get=GetExtraStyle, set=SetExtraStyle) %Property(name=ExtraStyle, get=GetExtraStyle, set=SetExtraStyle)
%Property(name=Font, get=GetFont, set=SetFont) %Property(name=Font, get=GetFont, set=SetFont)
%Property(name=ForegroundColour, get=GetForegroundColour, set=SetForegroundColour) %Property(name=ForegroundColour, get=GetForegroundColour, set=SetForegroundColour)
%Property(name=GrandParent, get=GetGrandParent) %Property(name=GrandParent, get=GetGrandParent)
%Property(name=TopLevelParent, get=GetTopLevelParent) %Property(name=TopLevelParent, get=GetTopLevelParent)
%Property(name=Handle, get=GetHandle) %Property(name=Handle, get=GetHandle)
%Property(name=HelpText, get=GetHelpText, set=SetHelpText) %Property(name=HelpText, get=GetHelpText, set=SetHelpText)
%Property(name=Id, get=GetId, set=SetId) %Property(name=Id, get=GetId, set=SetId)
%Property(name=Label, get=GetLabel, set=SetLabel) %Property(name=Label, get=GetLabel, set=SetLabel)
%Property(name=LayoutDirection, get=GetLayoutDirection, set=SetLayoutDirection) %Property(name=LayoutDirection, get=GetLayoutDirection, set=SetLayoutDirection)
%Property(name=MaxHeight, get=GetMaxHeight) %Property(name=MaxHeight, get=GetMaxHeight)
%Property(name=MaxSize, get=GetMaxSize, set=SetMaxSize) %Property(name=MaxSize, get=GetMaxSize, set=SetMaxSize)
%Property(name=MaxWidth, get=GetMaxWidth) %Property(name=MaxWidth, get=GetMaxWidth)
%Property(name=MinHeight, get=GetMinHeight) %Property(name=MinHeight, get=GetMinHeight)
%Property(name=MinSize, get=GetMinSize, set=SetMinSize) %Property(name=MinSize, get=GetMinSize, set=SetMinSize)
%Property(name=MinWidth, get=GetMinWidth) %Property(name=MinWidth, get=GetMinWidth)
%Property(name=Name, get=GetName, set=SetName) %Property(name=Name, get=GetName, set=SetName)
%Property(name=Parent, get=GetParent) %Property(name=Parent, get=GetParent)
%Property(name=Position, get=GetPosition, set=SetPosition) %Property(name=Position, get=GetPosition, set=SetPosition)
%Property(name=Rect, get=GetRect, set=SetRect) %Property(name=Rect, get=GetRect, set=SetRect)
%Property(name=ScreenPosition, get=GetScreenPosition) %Property(name=ScreenPosition, get=GetScreenPosition)
%Property(name=ScreenRect, get=GetScreenRect) %Property(name=ScreenRect, get=GetScreenRect)
%Property(name=Size, get=GetSize, set=SetSize) %Property(name=Size, get=GetSize, set=SetSize)
%Property(name=Sizer, get=GetSizer, set=SetSizer) %Property(name=Sizer, get=GetSizer, set=SetSizer)
%Property(name=ThemeEnabled, get=GetThemeEnabled, set=SetThemeEnabled) %Property(name=ThemeEnabled, get=GetThemeEnabled, set=SetThemeEnabled)
%Property(name=ToolTip, get=GetToolTip, set=SetToolTip) %Property(name=ToolTip, get=GetToolTip, set=SetToolTip)
%Property(name=UpdateClientRect, get=GetUpdateClientRect) %Property(name=UpdateClientRect, get=GetUpdateClientRect)
%Property(name=UpdateRegion, get=GetUpdateRegion) %Property(name=UpdateRegion, get=GetUpdateRegion)
%Property(name=Validator, get=GetValidator, set=SetValidator) %Property(name=Validator, get=GetValidator, set=SetValidator)
%Property(name=VirtualSize, get=GetVirtualSize, set=SetVirtualSize) %Property(name=VirtualSize, get=GetVirtualSize, set=SetVirtualSize)
%Property(name=WindowStyle, get=GetWindowStyle, set=SetWindowStyle) %Property(name=WindowStyle, get=GetWindowStyle, set=SetWindowStyle)
%Property(name=WindowStyleFlag, get=GetWindowStyleFlag, set=SetWindowStyleFlag) %Property(name=WindowStyleFlag, get=GetWindowStyleFlag, set=SetWindowStyleFlag)
%Property(name=WindowVariant, get=GetWindowVariant, set=SetWindowVariant) %Property(name=WindowVariant, get=GetWindowVariant, set=SetWindowVariant)
%Property(name=Shown, get=IsShown, set=Show) %Property(name=Shown, get=IsShown, set=Show)
%Property(name=Enabled, get=IsEnabled, set=Enable) %Property(name=Enabled, get=IsEnabled, set=Enable)
%Property(name=TopLevel, get=IsTopLevel) %Property(name=TopLevel, get=IsTopLevel)
%Property(name=MinClientSize, get=GetMinClientSize, set=SetMinClientSize) %Property(name=MinClientSize, get=GetMinClientSize, set=SetMinClientSize)
%Property(name=MaxClientSize, get=GetMaxClientSize, set=SetMaxClientSize) %Property(name=MaxClientSize, get=GetMaxClientSize, set=SetMaxClientSize)
public:
virtual wxWindow *GetMainWindowOfCompositeControl();
protected:
virtual void DoEnable(bool enable);
virtual void OnEnabled(bool enabled);
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetClientSize(int *width, int *height) const;
virtual wxSize DoGetBestClientSize() const;
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
virtual void DoSetClientSize(int width, int height);
virtual void DoSetSizeHints( int minW, int minH, int maxW, int maxH, int incW, int incH );
virtual wxSize DoGetBorderSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoSetWindowVariant( wxWindowVariant variant);
virtual wxBorder GetDefaultBorder() const;
virtual wxBorder GetDefaultBorderForControl() const;
protected: protected:
virtual
void DoCentre(
int direction
);
virtual virtual
wxSize DoGetBestSize(); wxSize DoGetBestSize();
virtual
void SetInitialBestSize(
const wxSize & size
);
void SendDestroyEvent(); void SendDestroyEvent();
virtual virtual
@@ -1227,7 +1098,7 @@ protected:
%Extract(id=pycode) %Extract(id=pycode)
def _Window_PostCreate(): def _Window_PostCreate(self, pre):
pass pass
Window.PostCreate = _Window_PostCreate Window.PostCreate = _Window_PostCreate
del _Window_PostCreate del _Window_PostCreate
@@ -1268,6 +1139,23 @@ wxWindow * wxGetTopLevelParent(
wxWindow * window wxWindow * window
); );
%Extract(id=pycode)
class FrozenWindow(object):
"""
A context manager to be used with Python 'with' statements
that will freeze the given window for the duration of the
with block.
"""
def __init__(self, window):
self._win = window
def __enter__(self):
self._win.Freeze()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self._win.Thaw()
%End
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -55,7 +55,7 @@ extern "C" {
* Define the SIP version number. * Define the SIP version number.
*/ */
#define SIP_VERSION 0x040c00 #define SIP_VERSION 0x040c00
#define SIP_VERSION_STR "4.12-snapshot-b2f993d3a067" #define SIP_VERSION_STR "4.12-snapshot-40a042b3abce"
/* /*
@@ -69,6 +69,7 @@ extern "C" {
* History: * History:
* *
* 8.1 Revised the sipVariableDef structure. * 8.1 Revised the sipVariableDef structure.
* sip_api_get_address() is now part of the public API.
* *
* 8.0 Changed the size of the sipSimpleWrapper structure. * 8.0 Changed the size of the sipSimpleWrapper structure.
* Added sip_api_get_address(). * Added sip_api_get_address().
@@ -1448,6 +1449,9 @@ typedef struct _sipAPIDef {
PyObject *sipKwdArgs, const char **kwdlist, PyObject **unused, PyObject *sipKwdArgs, const char **kwdlist, PyObject **unused,
const char *fmt, ...); const char *fmt, ...);
void (*api_add_exception)(sipErrorState es, PyObject **parseErrp); void (*api_add_exception)(sipErrorState es, PyObject **parseErrp);
/*
* The following are part of the public API.
*/
void *(*api_get_address)(struct _sipSimpleWrapper *w); void *(*api_get_address)(struct _sipSimpleWrapper *w);
} sipAPIDef; } sipAPIDef;

View File

@@ -363,6 +363,9 @@ static const sipAPIDef sip_api = {
sip_api_keep_reference, sip_api_keep_reference,
sip_api_parse_kwd_args, sip_api_parse_kwd_args,
sip_api_add_exception, sip_api_add_exception,
/*
* The following are part of the public API.
*/
sip_api_get_address sip_api_get_address
}; };

View File

@@ -69,6 +69,7 @@ public:
virtual void OnPreInit() { } virtual void OnPreInit() { }
void _BootstrapApp(); void _BootstrapApp();
virtual int MainLoop();
static bool IsDisplayAvailable(); static bool IsDisplayAvailable();
@@ -93,32 +94,32 @@ void wxPyApp::_BootstrapApp()
static bool haveInitialized = false; static bool haveInitialized = false;
bool result; bool result;
wxPyBlock_t blocked; wxPyBlock_t blocked;
PyObject* retval = NULL;
PyObject* pyint = NULL;
// Only initialize wxWidgets once // Only initialize wxWidgets once
if (! haveInitialized) { if (! haveInitialized) {
// Get any command-line args passed to this program from the sys module
// Copy the values in Python's sys.argv list to a C array of char* to
// be passed to the wxEntryStart function below.
int argc = 0; int argc = 0;
char** argv = NULL; char** argv = NULL;
blocked = wxPyBeginBlockThreads(); blocked = wxPyBeginBlockThreads();
PyObject* sysargv = PySys_GetObject("argv"); PyObject* sysargv = PySys_GetObject("argv");
PyObject* executable = PySys_GetObject("executable"); if (sysargv != NULL) {
argc = PyList_Size(sysargv);
if (sysargv != NULL && executable != NULL) {
argc = PyList_Size(sysargv) + 1;
argv = new char*[argc+1]; argv = new char*[argc+1];
argv[0] = strdup(PyString_AsString(executable));
int x; int x;
for(x=1; x<argc; x++) { for(x=0; x<argc; x++) {
PyObject *pyArg = PyList_GetItem(sysargv, x-1); PyObject *pyArg = PyList_GetItem(sysargv, x); // borrowed reference
// if there isn't anything in sys.argv[0] then set it to the python executable
if (x == 0 && PyObject_Length(pyArg) < 1)
pyArg = PySys_GetObject("executable");
argv[x] = strdup(PyString_AsString(pyArg)); argv[x] = strdup(PyString_AsString(pyArg));
} }
argv[argc] = NULL; argv[argc] = NULL;
} }
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
// Initialize wxWidgets // Initialize wxWidgets
#ifdef __WXOSX__ #ifdef __WXOSX__
wxMacAutoreleasePool autoreleasePool; wxMacAutoreleasePool autoreleasePool;
@@ -159,6 +160,28 @@ error:
} }
int wxPyApp::MainLoop()
{
int retval = 0;
{
#ifdef __WXOSX__
wxMacAutoreleasePool autoreleasePool;
#endif
DeletePendingObjects();
}
bool initialized = wxTopLevelWindows.GetCount() != 0;
if (initialized) {
if ( m_exitOnFrameDelete == Later ) {
m_exitOnFrameDelete = Yes;
}
retval = wxApp::MainLoop();
OnExit();
}
return retval;
}
// Function to test if the Display (or whatever is the platform equivallent) // Function to test if the Display (or whatever is the platform equivallent)
// can be connected to. This is accessable from wxPython as a staticmethod of // can be connected to. This is accessable from wxPython as a staticmethod of

View File

@@ -188,6 +188,7 @@ logged in on the main display of your Mac."""
def __del__(self): def __del__(self):
self.RestoreStdio() # Just in case the MainLoop was overridden self.RestoreStdio() # Just in case the MainLoop was overridden
def Destroy(self): def Destroy(self):
## self.this.own(False) ## self.this.own(False)
wx.PyApp.Destroy(self) wx.PyApp.Destroy(self)

View File

@@ -1,5 +1,4 @@
# A little trick to make 'wx' be a reference to this module so wx.Names can # A little trick to make 'wx' be a reference to this module so wx.Names can
# be used in the python code here. # be used in the python code here.
import sys as _sys import sys as _sys
@@ -42,7 +41,7 @@ def deprecated(func):
def new_func(*args, **kwargs): def new_func(*args, **kwargs):
import warnings import warnings
warnings.warn("Call to deprecated item %s." % func.__name__, warnings.warn("Call to deprecated item %s." % func.__name__,
category=DeprecationWarning) DeprecationWarning, stacklevel=2)
return func(*args, **kwargs) return func(*args, **kwargs)
new_func.__name__ = func.__name__ new_func.__name__ = func.__name__
new_func.__doc__ = func.__doc__ new_func.__doc__ = func.__doc__

124
src/event_ex.cpp Normal file
View File

@@ -0,0 +1,124 @@
class wxPyCallback : public wxEvtHandler {
DECLARE_ABSTRACT_CLASS(wxPyCallback)
public:
wxPyCallback(PyObject* func);
wxPyCallback(const wxPyCallback& other);
~wxPyCallback();
void EventThunker(wxEvent& event);
PyObject* m_func;
};
IMPLEMENT_ABSTRACT_CLASS(wxPyCallback, wxEvtHandler);
wxPyCallback::wxPyCallback(PyObject* func) {
m_func = func;
Py_INCREF(m_func);
}
wxPyCallback::wxPyCallback(const wxPyCallback& other) {
m_func = other.m_func;
Py_INCREF(m_func);
}
wxPyCallback::~wxPyCallback() {
wxPyBlock_t blocked = wxPyBeginBlockThreads();
Py_DECREF(m_func);
wxPyEndBlockThreads(blocked);
}
// #define wxPy_PRECALLINIT "_preCallInit"
// #define wxPy_POSTCALLCLEANUP "_postCallCleanup"
// This function is used for all events destined for Python event handlers.
void wxPyCallback::EventThunker(wxEvent& event) {
wxPyCallback* cb = (wxPyCallback*)event.m_callbackUserData;
PyObject* func = cb->m_func;
PyObject* result;
PyObject* arg;
PyObject* tuple;
bool checkSkip = false;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
wxString className = event.GetClassInfo()->GetClassName();
// // If the event is one of these types then pass the original
// // event object instead of the one passed to us.
// if ( className == wxT("wxPyEvent") ) {
// arg = ((wxPyEvent*)&event)->GetSelf();
// checkSkip = ((wxPyEvent*)&event)->GetCloned();
// }
// else if ( className == wxT("wxPyCommandEvent") ) {
// arg = ((wxPyCommandEvent*)&event)->GetSelf();
// checkSkip = ((wxPyCommandEvent*)&event)->GetCloned();
// }
// else {
arg = wxPyConstructObject((void*)&event, className);
// }
if (!arg) {
PyErr_Print();
} else {
// // "intern" the pre/post method names to speed up the HasAttr
// static PyObject* s_preName = NULL;
// static PyObject* s_postName = NULL;
// if (s_preName == NULL) {
// s_preName = PyString_FromString(wxPy_PRECALLINIT);
// s_postName = PyString_FromString(wxPy_POSTCALLCLEANUP);
// }
// // Check if the event object needs some preinitialization
// if (PyObject_HasAttr(arg, s_preName)) {
// result = PyObject_CallMethodObjArgs(arg, s_preName, arg, NULL);
// if ( result ) {
// Py_DECREF(result); // result is ignored, but we still need to decref it
// PyErr_Clear(); // Just in case...
// } else {
// PyErr_Print();
// }
// }
// Call the event handler, passing the event object
tuple = PyTuple_New(1);
PyTuple_SET_ITEM(tuple, 0, arg); // steals ref to arg
result = PyEval_CallObject(func, tuple);
if ( result ) {
Py_DECREF(result); // result is ignored, but we still need to decref it
PyErr_Clear(); // Just in case...
} else {
PyErr_Print();
}
// // Check if the event object needs some post cleanup
// if (PyObject_HasAttr(arg, s_postName)) {
// result = PyObject_CallMethodObjArgs(arg, s_postName, arg, NULL);
// if ( result ) {
// Py_DECREF(result); // result is ignored, but we still need to decref it
// PyErr_Clear(); // Just in case...
// } else {
// PyErr_Print();
// }
// }
// if ( checkSkip ) {
// // if the event object was one of our special types and
// // it had been cloned, then we need to extract the Skipped
// // value from the original and set it in the clone.
// result = PyObject_CallMethod(arg, "GetSkipped", "");
// if ( result ) {
// event.Skip(PyInt_AsLong(result));
// Py_DECREF(result);
// } else {
// PyErr_Print();
// }
// }
Py_DECREF(tuple);
}
wxPyEndBlockThreads(blocked);
}

285
src/event_ex.py Normal file
View File

@@ -0,0 +1,285 @@
class PyEventBinder(object):
"""
Instances of this class are used to bind specific events to event
handlers.
"""
def __init__(self, evtType, expectedIDs=0):
if expectedIDs not in [0, 1, 2]:
raise ValueError, "Invalid number of expectedIDs"
self.expectedIDs = expectedIDs
if isinstance(evtType, (list, tuple)):
self.evtType = list(evtType)
else:
self.evtType = [evtType]
def Bind(self, target, id1, id2, function):
"""Bind this set of event types to target using its COnnect() method."""
for et in self.evtType:
target.Connect(id1, id2, et, function)
def Unbind(self, target, id1, id2, handler=None):
"""Remove an event binding."""
success = 0
for et in self.evtType:
success += target.Disconnect(id1, id2, et, handler)
return success != 0
def _getEvtType(self):
"""
Make it easy to get to the default wxEventType typeID for this
event binder.
"""
return self.evtType[0]
typeId = property(_getEvtType)
def _EvtHandler_Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
"""
Bind an event to an event handler.
:param event: One of the EVT_* objects that specifies the
type of event to bind,
:param handler: A callable object to be invoked when the
event is delivered to self. Pass None to
disconnect an event handler.
:param source: Sometimes the event originates from a
different window than self, but you still
want to catch it in self. (For example, a
button event delivered to a frame.) By
passing the source of the event, the event
handling system is able to differentiate
between the same event type from different
controls.
:param id: Used to spcify the event source by ID instead
of instance.
:param id2: Used when it is desirable to bind a handler
to a range of IDs, such as with EVT_MENU_RANGE.
"""
if source is not None:
id = source.GetId()
event.Bind(self, id, id2, handler)
def _EvtHandler_Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY, handler=None):
"""
Disconnects the event handler binding for event from self.
Returns True if successful.
"""
if source is not None:
id = source.GetId()
return event.Unbind(self, id, id2, handler)
EvtHandler.Bind = _EvtHandler_Bind
EvtHandler.Unbind = _EvtHandler_Unbind
del _EvtHandler_Bind, _EvtHandler_Unbind
# Create some event binders
EVT_SIZE = wx.PyEventBinder( wxEVT_SIZE )
EVT_SIZING = wx.PyEventBinder( wxEVT_SIZING )
EVT_MOVE = wx.PyEventBinder( wxEVT_MOVE )
EVT_MOVING = wx.PyEventBinder( wxEVT_MOVING )
EVT_MOVE_START = wx.PyEventBinder( wxEVT_MOVE_START )
EVT_MOVE_END = wx.PyEventBinder( wxEVT_MOVE_END )
EVT_CLOSE = wx.PyEventBinder( wxEVT_CLOSE_WINDOW )
EVT_END_SESSION = wx.PyEventBinder( wxEVT_END_SESSION )
EVT_QUERY_END_SESSION = wx.PyEventBinder( wxEVT_QUERY_END_SESSION )
EVT_PAINT = wx.PyEventBinder( wxEVT_PAINT )
EVT_NC_PAINT = wx.PyEventBinder( wxEVT_NC_PAINT )
EVT_ERASE_BACKGROUND = wx.PyEventBinder( wxEVT_ERASE_BACKGROUND )
EVT_CHAR = wx.PyEventBinder( wxEVT_CHAR )
EVT_KEY_DOWN = wx.PyEventBinder( wxEVT_KEY_DOWN )
EVT_KEY_UP = wx.PyEventBinder( wxEVT_KEY_UP )
EVT_HOTKEY = wx.PyEventBinder( wxEVT_HOTKEY, 1)
EVT_CHAR_HOOK = wx.PyEventBinder( wxEVT_CHAR_HOOK )
EVT_MENU_OPEN = wx.PyEventBinder( wxEVT_MENU_OPEN )
EVT_MENU_CLOSE = wx.PyEventBinder( wxEVT_MENU_CLOSE )
EVT_MENU_HIGHLIGHT = wx.PyEventBinder( wxEVT_MENU_HIGHLIGHT, 1)
EVT_MENU_HIGHLIGHT_ALL = wx.PyEventBinder( wxEVT_MENU_HIGHLIGHT )
EVT_SET_FOCUS = wx.PyEventBinder( wxEVT_SET_FOCUS )
EVT_KILL_FOCUS = wx.PyEventBinder( wxEVT_KILL_FOCUS )
EVT_CHILD_FOCUS = wx.PyEventBinder( wxEVT_CHILD_FOCUS )
EVT_ACTIVATE = wx.PyEventBinder( wxEVT_ACTIVATE )
EVT_ACTIVATE_APP = wx.PyEventBinder( wxEVT_ACTIVATE_APP )
EVT_HIBERNATE = wx.PyEventBinder( wxEVT_HIBERNATE )
EVT_END_SESSION = wx.PyEventBinder( wxEVT_END_SESSION )
EVT_QUERY_END_SESSION = wx.PyEventBinder( wxEVT_QUERY_END_SESSION )
EVT_DROP_FILES = wx.PyEventBinder( wxEVT_DROP_FILES )
EVT_INIT_DIALOG = wx.PyEventBinder( wxEVT_INIT_DIALOG )
EVT_SYS_COLOUR_CHANGED = wx.PyEventBinder( wxEVT_SYS_COLOUR_CHANGED )
EVT_DISPLAY_CHANGED = wx.PyEventBinder( wxEVT_DISPLAY_CHANGED )
EVT_SHOW = wx.PyEventBinder( wxEVT_SHOW )
EVT_MAXIMIZE = wx.PyEventBinder( wxEVT_MAXIMIZE )
EVT_ICONIZE = wx.PyEventBinder( wxEVT_ICONIZE )
EVT_NAVIGATION_KEY = wx.PyEventBinder( wxEVT_NAVIGATION_KEY )
EVT_PALETTE_CHANGED = wx.PyEventBinder( wxEVT_PALETTE_CHANGED )
EVT_QUERY_NEW_PALETTE = wx.PyEventBinder( wxEVT_QUERY_NEW_PALETTE )
EVT_WINDOW_CREATE = wx.PyEventBinder( wxEVT_CREATE )
EVT_WINDOW_DESTROY = wx.PyEventBinder( wxEVT_DESTROY )
EVT_SET_CURSOR = wx.PyEventBinder( wxEVT_SET_CURSOR )
EVT_MOUSE_CAPTURE_CHANGED = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_CHANGED )
EVT_MOUSE_CAPTURE_LOST = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_LOST )
EVT_LEFT_DOWN = wx.PyEventBinder( wxEVT_LEFT_DOWN )
EVT_LEFT_UP = wx.PyEventBinder( wxEVT_LEFT_UP )
EVT_MIDDLE_DOWN = wx.PyEventBinder( wxEVT_MIDDLE_DOWN )
EVT_MIDDLE_UP = wx.PyEventBinder( wxEVT_MIDDLE_UP )
EVT_RIGHT_DOWN = wx.PyEventBinder( wxEVT_RIGHT_DOWN )
EVT_RIGHT_UP = wx.PyEventBinder( wxEVT_RIGHT_UP )
EVT_MOTION = wx.PyEventBinder( wxEVT_MOTION )
EVT_LEFT_DCLICK = wx.PyEventBinder( wxEVT_LEFT_DCLICK )
EVT_MIDDLE_DCLICK = wx.PyEventBinder( wxEVT_MIDDLE_DCLICK )
EVT_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_RIGHT_DCLICK )
EVT_LEAVE_WINDOW = wx.PyEventBinder( wxEVT_LEAVE_WINDOW )
EVT_ENTER_WINDOW = wx.PyEventBinder( wxEVT_ENTER_WINDOW )
EVT_MOUSEWHEEL = wx.PyEventBinder( wxEVT_MOUSEWHEEL )
EVT_MOUSE_AUX1_DOWN = wx.PyEventBinder( wxEVT_AUX1_DOWN )
EVT_MOUSE_AUX1_UP = wx.PyEventBinder( wxEVT_AUX1_UP )
EVT_MOUSE_AUX1_DCLICK = wx.PyEventBinder( wxEVT_AUX1_DCLICK )
EVT_MOUSE_AUX2_DOWN = wx.PyEventBinder( wxEVT_AUX2_DOWN )
EVT_MOUSE_AUX2_UP = wx.PyEventBinder( wxEVT_AUX2_UP )
EVT_MOUSE_AUX2_DCLICK = wx.PyEventBinder( wxEVT_AUX2_DCLICK )
EVT_MOUSE_EVENTS = wx.PyEventBinder([ wxEVT_LEFT_DOWN,
wxEVT_LEFT_UP,
wxEVT_MIDDLE_DOWN,
wxEVT_MIDDLE_UP,
wxEVT_RIGHT_DOWN,
wxEVT_RIGHT_UP,
wxEVT_MOTION,
wxEVT_LEFT_DCLICK,
wxEVT_MIDDLE_DCLICK,
wxEVT_RIGHT_DCLICK,
wxEVT_ENTER_WINDOW,
wxEVT_LEAVE_WINDOW,
wxEVT_MOUSEWHEEL,
wxEVT_AUX1_DOWN,
wxEVT_AUX1_UP,
wxEVT_AUX1_DCLICK,
wxEVT_AUX2_DOWN,
wxEVT_AUX2_UP,
wxEVT_AUX2_DCLICK,
])
# Scrolling from wxWindow (sent to wxScrolledWindow)
EVT_SCROLLWIN = wx.PyEventBinder([ wxEVT_SCROLLWIN_TOP,
wxEVT_SCROLLWIN_BOTTOM,
wxEVT_SCROLLWIN_LINEUP,
wxEVT_SCROLLWIN_LINEDOWN,
wxEVT_SCROLLWIN_PAGEUP,
wxEVT_SCROLLWIN_PAGEDOWN,
wxEVT_SCROLLWIN_THUMBTRACK,
wxEVT_SCROLLWIN_THUMBRELEASE,
])
EVT_SCROLLWIN_TOP = wx.PyEventBinder( wxEVT_SCROLLWIN_TOP )
EVT_SCROLLWIN_BOTTOM = wx.PyEventBinder( wxEVT_SCROLLWIN_BOTTOM )
EVT_SCROLLWIN_LINEUP = wx.PyEventBinder( wxEVT_SCROLLWIN_LINEUP )
EVT_SCROLLWIN_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLLWIN_LINEDOWN )
EVT_SCROLLWIN_PAGEUP = wx.PyEventBinder( wxEVT_SCROLLWIN_PAGEUP )
EVT_SCROLLWIN_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLLWIN_PAGEDOWN )
EVT_SCROLLWIN_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLLWIN_THUMBTRACK )
EVT_SCROLLWIN_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLLWIN_THUMBRELEASE )
# Scrolling from wx.Slider and wx.ScrollBar
EVT_SCROLL = wx.PyEventBinder([ wxEVT_SCROLL_TOP,
wxEVT_SCROLL_BOTTOM,
wxEVT_SCROLL_LINEUP,
wxEVT_SCROLL_LINEDOWN,
wxEVT_SCROLL_PAGEUP,
wxEVT_SCROLL_PAGEDOWN,
wxEVT_SCROLL_THUMBTRACK,
wxEVT_SCROLL_THUMBRELEASE,
wxEVT_SCROLL_CHANGED,
])
EVT_SCROLL_TOP = wx.PyEventBinder( wxEVT_SCROLL_TOP )
EVT_SCROLL_BOTTOM = wx.PyEventBinder( wxEVT_SCROLL_BOTTOM )
EVT_SCROLL_LINEUP = wx.PyEventBinder( wxEVT_SCROLL_LINEUP )
EVT_SCROLL_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLL_LINEDOWN )
EVT_SCROLL_PAGEUP = wx.PyEventBinder( wxEVT_SCROLL_PAGEUP )
EVT_SCROLL_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLL_PAGEDOWN )
EVT_SCROLL_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLL_THUMBTRACK )
EVT_SCROLL_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLL_THUMBRELEASE )
EVT_SCROLL_CHANGED = wx.PyEventBinder( wxEVT_SCROLL_CHANGED )
EVT_SCROLL_ENDSCROLL = EVT_SCROLL_CHANGED
# Scrolling from wx.Slider and wx.ScrollBar, with an id
EVT_COMMAND_SCROLL = wx.PyEventBinder([ wxEVT_SCROLL_TOP,
wxEVT_SCROLL_BOTTOM,
wxEVT_SCROLL_LINEUP,
wxEVT_SCROLL_LINEDOWN,
wxEVT_SCROLL_PAGEUP,
wxEVT_SCROLL_PAGEDOWN,
wxEVT_SCROLL_THUMBTRACK,
wxEVT_SCROLL_THUMBRELEASE,
wxEVT_SCROLL_CHANGED,
], 1)
EVT_COMMAND_SCROLL_TOP = wx.PyEventBinder( wxEVT_SCROLL_TOP, 1)
EVT_COMMAND_SCROLL_BOTTOM = wx.PyEventBinder( wxEVT_SCROLL_BOTTOM, 1)
EVT_COMMAND_SCROLL_LINEUP = wx.PyEventBinder( wxEVT_SCROLL_LINEUP, 1)
EVT_COMMAND_SCROLL_LINEDOWN = wx.PyEventBinder( wxEVT_SCROLL_LINEDOWN, 1)
EVT_COMMAND_SCROLL_PAGEUP = wx.PyEventBinder( wxEVT_SCROLL_PAGEUP, 1)
EVT_COMMAND_SCROLL_PAGEDOWN = wx.PyEventBinder( wxEVT_SCROLL_PAGEDOWN, 1)
EVT_COMMAND_SCROLL_THUMBTRACK = wx.PyEventBinder( wxEVT_SCROLL_THUMBTRACK, 1)
EVT_COMMAND_SCROLL_THUMBRELEASE = wx.PyEventBinder( wxEVT_SCROLL_THUMBRELEASE, 1)
EVT_COMMAND_SCROLL_CHANGED = wx.PyEventBinder( wxEVT_SCROLL_CHANGED, 1)
EVT_COMMAND_SCROLL_ENDSCROLL = EVT_COMMAND_SCROLL_CHANGED
EVT_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_BUTTON_CLICKED, 1)
EVT_CHECKBOX = wx.PyEventBinder( wxEVT_COMMAND_CHECKBOX_CLICKED, 1)
EVT_CHOICE = wx.PyEventBinder( wxEVT_COMMAND_CHOICE_SELECTED, 1)
EVT_LISTBOX = wx.PyEventBinder( wxEVT_COMMAND_LISTBOX_SELECTED, 1)
EVT_LISTBOX_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, 1)
EVT_MENU = wx.PyEventBinder( wxEVT_COMMAND_MENU_SELECTED, 1)
EVT_MENU_RANGE = wx.PyEventBinder( wxEVT_COMMAND_MENU_SELECTED, 2)
EVT_SLIDER = wx.PyEventBinder( wxEVT_COMMAND_SLIDER_UPDATED, 1)
EVT_RADIOBOX = wx.PyEventBinder( wxEVT_COMMAND_RADIOBOX_SELECTED, 1)
EVT_RADIOBUTTON = wx.PyEventBinder( wxEVT_COMMAND_RADIOBUTTON_SELECTED, 1)
EVT_SCROLLBAR = wx.PyEventBinder( wxEVT_COMMAND_SCROLLBAR_UPDATED, 1)
EVT_VLBOX = wx.PyEventBinder( wxEVT_COMMAND_VLBOX_SELECTED, 1)
EVT_COMBOBOX = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_SELECTED, 1)
EVT_TOOL = wx.PyEventBinder( wxEVT_COMMAND_TOOL_CLICKED, 1)
EVT_TOOL_RANGE = wx.PyEventBinder( wxEVT_COMMAND_TOOL_CLICKED, 2)
EVT_TOOL_RCLICKED = wx.PyEventBinder( wxEVT_COMMAND_TOOL_RCLICKED, 1)
EVT_TOOL_RCLICKED_RANGE = wx.PyEventBinder( wxEVT_COMMAND_TOOL_RCLICKED, 2)
EVT_TOOL_ENTER = wx.PyEventBinder( wxEVT_COMMAND_TOOL_ENTER, 1)
EVT_TOOL_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED, 1)
EVT_CHECKLISTBOX = wx.PyEventBinder( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, 1)
EVT_COMBOBOX_DROPDOWN = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_DROPDOWN , 1)
EVT_COMBOBOX_CLOSEUP = wx.PyEventBinder( wxEVT_COMMAND_COMBOBOX_CLOSEUP , 1)
EVT_COMMAND_LEFT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_CLICK, 1)
EVT_COMMAND_LEFT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_LEFT_DCLICK, 1)
EVT_COMMAND_RIGHT_CLICK = wx.PyEventBinder( wxEVT_COMMAND_RIGHT_CLICK, 1)
EVT_COMMAND_RIGHT_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_RIGHT_DCLICK, 1)
EVT_COMMAND_SET_FOCUS = wx.PyEventBinder( wxEVT_COMMAND_SET_FOCUS, 1)
EVT_COMMAND_KILL_FOCUS = wx.PyEventBinder( wxEVT_COMMAND_KILL_FOCUS, 1)
EVT_COMMAND_ENTER = wx.PyEventBinder( wxEVT_COMMAND_ENTER, 1)
EVT_IDLE = wx.PyEventBinder( wxEVT_IDLE )
EVT_UPDATE_UI = wx.PyEventBinder( wxEVT_UPDATE_UI, 1)
EVT_UPDATE_UI_RANGE = wx.PyEventBinder( wxEVT_UPDATE_UI, 2)
EVT_CONTEXT_MENU = wx.PyEventBinder( wxEVT_CONTEXT_MENU )
EVT_TEXT_CUT = wx.PyEventBinder( wxEVT_COMMAND_TEXT_CUT )
EVT_TEXT_COPY = wx.PyEventBinder( wxEVT_COMMAND_TEXT_COPY )
EVT_TEXT_PASTE = wx.PyEventBinder( wxEVT_COMMAND_TEXT_PASTE )
EVT_THREAD = wx.PyEventBinder( wxEVT_COMMAND_THREAD )

View File

@@ -62,6 +62,12 @@ inline void wxPyEndBlockThreads(wxPyBlock_t blocked) {
PyGILState_Release(blocked); PyGILState_Release(blocked);
} }
PyObject* wxPyConstructObject(void* ptr,
const wxString& className,
int setThisOwn=0);
%End %End
@@ -101,4 +107,16 @@ inline void wxPyEndBlockThreads(wxPyBlock_t blocked) {
Py_DECREF(uni); // release the temporary Unicode object we created Py_DECREF(uni); // release the temporary Unicode object we created
return target; return target;
} }
PyObject* wxPyConstructObject(void* ptr,
const wxString& className,
int setThisOwn)
{
const sipTypeDef* td = sipFindType(className);
if (!td)
return NULL;
PyObject* transferObj = setThisOwn ? Py_None : NULL;
return sipConvertFromType(ptr, td, transferObj);
}
%End %End

View File

@@ -1,6 +1,7 @@
import unittest2 import unittest2
import wxPhoenix as wx import wxPhoenix as wx
import warnings
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -10,12 +11,10 @@ class App(unittest2.TestCase):
app = wx.App() app = wx.App()
def test_App_OnInit(self): def test_App_OnInit(self):
class MyApp(wx.App): class MyApp(wx.App):
def OnInit(self): def OnInit(self):
self.onInit_called = True self.onInit_called = True
return True return True
app = MyApp() app = MyApp()
self.assertTrue(app.onInit_called) self.assertTrue(app.onInit_called)
@@ -23,7 +22,11 @@ class App(unittest2.TestCase):
v = wx.version() v = wx.version()
def test_PySimpleApp(self): def test_PySimpleApp(self):
app = wx.PySimpleApp() # wx.PySimpleApp is supposed to be deprecated, make sure it is.
with warnings.catch_warnings():
warnings.simplefilter("error")
with self.assertRaises(DeprecationWarning):
app = wx.PySimpleApp()
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------

View File

@@ -123,6 +123,20 @@ class Events(unittest2.TestCase):
evt = wx.WindowDestroyEvent() evt = wx.WindowDestroyEvent()
def test_eventBinding(self):
class Frame(wx.Frame):
def __init__(self, *args, **kw):
wx.Frame.__init__(self, *args, **kw)
self.Bind(wx.EVT_SIZE, self.onSize)
self.gotEvent = False
def onSize(self, evt):
self.gotEvent = True
evt.EventObject.Close()
app = wx.App()
frm = Frame(None)
frm.Show()
app.MainLoop()
self.assertTrue(frm.gotEvent)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------