Cleanup obsolete samples
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1f575e6569
commit
0d575a5dfa
@ -1,133 +0,0 @@
|
||||
"""
|
||||
<html><body>
|
||||
This demo shows how to embed an ActiveX control in a wxPython application, (Win32 only.)
|
||||
<p>
|
||||
The MakeActiveXClass function dynamically builds a new Class on the fly, that has the
|
||||
same signature and semantics as wxWindow. This means that when you call the function
|
||||
you get back a new class that you can use just like wxWindow, (set the size and position,
|
||||
use in a sizer, etc.) except its contents will be the COM control.
|
||||
<p>
|
||||
This demo embeds the Adobe Acrobat Reader, and gives you some buttons for opening a PDF
|
||||
file, changing pages, etc. that show how to call methods on the COM object. If you don't
|
||||
have Acrobat Reader 4.0 installed it won't work.
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
import sys
|
||||
import wx
|
||||
|
||||
if wx.Platform == '__WXMSW__':
|
||||
import wx.lib.activexwrapper as ax
|
||||
import win32com.client.gencache
|
||||
|
||||
try:
|
||||
acrobat = win32com.client.gencache.EnsureModule(
|
||||
'{CA8A9783-280D-11CF-A24D-444553540000}', 0x0, 1, 3
|
||||
)
|
||||
except:
|
||||
raise ImportError("Can't load PDF.OCX, install Acrobat 4.0")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
self.pdf = None
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
# this function creates a new class that can be used as
|
||||
# a wx.Window, but contains the given ActiveX control.
|
||||
ActiveXWrapper = ax.MakeActiveXClass(acrobat.Pdf)
|
||||
|
||||
# create an instance of the new class
|
||||
self.pdf = ActiveXWrapper( self, -1, style=wx.SUNKEN_BORDER)
|
||||
|
||||
sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Open PDF File")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnOpenButton)
|
||||
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Next Page -->")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
|
||||
|
||||
|
||||
btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
|
||||
sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(True)
|
||||
|
||||
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
|
||||
|
||||
|
||||
def OnDestroy(self, evt):
|
||||
if self.pdf:
|
||||
self.pdf.Cleanup()
|
||||
self.pdf = None
|
||||
|
||||
|
||||
|
||||
def OnOpenButton(self, event):
|
||||
dlg = wx.FileDialog(self, wildcard="*.pdf")
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
wx.BeginBusyCursor()
|
||||
self.pdf.LoadFile(dlg.GetPath())
|
||||
wx.EndBusyCursor()
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
def OnPrevPageButton(self, event):
|
||||
self.pdf.gotoPreviousPage()
|
||||
|
||||
|
||||
def OnNextPageButton(self, event):
|
||||
self.pdf.gotoNextPage()
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wx.Platform == '__WXMSW__':
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
else:
|
||||
dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
|
||||
'Sorry', wx.OK | wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
class TestFrame(wx.Frame):
|
||||
def __init__(self):
|
||||
wx.Frame.__init__(
|
||||
self, None, -1, "ActiveX test -- Acrobat", size=(640, 480),
|
||||
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
)
|
||||
|
||||
self.tp = TestPanel(self, sys.stdout)
|
||||
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frame = TestFrame()
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
||||
|
@ -1,246 +0,0 @@
|
||||
"""
|
||||
<html><body>
|
||||
This demo shows how to embed an ActiveX control in a wxPython
|
||||
application, (Win32 only.)
|
||||
|
||||
<p>
|
||||
The MakeActiveXClass function dynamically builds a new Class on the
|
||||
fly, that has the same signature and semantics as wxWindow. This
|
||||
means that when you call the function you get back a new class that
|
||||
you can use just like wxWindow, (set the size and position, use in a
|
||||
sizer, etc.) except its contents will be the COM control.
|
||||
|
||||
<p>
|
||||
This demo embeds the Internet Explorer WebBrowser control, and shows
|
||||
how to receive events from the COM control. (The title bar and status
|
||||
bar are updated as pages change, in addition to the log messages being
|
||||
shown.)
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
import sys
|
||||
import wx
|
||||
|
||||
if wx.Platform == '__WXMSW__':
|
||||
import wx.lib.activexwrapper as ax
|
||||
import win32com.client.gencache
|
||||
|
||||
try:
|
||||
browserModule = win32com.client.gencache.EnsureModule(
|
||||
"{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1
|
||||
)
|
||||
except:
|
||||
raise ImportError("IE4 or greater does not appear to be installed.")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Window):
|
||||
def __init__(self, parent, log, frame=None):
|
||||
wx.Window.__init__(
|
||||
self, parent, -1,
|
||||
style=wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
)
|
||||
|
||||
self.ie = None
|
||||
self.log = log
|
||||
self.current = "http://wxPython.org/"
|
||||
self.frame = frame
|
||||
|
||||
if frame:
|
||||
self.titleBase = frame.GetTitle()
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
# Make a new class that derives from the WebBrowser class in the
|
||||
# COM module imported above. This class also derives from wxWindow and
|
||||
# implements the machinery needed to integrate the two worlds.
|
||||
theClass = ax.MakeActiveXClass(
|
||||
browserModule.WebBrowser, eventObj = self
|
||||
)
|
||||
|
||||
# Create an instance of that class
|
||||
self.ie = theClass(self, -1) ##, style=wxSUNKEN_BORDER)
|
||||
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Open", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnOpenButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Home", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnHomeButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "<--", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "-->", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Stop", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnStopButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Search", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnSearchPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Refresh", style=wx.BU_EXACTFIT)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnRefreshPageButton, id=btn.GetId())
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
txt = wx.StaticText(self, -1, "Location:")
|
||||
btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2)
|
||||
|
||||
self.location = wx.ComboBox(self, wx.NewId(), "", style=wx.CB_DROPDOWN)
|
||||
self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, id=self.location.GetId())
|
||||
self.Bind(wx.EVT_KEY_UP, self.OnLocationKey, self.location)
|
||||
self.Bind(wx.EVT_CHAR, self.IgnoreReturn, self.location)
|
||||
btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
sizer.Add(btnSizer, 0, wx.EXPAND)
|
||||
sizer.Add(self.ie, 1, wx.EXPAND)
|
||||
|
||||
self.ie.Navigate(self.current)
|
||||
self.location.Append(self.current)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(True)
|
||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
|
||||
|
||||
|
||||
def ShutdownDemo(self):
|
||||
# put the frame title back
|
||||
if self.frame:
|
||||
self.frame.SetTitle(self.titleBase)
|
||||
|
||||
|
||||
def OnDestroy(self, evt):
|
||||
if self.ie:
|
||||
self.ie.Cleanup()
|
||||
self.ie = None
|
||||
self.frame = None
|
||||
|
||||
|
||||
def OnSize(self, evt):
|
||||
self.Layout()
|
||||
|
||||
|
||||
def OnLocationSelect(self, evt):
|
||||
url = self.location.GetStringSelection()
|
||||
self.log.write('OnLocationSelect: %s\n' % url)
|
||||
self.ie.Navigate(url)
|
||||
|
||||
def OnLocationKey(self, evt):
|
||||
if evt.KeyCode() == wx.WXK_RETURN:
|
||||
URL = self.location.GetValue()
|
||||
self.location.Append(URL)
|
||||
self.ie.Navigate(URL)
|
||||
else:
|
||||
evt.Skip()
|
||||
|
||||
def IgnoreReturn(self, evt):
|
||||
print 'IgnoreReturn'
|
||||
if evt.KeyCode() != wx.WXK_RETURN:
|
||||
evt.Skip()
|
||||
|
||||
def OnOpenButton(self, event):
|
||||
dlg = wx.TextEntryDialog(self, "Open Location",
|
||||
"Enter a full URL or local path",
|
||||
self.current, wx.OK|wx.CANCEL)
|
||||
|
||||
dlg.CentreOnParent()
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
self.current = dlg.GetValue()
|
||||
self.ie.Navigate(self.current)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
def OnHomeButton(self, event):
|
||||
self.ie.GoHome() ## ET Phone Home!
|
||||
|
||||
def OnPrevPageButton(self, event):
|
||||
self.ie.GoBack()
|
||||
|
||||
def OnNextPageButton(self, event):
|
||||
self.ie.GoForward()
|
||||
|
||||
def OnStopButton(self, evt):
|
||||
self.ie.Stop()
|
||||
|
||||
def OnSearchPageButton(self, evt):
|
||||
self.ie.GoSearch()
|
||||
|
||||
def OnRefreshPageButton(self, evt):
|
||||
self.ie.Refresh2(3)
|
||||
|
||||
|
||||
# The following event handlers are called by the web browser COM
|
||||
# control since we passed self to MakeActiveXClass. It will look
|
||||
# here for matching attributes and call them if they exist. See the
|
||||
# module generated by makepy for details of method names, etc.
|
||||
def OnBeforeNavigate2(self, pDisp, URL, *args):
|
||||
self.log.write('OnBeforeNavigate2: %s\n' % URL)
|
||||
|
||||
def OnNavigateComplete2(self, pDisp, URL):
|
||||
self.log.write('OnNavigateComplete2: %s\n' % URL)
|
||||
self.current = URL
|
||||
self.location.SetValue(URL)
|
||||
|
||||
def OnTitleChange(self, text):
|
||||
self.log.write('OnTitleChange: %s\n' % text)
|
||||
if self.frame:
|
||||
self.frame.SetTitle(self.titleBase + ' -- ' + text)
|
||||
|
||||
def OnStatusTextChange(self, text):
|
||||
self.log.write('OnStatusTextChange: %s\n' % text)
|
||||
if self.frame:
|
||||
self.frame.SetStatusText(text)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# for the demo framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wx.Platform == '__WXMSW__':
|
||||
win = TestPanel(nb, log, frame)
|
||||
return win
|
||||
else:
|
||||
dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
|
||||
'Sorry', wx.OK | wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
class TestFrame(wx.Frame):
|
||||
def __init__(self):
|
||||
wx.Frame.__init__(
|
||||
self, None, -1, "ActiveX test -- Internet Explorer",
|
||||
size=(640, 480),
|
||||
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
)
|
||||
|
||||
self.CreateStatusBar()
|
||||
self.tp = TestPanel(self, sys.stdout, self)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, evt):
|
||||
self.tp.Destroy()
|
||||
self.Destroy()
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frame = TestFrame()
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
|
@ -1,197 +0,0 @@
|
||||
# demo for ErrorDialogs.py
|
||||
# usual wxWindows license stuff here.
|
||||
# by Chris Fama, with thanks to Robin Dunn, and others on the wxPython-users
|
||||
# mailing list.
|
||||
#
|
||||
# 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o Updated for wx namespace
|
||||
#
|
||||
# 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o Looks like we have issues until the library is updated.
|
||||
# - Had to rename back to wx* naming conventions
|
||||
# - Getting unusual failures in the library itself when that is done.
|
||||
#
|
||||
|
||||
import sys
|
||||
|
||||
import wx
|
||||
import wx.lib.ErrorDialogs as edlg
|
||||
|
||||
_debug = 0
|
||||
|
||||
ID_TEXT = 10000
|
||||
ID_BUTTON_wxPyNonFatalError = 10001
|
||||
ID_BUTTON_wxPyFatalError = 10002
|
||||
ID_BUTTON_wxPyFatalErrorDialog = 10003
|
||||
ID_BUTTON_wxPyNonFatalErrorDialog = 10004
|
||||
ID_BUTTON_wxPyFatalErrorDialogWithTraceback = 10005
|
||||
ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback = 10006
|
||||
|
||||
def ErrorDialogsDemoPanelFunc( parent, call_fit = True, set_sizer = True ):
|
||||
item0 = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
item1 = wx.StaticText(
|
||||
parent, ID_TEXT,
|
||||
"Please select one of the buttons below for an example using explicit errors..."
|
||||
)
|
||||
|
||||
item0.AddWindow( item1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item2 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item3 = wx.Button( parent, ID_BUTTON_wxPyNonFatalError, "wxPyNonFatalError")
|
||||
item2.AddWindow( item3, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item4 = wx.Button( parent, ID_BUTTON_wxPyFatalError, "wxPyFatalError")
|
||||
item2.AddWindow( item4, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item0.AddSizer( item2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item5 = wx.StaticText( parent, ID_TEXT, "Please select one of the buttons below for interpreter errors...")
|
||||
item0.AddWindow( item5, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item6 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item7 = wx.Button( parent, ID_BUTTON_wxPyFatalErrorDialog, "wxPyFatalErrorDialog")
|
||||
item6.AddWindow( item7, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item8 = wx.Button( parent, ID_BUTTON_wxPyNonFatalErrorDialog, "wxPyNonFatalErrorDialog")
|
||||
item6.AddWindow( item8, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item9 = wx.Button(
|
||||
parent, ID_BUTTON_wxPyFatalErrorDialogWithTraceback,
|
||||
"wxPyFatalErrorDialogWithTraceback"
|
||||
)
|
||||
item6.AddWindow( item9, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item10 = wx.Button(
|
||||
parent, ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback,
|
||||
"wxPyNonFatalErrorDialogWithTraceback"
|
||||
)
|
||||
item10.SetDefault()
|
||||
item6.AddWindow( item10, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item0.AddSizer( item6, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
item11 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item0.AddSizer( item11, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
|
||||
|
||||
if set_sizer == True:
|
||||
parent.SetAutoLayout( True )
|
||||
parent.SetSizer( item0 )
|
||||
if call_fit == True:
|
||||
item0.Fit( parent )
|
||||
item0.SetSizeHints( parent )
|
||||
|
||||
return item0
|
||||
|
||||
# Menu bar functions
|
||||
|
||||
# Bitmap functions
|
||||
|
||||
|
||||
# End of generated file
|
||||
|
||||
class MyPanel(wx.Panel):
|
||||
def __init__(self,parent=None):
|
||||
wx.Panel.__init__(self,parent,-1)
|
||||
|
||||
args = (None, -1)
|
||||
kwargs = {
|
||||
'programname': "sumthing",
|
||||
'mailto': "me@sumwear",
|
||||
'whendismissed': "from wxPython.wx import * ; wxBell()"
|
||||
}
|
||||
|
||||
self.dialogs = map(apply,
|
||||
[edlg.wxPyNonFatalErrorDialogWithTraceback,
|
||||
edlg.wxPyNonFatalErrorDialog,#WithTraceback
|
||||
edlg.wxPyFatalErrorDialogWithTraceback,
|
||||
edlg.wxPyFatalErrorDialog #WithTraceback
|
||||
],
|
||||
(args,) * 4,
|
||||
(kwargs,) * 4
|
||||
)
|
||||
|
||||
ErrorDialogsDemoPanelFunc(self)
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyFatalErrorDialog)
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyNonFatalError)
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyFatalError)
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyFatalErrorDialogWithTraceback)
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyNonFatalErrorDialog)
|
||||
self.Bind(wx.EVT_BUTTON, self.DoDialog, id=ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback)
|
||||
|
||||
IndexFromID = {
|
||||
ID_BUTTON_wxPyFatalErrorDialog: 3,
|
||||
ID_BUTTON_wxPyFatalErrorDialogWithTraceback: 2,
|
||||
ID_BUTTON_wxPyNonFatalErrorDialog: 1,
|
||||
ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback: 0
|
||||
}
|
||||
|
||||
def DoDialog(self,event):
|
||||
id = event.GetId()
|
||||
|
||||
if id in [ID_BUTTON_wxPyFatalError,ID_BUTTON_wxPyNonFatalError]:
|
||||
if id == ID_BUTTON_wxPyFatalError:
|
||||
print "%s.DoDialog(): testing explicit wxPyFatalError..."\
|
||||
% self
|
||||
edlg.wxPyFatalError(self,"Test Non-fatal error.<p>"
|
||||
"Nearly arbitrary HTML (i.e., that which is"
|
||||
" understood by <B><I>wxHtmlWindow</i></b>)."
|
||||
"<p><table border=\"2\"><tr><td>This</td><td>is</td></tr>"
|
||||
"<tr><td>a</td><td>table</td></tr></table></p>")
|
||||
else:
|
||||
print "%s.DoDialog(): testing explicit wxPyNonFatalError..."\
|
||||
% self
|
||||
edlg.wxPyNonFatalError(self,"Test Non-fatal error.<p>"
|
||||
"Nearly arbitrary HTML (i.e., that which is"
|
||||
" understood by <B><I>wxHtmlWindow</i></b>)."
|
||||
"<p><table border=\"2\"><tr><td>This</td><td>is</td></tr>"
|
||||
"<tr><td>a</td><td>table</td></tr></table></p>")
|
||||
else:
|
||||
sys.stderr = self.dialogs[self.IndexFromID[id]]
|
||||
print "%s.DoDialog(): testing %s..." % (self,sys.stderr)
|
||||
this_will_generate_a_NameError_exception
|
||||
|
||||
def ShutdownDemo(self):
|
||||
for d in self.dialogs:
|
||||
d.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyFrame(wx.Frame):
|
||||
def __init__(self,parent=None):
|
||||
wx.Frame.__init__(self,parent,-1,
|
||||
"Please make a selection...",
|
||||
)
|
||||
self.panel = MyPanel(self)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self,event):
|
||||
self.panel.Close()
|
||||
self.Destroy()
|
||||
|
||||
class MyApp(wx.App):
|
||||
def OnInit(self):
|
||||
frame = MyFrame()
|
||||
frame.Show(True)
|
||||
self.SetTopWindow(frame)
|
||||
return True
|
||||
|
||||
def runTest(pframe, nb, log):
|
||||
panel = MyPanel(nb)
|
||||
return panel
|
||||
|
||||
edlg._debug = 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr = edlg.wxPyNonWindowingErrorHandler()
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
sys.exit()
|
||||
else:
|
||||
overview = edlg.__doc__
|
@ -1,217 +0,0 @@
|
||||
# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o Updated for wx namespace
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
if wx.Platform == '__WXMSW__':
|
||||
import wx.iewin as iewin
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Window):
|
||||
def __init__(self, parent, log, frame=None):
|
||||
wx.Window.__init__(
|
||||
self, parent, -1,
|
||||
style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
)
|
||||
|
||||
self.log = log
|
||||
self.current = "http://wxPython.org/"
|
||||
self.frame = frame
|
||||
|
||||
if frame:
|
||||
self.titleBase = frame.GetTitle()
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.ie = iewin.IEHtmlWin(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
|
||||
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Open", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Home", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnHomeButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "<--", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "-->", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Stop", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnStopButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Search", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnSearchPageButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
btn = wx.Button(self, wx.NewId(), "Refresh", style=wx.BU_EXACTFIT)
|
||||
wx.EVT_BUTTON(self, btn.GetId(), self.OnRefreshPageButton)
|
||||
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
txt = wx.StaticText(self, -1, "Location:")
|
||||
btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2)
|
||||
|
||||
self.location = wx.ComboBox(
|
||||
self, wx.NewId(), "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER
|
||||
)
|
||||
|
||||
wx.EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect)
|
||||
wx.EVT_KEY_UP(self.location, self.OnLocationKey)
|
||||
wx.EVT_CHAR(self.location, self.IgnoreReturn)
|
||||
btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2)
|
||||
|
||||
sizer.Add(btnSizer, 0, wx.EXPAND)
|
||||
sizer.Add(self.ie, 1, wx.EXPAND)
|
||||
|
||||
self.ie.Navigate(self.current)
|
||||
self.location.Append(self.current)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(True)
|
||||
wx.EVT_SIZE(self, self.OnSize)
|
||||
|
||||
# Hook up the event handlers for the IE window
|
||||
iewin.EVT_MSHTML_BEFORENAVIGATE2(self, -1, self.OnBeforeNavigate2)
|
||||
iewin.EVT_MSHTML_NEWWINDOW2(self, -1, self.OnNewWindow2)
|
||||
iewin.EVT_MSHTML_DOCUMENTCOMPLETE(self, -1, self.OnDocumentComplete)
|
||||
#EVT_MSHTML_PROGRESSCHANGE(self, -1, self.OnProgressChange)
|
||||
iewin.EVT_MSHTML_STATUSTEXTCHANGE(self, -1, self.OnStatusTextChange)
|
||||
iewin.EVT_MSHTML_TITLECHANGE(self, -1, self.OnTitleChange)
|
||||
|
||||
|
||||
def ShutdownDemo(self):
|
||||
# put the frame title back
|
||||
if self.frame:
|
||||
self.frame.SetTitle(self.titleBase)
|
||||
|
||||
|
||||
def OnSize(self, evt):
|
||||
self.Layout()
|
||||
|
||||
|
||||
def OnLocationSelect(self, evt):
|
||||
url = self.location.GetStringSelection()
|
||||
self.log.write('OnLocationSelect: %s\n' % url)
|
||||
self.ie.Navigate(url)
|
||||
|
||||
def OnLocationKey(self, evt):
|
||||
if evt.KeyCode() == wx.WXK_RETURN:
|
||||
URL = self.location.GetValue()
|
||||
self.location.Append(URL)
|
||||
self.ie.Navigate(URL)
|
||||
else:
|
||||
evt.Skip()
|
||||
|
||||
|
||||
def IgnoreReturn(self, evt):
|
||||
if evt.GetKeyCode() != wx.WXK_RETURN:
|
||||
evt.Skip()
|
||||
|
||||
def OnOpenButton(self, event):
|
||||
dlg = wx.TextEntryDialog(self, "Open Location",
|
||||
"Enter a full URL or local path",
|
||||
self.current, wx.OK|wx.CANCEL)
|
||||
dlg.CentreOnParent()
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
self.current = dlg.GetValue()
|
||||
self.ie.Navigate(self.current)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
def OnHomeButton(self, event):
|
||||
self.ie.GoHome() ## ET Phone Home!
|
||||
|
||||
def OnPrevPageButton(self, event):
|
||||
self.ie.GoBack()
|
||||
|
||||
def OnNextPageButton(self, event):
|
||||
self.ie.GoForward()
|
||||
|
||||
def OnStopButton(self, evt):
|
||||
self.ie.Stop()
|
||||
|
||||
def OnSearchPageButton(self, evt):
|
||||
self.ie.GoSearch()
|
||||
|
||||
def OnRefreshPageButton(self, evt):
|
||||
self.ie.Refresh(iewin.IEHTML_REFRESH_COMPLETELY)
|
||||
|
||||
|
||||
def logEvt(self, name, event):
|
||||
self.log.write('%s: %s\n' %
|
||||
(name, (event.GetLong1(), event.GetLong2(), event.GetText1())))
|
||||
|
||||
def OnBeforeNavigate2(self, evt):
|
||||
self.logEvt('OnBeforeNavigate2', evt)
|
||||
|
||||
def OnNewWindow2(self, evt):
|
||||
self.logEvt('OnNewWindow2', evt)
|
||||
evt.Veto() # don't allow it
|
||||
|
||||
def OnDocumentComplete(self, evt):
|
||||
self.logEvt('OnDocumentComplete', evt)
|
||||
self.current = evt.GetText1()
|
||||
self.location.SetValue(self.current)
|
||||
|
||||
def OnTitleChange(self, evt):
|
||||
self.logEvt('OnTitleChange', evt)
|
||||
if self.frame:
|
||||
self.frame.SetTitle(self.titleBase + ' -- ' + evt.GetText1())
|
||||
|
||||
def OnStatusTextChange(self, evt):
|
||||
self.logEvt('OnStatusTextChange', evt)
|
||||
if self.frame:
|
||||
self.frame.SetStatusText(evt.GetText1())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# for the demo framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wx.Platform == '__WXMSW__':
|
||||
win = TestPanel(nb, log, frame)
|
||||
return win
|
||||
else:
|
||||
dlg = wx.MessageDialog(frame, 'This demo only works on Windows.',
|
||||
'Sorry', wx.OK | wx.ICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
<html><body>
|
||||
<h2>wx.IEHtmlWin</h2>
|
||||
|
||||
The wx.IEHtmlWin class is the first example of using a contributed
|
||||
wxActiveX class in wxWindows C++. It is still experimental, but
|
||||
I think it is useful.
|
||||
|
||||
<p> Using this class is simpler than ActiveXWrapper, doesn't rely on
|
||||
the win32all extensions, and is more "wx\'ish", meaning that it uses
|
||||
events and etc. as would be expected from any other wx window.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -71,7 +71,6 @@ _treeList = [
|
||||
|
||||
# dialogs from libraries
|
||||
('More Dialogs', [
|
||||
##'ErrorDialogs',
|
||||
'ImageBrowser',
|
||||
'MultipleChoiceDialog',
|
||||
'ScrolledMessageDialog',
|
||||
@ -143,7 +142,6 @@ _treeList = [
|
||||
'FloatBar',
|
||||
'FloatCanvas',
|
||||
'HtmlWindow',
|
||||
##'IEHtmlWin',
|
||||
'IntCtrl',
|
||||
'MVCTree',
|
||||
'MaskedEditControls',
|
||||
@ -180,7 +178,6 @@ _treeList = [
|
||||
('Process and Events', [
|
||||
'EventManager',
|
||||
'KeyEvents',
|
||||
##'OOR',
|
||||
'Process',
|
||||
'PythonEvents',
|
||||
'Threads',
|
||||
@ -225,10 +222,7 @@ _treeList = [
|
||||
|
||||
# need libs not coming with the demo
|
||||
('Objects using an external library', [
|
||||
##'ActiveXWrapper_Acrobat',
|
||||
##'ActiveXWrapper_IE', # currently has tstate problems...
|
||||
'GLCanvas',
|
||||
#'PlotCanvas', # deprecated, use PyPlot
|
||||
]),
|
||||
|
||||
|
||||
|
@ -1,155 +0,0 @@
|
||||
|
||||
import wx
|
||||
import wx.html as wxhtml
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
BTN1 = wx.NewId()
|
||||
BTN2 = wx.NewId()
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
html = wxhtml.HtmlWindow(self, -1)
|
||||
html.SetPage(overview)
|
||||
sizer.Add(html, 1, wx.EXPAND|wx.ALL, 5)
|
||||
|
||||
btns = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btns.Add((50, -1), 1, wx.EXPAND)
|
||||
btn1 = wx.Button(self, BTN1, "Find My Alter-ego") # don't save a ref to this one
|
||||
btns.Add(btn1)
|
||||
btns.Add((50, -1), 1, wx.EXPAND)
|
||||
self.btn2 = wx.Button(self, BTN2, "Find Myself")
|
||||
btns.Add(self.btn2)
|
||||
btns.Add((50, -1), 1, wx.EXPAND)
|
||||
|
||||
sizer.Add(btns, 0, wx.EXPAND|wx.ALL, 15)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(True)
|
||||
|
||||
self.sizer = sizer # save it for testing later
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.OnFindButton1, id=BTN1)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnFindButton2, id=BTN2)
|
||||
|
||||
|
||||
def OnFindButton1(self, evt):
|
||||
win = self.FindWindowById(BTN1)
|
||||
|
||||
if win is None:
|
||||
self.log.write("***** OOPS! None returned...\n")
|
||||
return
|
||||
|
||||
className = win.__class__.__name__
|
||||
|
||||
if className in ["Button", "ButtonPtr"]:
|
||||
self.log.write("The types are the same! <grin>\n")
|
||||
else:
|
||||
self.log.write("Got %s, expected wxButton or wxButtonPtr\n" % className)
|
||||
|
||||
|
||||
|
||||
def OnFindButton2(self, evt):
|
||||
win = self.FindWindowById(BTN2)
|
||||
|
||||
if win is None:
|
||||
self.log.write("***** OOPS! None returned...\n")
|
||||
return
|
||||
|
||||
if win is self.btn2:
|
||||
self.log.write("The objects are the same! <grin>\n")
|
||||
else:
|
||||
self.log.write("The objects are NOT the same! <frown>\n")
|
||||
|
||||
win = evt.GetEventObject()
|
||||
|
||||
if win is None:
|
||||
self.log.write("***** OOPS! None returned...\n")
|
||||
return
|
||||
|
||||
if win is self.btn2:
|
||||
self.log.write("The objects are the same! <grin>\n")
|
||||
else:
|
||||
self.log.write("The objects are NOT the same! <frown>\n")
|
||||
|
||||
sizer = self.GetSizer()
|
||||
|
||||
if sizer is None:
|
||||
self.log.write("***** OOPS! None returned...\n")
|
||||
return
|
||||
|
||||
if sizer is self.sizer:
|
||||
self.log.write("The objects are the same! <grin>\n")
|
||||
else:
|
||||
self.log.write("The objects are NOT the same! <frown>\n")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """\
|
||||
<html><body>
|
||||
<h2>Original Object Return</h2>
|
||||
|
||||
<p>Several methods in wxWindows return pointers to base class objects,
|
||||
when in fact the actual object pointed to is of a derived type. Since
|
||||
SWIG isn't able to tell the actual type it just creates a new Python
|
||||
shadow object of the base type to wrap around the base type pointer
|
||||
and returns it.
|
||||
|
||||
<p>In wxPython prior to 2.3.0 this could cause annoying issues. For
|
||||
example if you called:
|
||||
|
||||
<pre>
|
||||
|
||||
myText = someWindow.FindWindowById(txtID)
|
||||
</pre>
|
||||
|
||||
expecting to get a wxTextCtrl you would actually get a wxWindow object
|
||||
instead. If you then try to call SetValue on that object you'll get
|
||||
an exception since there is no such method. This is the reason for
|
||||
the wxPyTypeCast hack that has been in wxPython for so long.
|
||||
|
||||
<p>Even with wxPyTypeCast there was the issue that the object returned
|
||||
was not the same one that was created in Python originally, but a new
|
||||
object of the same type that wraps the same C++ pointer. If the
|
||||
programmer has set additional attributes of that original object they
|
||||
will not exist in the new object.
|
||||
|
||||
<p>For a long time now I have wanted to do away with wxPyTypeCast and
|
||||
also find a way to return the original Python object from methods like
|
||||
FindWindowById. This project naturally divides into two phases:
|
||||
|
||||
<p><ol>
|
||||
|
||||
<li>Teach the wrapper methods how to return objects of the right type,
|
||||
and be able to then turn wxPyTypeCast in to a no-op.
|
||||
|
||||
<li>Be able to return the original Python shadow object if it still exists.
|
||||
|
||||
</ol>
|
||||
|
||||
<p>The first button below shows the first of these phases (<i>working</i>)
|
||||
and the second will show #2 (<i>working as of Python 2.3.2</i>)
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
@ -1,51 +0,0 @@
|
||||
|
||||
#
|
||||
# wx.lib.wxPlotCanvas is deprecated. Use wx.lib.plot instead.
|
||||
#
|
||||
|
||||
import wx
|
||||
import wx.lib.wxPlotCanvas as plot
|
||||
|
||||
import Numeric
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def _InitObjects():
|
||||
# 100 points sin function, plotted as green circles
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
|
||||
data1.shape = (100, 2)
|
||||
data1[:,1] = Numeric.sin(data1[:,0])
|
||||
markers1 = plot.PolyMarker(data1, color='green', marker='circle',size=1)
|
||||
|
||||
# 50 points cos function, plotted as red line
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
|
||||
data1.shape = (50,2)
|
||||
data1[:,1] = Numeric.cos(data1[:,0])
|
||||
lines = plot.PolyLine(data1, color='red')
|
||||
|
||||
# A few more points...
|
||||
pi = Numeric.pi
|
||||
markers2 = plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
|
||||
(3.*pi/4., -1)], color='blue',
|
||||
fillcolor='green', marker='cross')
|
||||
|
||||
return plot.PlotGraphics([markers1, lines, markers2])
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = plot.PlotCanvas(nb)
|
||||
win.draw(_InitObjects(),'automatic','automatic');
|
||||
return win
|
||||
|
||||
overview = plot.__doc__
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
Loading…
Reference in New Issue
Block a user