FileBrowseButton now has history, updated demo
Added ActiveXWrapper and demos. It can't do callback events yet, but I'm working on it. Can curently embed a control and make method calls to it. Updated the wxCalendar (python version) and it's demo. It now has printing support. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7136 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
83
utils/wxPython/lib/activexwrapper.py
Normal file
83
utils/wxPython/lib/activexwrapper.py
Normal file
@@ -0,0 +1,83 @@
|
||||
#----------------------------------------------------------------------
|
||||
# Name: wxPython.lib.activexwrapper
|
||||
# Purpose: a wxWindow derived class that can hold an ActiveX control
|
||||
#
|
||||
# Author: Mike Fletcher, Robin Dunn
|
||||
#
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 2000 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
try:
|
||||
import win32ui
|
||||
except ImportError:
|
||||
raise ImportError( "Cannot find win32ui module, wxWindows ActiveXControl module cannot be loaded")
|
||||
|
||||
### Following makes it possible to include this module without
|
||||
# needing to include the (rather large) win32con module...
|
||||
##from win32con import WS_TABSTOP, WS_VISIBLE
|
||||
WS_TABSTOP = 0x10000
|
||||
WS_VISIBLE = 0x10000000
|
||||
|
||||
class ActiveXWrapper( wxWindow ):
|
||||
"""
|
||||
Class providing easy integration of ActiveXControls into
|
||||
wxPython GUI environments. Pass an instantiated control class (one
|
||||
which inherits from pywin.mfc.activex.Control and a particular control
|
||||
class generated by gencache) in the argument "control". Alternatively,
|
||||
pass the instantiated control to the SetControl method to allow for
|
||||
specifying the win32 style, id, etceteras
|
||||
"""
|
||||
def __init__( self, parent, ID=-1, pos = wxDefaultPosition, size = wxDefaultSize,
|
||||
style = 0,
|
||||
name = "ActiveXControlWindow",
|
||||
control = None,
|
||||
controlName = "Control",
|
||||
eraseBackground = 1,
|
||||
):
|
||||
wxWindow.__init__( self, parent, ID, pos, size, style, name )
|
||||
win32ui.EnableControlContainer()
|
||||
self.windowPointer = win32ui.CreateWindowFromHandle(self.GetHandle())
|
||||
if control:
|
||||
self.SetControl( control, name )
|
||||
EVT_SIZE( self, self.OnSize)
|
||||
if not eraseBackground:
|
||||
def nullfunction( event ): pass
|
||||
EVT_ERASE_BACKGROUND( self, nullfunction )
|
||||
|
||||
|
||||
def SetControl( self, controlObject, name="Control",
|
||||
style=WS_TABSTOP | WS_VISIBLE, ID=None):
|
||||
"""
|
||||
Pass a pre-built control object, calls the control's
|
||||
CreateControl method with the proper arguments to make it a
|
||||
child of this window
|
||||
"""
|
||||
self.control = controlObject
|
||||
w,h = self.GetSizeTuple()
|
||||
if not ID:
|
||||
ID = wxNewId()
|
||||
self.control.CreateControl( name, style, (0,0,w,h),
|
||||
self.windowPointer,
|
||||
ID)
|
||||
|
||||
|
||||
def Cleanup( self ):
|
||||
"""Delete the reference to the control, to ensure that it is dereferenced."""
|
||||
self.control = None
|
||||
self.windowPointer = None
|
||||
|
||||
def OnSize( self, event=None ):
|
||||
"""wxPython resize event, call MoveWindow on the control"""
|
||||
size = self.GetClientSize()
|
||||
self.control.MoveWindow( (0,0,size.width,size.height),1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user