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:
Robin Dunn
2000-04-12 03:06:57 +00:00
parent 7b84e4c356
commit aaca0586f2
11 changed files with 757 additions and 128 deletions

View File

@@ -0,0 +1,127 @@
"""
ActiveXControl sample usage.
Based on original code by Willy Heineman, wheineman@uconect.net, 14 February 2000
ActiveXControl provides a simplified wrapper for creating activeX
controls within wxPython GUIs. It allows you to include the activeX
control in a sizer, and includes a flag to prevent redrawing the
background behind the control (reduces the annoying flicker on
Win32 systems).
"""
from wxPython.wx import *
from wxPython.lib.activexwrapper import ActiveXWrapper
import pythoncom
import pywin.mfc.activex
import win32com.client.gencache
import win32con
import win32ui
acrobatOCX = win32com.client.gencache.EnsureModule('{CA8A9783-280D-11CF-A24D-444553540000}', 0x0, 1, 3)
if acrobatOCX is None:
win32ui.MessageBox("Can't load PDF.OCX, install Acrobat 4.0",
'ActiveX Demo',
win32con.MB_OK | win32con.MB_ICONSTOP)
raise ImportError
#----------------------------------------------------------------------
# NOTE:
# Your ActiveX control _must_ be an instance of pywin.mfc.activex.Control,
# as we use the CreateControl method to bind the GUI systems.
class PDFControl(pywin.mfc.activex.Control, acrobatOCX.Pdf):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
acrobatOCX.Pdf.__init__(self)
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.log = log
sizer = wxBoxSizer(wxVERTICAL)
btnSizer = wxBoxSizer(wxHORIZONTAL)
# Build the wxPython wrapper window and put the Acrobat
# control in it
self.axw = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER, eraseBackground=0)
self.axw.SetControl( PDFControl() )
sizer.Add(self.axw, 1, wxEXPAND)
btn = wxButton(self, wxNewId(), "Open PDF File")
EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btn = wxButton(self, wxNewId(), "<-- Previous Page")
EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btn = wxButton(self, wxNewId(), "Next Page -->")
EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btnSizer.Add(50, -1, 2, wxEXPAND)
sizer.Add(btnSizer, 0, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(true)
def __del__(self):
self.axw.Cleanup()
self.axw = None
def OnOpenButton(self, event):
dlg = wxFileDialog(self, wildcard="*.pdf")
if dlg.ShowModal() == wxID_OK:
self.axw.control.LoadFile(dlg.GetPath())
dlg.Destroy()
def OnPrevPageButton(self, event):
self.axw.control.gotoPreviousPage()
def OnNextPageButton(self, event):
self.axw.control.gotoNextPage()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
overview = __doc__
#----------------------------------------------------------------------
if __name__ == '__main__':
class TestFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, "ActiveX test -- Acrobat", size=(640, 480))
self.tp = TestPanel(self, sys.stdout)
def OnCloseWindow(self, event):
self.tp.axw.Cleanup()
self.Destroy()
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(true)
app.MainLoop()

View File

@@ -0,0 +1,133 @@
"""
ActiveXControl sample usage.
Based on original code by Willy Heineman, wheineman@uconect.net, 14 February 2000
ActiveXControl provides a simplified wrapper for creating activeX
controls within wxPython GUIs.
"""
from wxPython.wx import *
from wxPython.lib.activexwrapper import ActiveXWrapper
import pythoncom
import pywin.mfc.activex
import win32com.client.gencache
import win32con
import win32ui
browserModule = win32com.client.gencache.EnsureModule("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1)
if browserModule is None:
win32ui.MessageBox("IE4 or greater does not appear to be installed.",
'ActiveX Demo',
win32con.MB_OK | win32con.MB_ICONSTOP)
raise ImportError
#----------------------------------------------------------------------
# NOTE:
# Your ActiveX control _must_ be an instance of pywin.mfc.activex.Control,
# as we use the CreateControl method to bind the GUI systems.
class WebBrowserControl(pywin.mfc.activex.Control,
browserModule.WebBrowser):
def __init__(self):
pywin.mfc.activex.Control.__init__(self)
browserModule.WebBrowser.__init__(self)
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
self.log = log
self.current = "http://alldunn.com/"
sizer = wxBoxSizer(wxVERTICAL)
btnSizer = wxBoxSizer(wxHORIZONTAL)
# Build the wxPython wrapper window and put the Acrobat
# control in it
self.axw = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER, eraseBackground=0)
self.axw.SetControl( WebBrowserControl() )
sizer.Add(self.axw, 1, wxEXPAND)
self.axw.control.Navigate(self.current)
btn = wxButton(self, wxNewId(), "Open Location")
EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btn = wxButton(self, wxNewId(), "<-- Back Page")
EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btn = wxButton(self, wxNewId(), "Forward Page -->")
EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
btnSizer.Add(50, -1, 2, wxEXPAND)
sizer.Add(btnSizer, 0, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(true)
def __del__(self):
self.axw.Cleanup()
self.axw = None
def OnOpenButton(self, event):
dlg = wxTextEntryDialog(self, "Open Location",
"Enter a full URL or local path",
self.current, wxOK|wxCANCEL)
dlg.CentreOnParent()
if dlg.ShowModal() == wxID_OK:
self.current = dlg.GetValue()
self.axw.control.Navigate(self.current)
dlg.Destroy()
def OnPrevPageButton(self, event):
self.axw.control.GoBack()
def OnNextPageButton(self, event):
self.axw.control.GoForward()
#----------------------------------------------------------------------
# for the demo framework...
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
overview = __doc__
#----------------------------------------------------------------------
if __name__ == '__main__':
class TestFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, "ActiveX test -- Internet Explorer", size=(640, 480))
self.tp = TestPanel(self, sys.stdout)
def OnCloseWindow(self, event):
self.tp.axw.Cleanup()
self.Destroy()
app = wxPySimpleApp()
frame = TestFrame()
frame.Show(true)
app.MainLoop()

View File

@@ -1,13 +1,38 @@
from wxPython.wx import *
from wxPython.lib.filebrowsebutton import FileBrowseButton
from wxPython.lib.filebrowsebutton import FileBrowseButton, FileBrowseButtonWithHistory
#----------------------------------------------------------------------
class TestPanel(wxPanel):
def __init__(self, parent, ID, log):
wxPanel.__init__(self, parent, ID)
self.log = log
self.fbb = FileBrowseButton(self, -1, wxPoint(20,20), wxSize(350, -1),
changeCallback = self.fbbCallback)
self.fbbh = FileBrowseButtonWithHistory(self, -1, wxPoint(20, 50),
wxSize(350, -1),
changeCallback = self.fbbhCallback)
self.fbbh.SetHistory([])
def fbbCallback(self, evt):
self.log.write('FileBrowseButton: %s\n' % evt.GetString())
def fbbhCallback(self, evt):
value = evt.GetString()
self.log.write('FileBrowseButtonWithHistory: %s\n' % value)
history = self.fbbh.GetHistory()
history.append(value)
self.fbbh.SetHistory(history)
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = wxPanel(nb, -1)
fbb = FileBrowseButton(win, -1, wxPoint(20,20), wxSize(350, -1))
win = TestPanel(nb, -1, log)
return win

View File

@@ -72,7 +72,7 @@ class CustomDataTable(wxPyGridTableBase):
#--------------------------------------------------
# optional methods
# Some optional methods
# Called when the grid needs to display labels
def GetColLabelValue(self, col):
@@ -101,8 +101,6 @@ class CustomDataTable(wxPyGridTableBase):
#---------------------------------------------------------------------------

View File

@@ -21,7 +21,9 @@ _useSplitter = true
_useNestedSplitter = true
_treeList = [
('New since last release', ['wxGrid']),
('New since last release', ['wxGrid', 'wxStyledTextCtrl',
'ActiveXWrapper_Acrobat', 'ActiveXWrapper_IE',
'FileBrowseButton', 'wxCalendar']),
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),