This commit was manufactured by cvs2svn to create tag 'M_STABLE'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/M_STABLE@40387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
131
wxPython/demo/ActiveXWrapper_Acrobat.py
Normal file
@@ -0,0 +1,131 @@
|
||||
"""
|
||||
<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>
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
from wxPython.lib.activexwrapper import MakeActiveXClass
|
||||
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(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.pdf = None
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
btnSizer = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
# this function creates a new class that can be used as
|
||||
# a wxWindow, but contains the given ActiveX control.
|
||||
ActiveXWrapper = MakeActiveXClass(acrobat.Pdf)
|
||||
|
||||
# create an instance of the new class
|
||||
self.pdf = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER)
|
||||
|
||||
sizer.Add(self.pdf, 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):
|
||||
if self.pdf:
|
||||
self.pdf.Cleanup()
|
||||
self.pdf = None
|
||||
|
||||
|
||||
|
||||
def OnOpenButton(self, event):
|
||||
dlg = wxFileDialog(self, wildcard="*.pdf")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
wxBeginBusyCursor()
|
||||
self.pdf.LoadFile(dlg.GetPath())
|
||||
wxEndBusyCursor()
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
def OnPrevPageButton(self, event):
|
||||
self.pdf.gotoPreviousPage()
|
||||
|
||||
|
||||
def OnNextPageButton(self, event):
|
||||
self.pdf.gotoNextPage()
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXMSW__':
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
else:
|
||||
dlg = wxMessageDialog(frame, 'This demo only works on MSW.',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, None, -1, "ActiveX test -- Acrobat", size=(640, 480),
|
||||
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
self.tp = TestPanel(self, sys.stdout)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
|
||||
self.tp.pdf.Cleanup()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
app = wxPySimpleApp()
|
||||
frame = TestFrame()
|
||||
frame.Show(true)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
205
wxPython/demo/ActiveXWrapper_IE.py
Normal file
@@ -0,0 +1,205 @@
|
||||
"""
|
||||
<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 Exploer 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>
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
if wxPlatform == '__WXMSW__':
|
||||
from wxPython.lib.activexwrapper import MakeActiveXClass
|
||||
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(wxWindow):
|
||||
def __init__(self, parent, log, frame=None):
|
||||
wxWindow.__init__(self, parent, -1)#, style=wxCLIP_CHILDREN)
|
||||
self.ie = None
|
||||
self.log = log
|
||||
self.current = "http://wxPython.org/"
|
||||
self.frame = frame
|
||||
if frame:
|
||||
self.titleBase = frame.GetTitle()
|
||||
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
btnSizer = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
# 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 = MakeActiveXClass(browserModule.WebBrowser,
|
||||
eventObj = self)
|
||||
|
||||
# Create an instance of that class
|
||||
self.ie = theClass(self, -1, style=wxSUNKEN_BORDER)
|
||||
|
||||
|
||||
#btn = wxButton(self, wxNewId(), " Open ")
|
||||
#EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
|
||||
#btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxNewId(), " Home ")
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnHomeButton)
|
||||
btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxNewId(), " <-- ")
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
|
||||
btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
btn = wxButton(self, wxNewId(), " --> ")
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
|
||||
btnSizer.Add(btn, 0, wxEXPAND|wxALL, 5)
|
||||
|
||||
txt = wxStaticText(self, -1, "Location:")
|
||||
btnSizer.Add(txt, 0, wxCENTER|wxALL, 5)
|
||||
|
||||
self.location = wxComboBox(self, wxNewId(), "", style=wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, self.location.GetId(), self.OnLocationSelect)
|
||||
EVT_KEY_UP(self.location, self.OnLocationKey)
|
||||
#EVT_CHAR(self.location, self.IgnoreReturn)
|
||||
btnSizer.Add(self.location, 1, wxEXPAND|wxALL, 5)
|
||||
|
||||
sizer.Add(btnSizer, 0, wxEXPAND)
|
||||
sizer.Add(self.ie, 1, wxEXPAND)
|
||||
|
||||
self.ie.Navigate(self.current)
|
||||
self.location.Append(self.current)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(true)
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
|
||||
|
||||
def OnSize(self, evt):
|
||||
self.Layout()
|
||||
|
||||
def __del__(self):
|
||||
if self.ie:
|
||||
self.ie.Cleanup()
|
||||
self.ie = None
|
||||
|
||||
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() == 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() != WXK_RETURN:
|
||||
evt.Skip()
|
||||
|
||||
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.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()
|
||||
|
||||
|
||||
# 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 wxPlatform == '__WXMSW__':
|
||||
win = TestPanel(nb, log, frame)
|
||||
return win
|
||||
else:
|
||||
dlg = wxMessageDialog(frame, 'This demo only works on MSW.',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, None, -1, "ActiveX test -- Internet Explorer",
|
||||
size=(640, 480),
|
||||
style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
self.CreateStatusBar()
|
||||
self.tp = TestPanel(self, sys.stdout, self)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.tp.ie.Cleanup()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
app = wxPySimpleApp()
|
||||
frame = TestFrame()
|
||||
frame.Show(true)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
106
wxPython/demo/AnalogClockWindow.py
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
|
||||
|
||||
import wx
|
||||
from wx.lib import analogclock as ac
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
# A mostly default clock
|
||||
c1 = ac.AnalogClockWindow(self)
|
||||
c1.SetBackgroundColour("RED")
|
||||
c1.SetHandColours("BLUE")
|
||||
c1.SetTickColours("WHITE")
|
||||
c1.SetTickSizes(h=5, m=2)
|
||||
|
||||
|
||||
# A clock with roman numerals, shown only at the quarter
|
||||
# marks, and a separatly coloured watch face.
|
||||
c2 = ac.AnalogClockWindow(self)
|
||||
c2.SetBackgroundColour("WHITE")
|
||||
c2.SetHandColours("RED")
|
||||
c2.SetTickColours("BLUE")
|
||||
c2.SetTickStyles(ac.TICKS_ROMAN)
|
||||
c2.SetClockStyle(ac.SHOW_QUARTERS_TICKS | ac.SHOW_SHADOWS)
|
||||
c2.SetWatchPenBrush(p=wx.Pen((238, 238, 227), 1, wx.SOLID),
|
||||
b=wx.Brush("CADET BLUE", wx.SOLID))
|
||||
c2.SetTickSizes(h=12)
|
||||
|
||||
# A clock with rotated decimal numbers, shown at all twelve
|
||||
# hour marks
|
||||
c3 = ac.AnalogClockWindow(self)
|
||||
c3.SetBackgroundColour("BLUE")
|
||||
c3.SetHandColours("WHITE")
|
||||
c3.SetTickColours("RED")
|
||||
c3.SetTickStyles(h=ac.TICKS_DECIMAL)
|
||||
c3.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.ROTATE_TICKS)
|
||||
c3.SetTickSizes(h=14)
|
||||
|
||||
# a plain clock, with square hour and round minute marks, no
|
||||
# shadow raised border
|
||||
c4 = ac.AnalogClockWindow(self, style=wx.RAISED_BORDER)
|
||||
c4.SetTickStyles(h=ac.TICKS_SQUARE, m=ac.TICKS_CIRCLE)
|
||||
c4.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.SHOW_MINUTES_TICKS)
|
||||
c4.SetTickSizes(h=5, m=2)
|
||||
|
||||
|
||||
# no minute tick marks
|
||||
c5 = ac.AnalogClockWindow(self)
|
||||
c5.SetTickStyles(h=ac.TICKS_CIRCLE)
|
||||
c5.SetClockStyle(ac.SHOW_HOURS_TICKS | ac.SHOW_SHADOWS | ac.ROTATE_TICKS)
|
||||
c5.SetTickSizes(h=5, m=2)
|
||||
|
||||
# sunken border
|
||||
c6 = ac.AnalogClockWindow(self, style=wx.SUNKEN_BORDER)
|
||||
c6.SetTickSizes(h=5, m=2)
|
||||
|
||||
|
||||
# layout the clocks in a grid
|
||||
gs = wx.GridSizer(2, 3, 4, 4)
|
||||
gs.Add(c1, 0, wx.EXPAND)
|
||||
gs.Add(c2, 0, wx.EXPAND)
|
||||
gs.Add(c3, 0, wx.EXPAND)
|
||||
gs.Add(c4, 0, wx.EXPAND)
|
||||
gs.Add(c5, 0, wx.EXPAND)
|
||||
gs.Add(c6, 0, wx.EXPAND)
|
||||
|
||||
# put it in another sizer for a border
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(gs, 1, wx.EXPAND | wx.ALL, 10)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>AnalogClockWindow</center></h2>
|
||||
|
||||
This is a nice little clock class that was contributed to by several
|
||||
members of the wxPython-users group.
|
||||
<p>
|
||||
Check the options available by right-clicking the clock.
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
||||
178
wxPython/demo/ErrorDialogs.py
Normal file
@@ -0,0 +1,178 @@
|
||||
# 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.
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.ErrorDialogs import *
|
||||
_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 = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
item1 = wxStaticText( parent, ID_TEXT, "Please select one of the buttons below for an example using explicit errors...", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item0.AddWindow( item1, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item2 = wxFlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item3 = wxButton( parent, ID_BUTTON_wxPyNonFatalError, "wxPyNonFatalError", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item2.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item4 = wxButton( parent, ID_BUTTON_wxPyFatalError, "wxPyFatalError", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item2.AddWindow( item4, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item0.AddSizer( item2, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item5 = wxStaticText( parent, ID_TEXT, "Please select one of the buttons below for interpreter errors...", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item0.AddWindow( item5, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item6 = wxFlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item7 = wxButton( parent, ID_BUTTON_wxPyFatalErrorDialog, "wxPyFatalErrorDialog", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item6.AddWindow( item7, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item8 = wxButton( parent, ID_BUTTON_wxPyNonFatalErrorDialog, "wxPyNonFatalErrorDialog", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item6.AddWindow( item8, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item9 = wxButton( parent, ID_BUTTON_wxPyFatalErrorDialogWithTraceback, "wxPyFatalErrorDialogWithTraceback", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item6.AddWindow( item9, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item10 = wxButton( parent, ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback, "wxPyNonFatalErrorDialogWithTraceback", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item10.SetDefault()
|
||||
item6.AddWindow( item10, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item0.AddSizer( item6, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item11 = wxFlexGridSizer( 0, 2, 0, 0 )
|
||||
|
||||
item0.AddSizer( item11, 0, wxALIGN_CENTRE|wxALL, 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(wxPanel):
|
||||
def __init__(self,parent=None):
|
||||
wxPanel.__init__(self,parent,-1)
|
||||
args = (None, -1)
|
||||
kwargs = {
|
||||
'programname': "sumthing",
|
||||
'mailto': "me@sumwear",
|
||||
'whendismissed': "from wxPython.wx import * ; wxBell()"}
|
||||
self.dialogs = map(apply,
|
||||
[wxPyNonFatalErrorDialogWithTraceback,
|
||||
wxPyNonFatalErrorDialog,#WithTraceback
|
||||
wxPyFatalErrorDialogWithTraceback,
|
||||
wxPyFatalErrorDialog],#WithTraceback
|
||||
(args,) * 4,
|
||||
(kwargs,) * 4)
|
||||
ErrorDialogsDemoPanelFunc(self)
|
||||
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyFatalErrorDialog,
|
||||
self.DoDialog)
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyNonFatalError,
|
||||
self.DoDialog)
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyFatalError,
|
||||
self.DoDialog)
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyFatalErrorDialogWithTraceback,
|
||||
self.DoDialog)
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyNonFatalErrorDialog,
|
||||
self.DoDialog)
|
||||
EVT_BUTTON(self,
|
||||
ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback,
|
||||
self.DoDialog)
|
||||
EVT_CLOSE(self,self.OnClose)
|
||||
|
||||
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
|
||||
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
|
||||
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 OnClose(self,evt):
|
||||
for d in self.dialogs:
|
||||
d.Destroy ()
|
||||
self.Destroy ()
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self,parent=None):
|
||||
wxFrame.__init__(self,parent,-1,
|
||||
"Please make a selection...",
|
||||
)
|
||||
self. panel = MyPanel(self)
|
||||
EVT_CLOSE (self,self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self,event):
|
||||
self.panel.Close()
|
||||
self.Destroy()
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = MyFrame()
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
def runTest(pframe, nb, log):
|
||||
panel = MyPanel(nb)
|
||||
return panel
|
||||
|
||||
from wxPython.lib import ErrorDialogs
|
||||
ErrorDialogs._debug = 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.stderr = wxPyNonWindowingErrorHandler()
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
sys.exit()
|
||||
else:
|
||||
overview = ErrorDialogs.__doc__
|
||||
138
wxPython/demo/OOR.py
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
BTN1 = wxNewId()
|
||||
BTN2 = wxNewId()
|
||||
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
html = wxHtmlWindow(self, -1)
|
||||
html.SetPage(overview)
|
||||
sizer.Add(html, 1, wxEXPAND|wxALL, 5)
|
||||
|
||||
btns = wxBoxSizer(wxHORIZONTAL)
|
||||
btns.Add(50, -1, 1, wxEXPAND)
|
||||
btn1 = wxButton(self, BTN1, "Find My Alter-ego") # don't save a ref to this one
|
||||
btns.Add(btn1)
|
||||
btns.Add(50, -1, 1, wxEXPAND)
|
||||
self.btn2 = wxButton(self, BTN2, "Find Myself")
|
||||
btns.Add(self.btn2)
|
||||
btns.Add(50, -1, 1, wxEXPAND)
|
||||
|
||||
sizer.Add(btns, 0, wxEXPAND|wxALL, 15)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(true)
|
||||
|
||||
self.sizer = sizer # save it for testing later
|
||||
|
||||
EVT_BUTTON(self, BTN1, self.OnFindButton1)
|
||||
EVT_BUTTON(self, BTN2, self.OnFindButton2)
|
||||
|
||||
|
||||
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 ["wxButton", "wxButtonPtr"]:
|
||||
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 2.3.2</i>)
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
403
wxPython/demo/OldSizers.py
Normal file
@@ -0,0 +1,403 @@
|
||||
#----------------------------------------------------------------------
|
||||
# sizer test code
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.sizers import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox1(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox2(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox3(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox4(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 1)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox5(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 3)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox6(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL, wxSize(250, 50))
|
||||
box.Add(wxButton(win, 1010, "10"), 10)
|
||||
box.Add(wxButton(win, 1010, "20"), 20)
|
||||
box.Add(wxButton(win, 1010, "30"), 30)
|
||||
box.Add(wxButton(win, 1010, "15"), 15)
|
||||
box.Add(wxButton(win, 1010, "5"), 5)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder1(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder2(win):
|
||||
bdr = wxBorderSizer(wxEAST | wxWEST)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder3(win):
|
||||
bdr = wxBorderSizer(wxNORTH | wxWEST)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeShapes(win):
|
||||
box =wxBoxSizer(wxVERTICAL)
|
||||
box.Add(wxStaticLine(win, -1), 0)
|
||||
for line in (
|
||||
(wxANCHOR_NW, "NorthWest"),
|
||||
(wxANCHOR_NORTH, "North"),
|
||||
(wxANCHOR_NE, "NorthEast")
|
||||
), (
|
||||
(wxANCHOR_WEST, "West"),
|
||||
(wxANCHOR_NONE, "Center"),
|
||||
(wxANCHOR_EAST, "East")
|
||||
), (
|
||||
(wxANCHOR_SW, "SouthWest"),
|
||||
(wxANCHOR_SOUTH, "South"),
|
||||
(wxANCHOR_SE, "SouthEast")
|
||||
):
|
||||
linebox =wxBoxSizer(wxHORIZONTAL)
|
||||
linebox.Add(wxStaticLine(win, -1, style=wxVERTICAL), 0)
|
||||
for (anchor, label) in line:
|
||||
sizer =wxShapeSizer(anchor)
|
||||
sizer.Add(wxButton(win, -1, label, size=wxSize(100, 50)))
|
||||
linebox.Add(sizer, 1)
|
||||
linebox.Add(wxStaticLine(win, -1, style=wxVERTICAL), 0)
|
||||
box.Add(linebox, 1)
|
||||
box.Add(wxStaticLine(win, -1), 0)
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBoxInBox(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
box.Add(wxButton(win, 1010, "one"))
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
])
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
])
|
||||
|
||||
box2.Add(box3, 1)
|
||||
box.Add(box2, 1)
|
||||
|
||||
box.Add(wxButton(win, 1010, "ten"))
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBoxInBorder(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
box = makeSimpleBox3(win)
|
||||
bdr.Add(box, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBorderInBox(win):
|
||||
insideBox = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ wxButton(win, 1010, "one"),
|
||||
wxButton(win, 1010, "two"),
|
||||
wxButton(win, 1010, "three"),
|
||||
wxButton(win, 1010, "four"),
|
||||
wxButton(win, 1010, "five"),
|
||||
])
|
||||
|
||||
insideBox.Add(box2, 0)
|
||||
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
bdr.Add(wxButton(win, 1010, "border"), 20)
|
||||
insideBox.Add(bdr, 1)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 0),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
])
|
||||
insideBox.Add(box3, 1)
|
||||
|
||||
outsideBox = wxBoxSizer(wxVERTICAL)
|
||||
outsideBox.Add(wxButton(win, 1010, "top"))
|
||||
outsideBox.Add(insideBox, 1)
|
||||
outsideBox.Add(wxButton(win, 1010, "bottom"))
|
||||
|
||||
return outsideBox
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
theTests = [
|
||||
("Simple horizontal boxes", makeSimpleBox1,
|
||||
"This is a HORIZONTAL box sizer with four non-stretchable buttons held "
|
||||
"within it. Notice that the buttons are added and aligned in the horizontal "
|
||||
"dimension. Also notice that they are fixed size in the horizontal dimension, "
|
||||
"but will stretch vertically."
|
||||
),
|
||||
|
||||
("Simple vertical boxes", makeSimpleBox2,
|
||||
"Exactly the same as the previous sample but using a VERTICAL box sizer "
|
||||
"instead of a HORIZONTAL one."
|
||||
),
|
||||
|
||||
("Add a stretchable", makeSimpleBox3,
|
||||
"We've added one more button with the strechable flag turned on. Notice "
|
||||
"how it grows to fill the extra space in the otherwise fixed dimension."
|
||||
),
|
||||
|
||||
("More than one stretchable", makeSimpleBox4,
|
||||
"Here there are several items that are stretchable, they all divide up the "
|
||||
"extra space evenly."
|
||||
),
|
||||
|
||||
("Weighting factor", makeSimpleBox5,
|
||||
"This one shows more than one strechable, but one of them has a weighting "
|
||||
"factor so it gets more of the free space."
|
||||
),
|
||||
|
||||
# ("Percent Sizer", makeSimpleBox6,
|
||||
# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
|
||||
# "the weighting factors add up to 100!"
|
||||
# ),
|
||||
|
||||
("", None, ""),
|
||||
|
||||
("Simple border sizer", makeSimpleBorder1,
|
||||
"The wxBorderSizer leaves empty space around its contents. This one "
|
||||
"gives a border all the way around."
|
||||
),
|
||||
|
||||
("East and West border", makeSimpleBorder2,
|
||||
"You can pick and choose which sides have borders."
|
||||
),
|
||||
|
||||
("North and West border", makeSimpleBorder3,
|
||||
"You can pick and choose which sides have borders."
|
||||
),
|
||||
|
||||
("", None, ""),
|
||||
|
||||
|
||||
("Proportional resize", makeShapes,
|
||||
"The wxShapeSizer preserves the original proportions of the window."
|
||||
),
|
||||
|
||||
("", None, ""),
|
||||
|
||||
("Boxes inside of boxes", makeBoxInBox,
|
||||
"This one shows nesting of boxes within boxes within boxes, using both "
|
||||
"orientations. Notice also that button seven has a greater weighting "
|
||||
"factor than its siblings."
|
||||
),
|
||||
|
||||
("Boxes inside a Border", makeBoxInBorder,
|
||||
"Sizers of different types can be nested withing each other as well. "
|
||||
"Here is a box sizer with several buttons embedded within a border sizer."
|
||||
),
|
||||
|
||||
("Border in a Box", makeBorderInBox,
|
||||
"Another nesting example. This one has Boxes and a Border inside another Box."
|
||||
),
|
||||
|
||||
]
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, title, sizerFunc):
|
||||
wxFrame.__init__(self, parent, -1, title)
|
||||
EVT_BUTTON(self, 1010, self.OnButton)
|
||||
|
||||
self.sizer = sizerFunc(self)
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
||||
self.sizer.FitWindow(self)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
self.sizer.Layout(size)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.MakeModal(false)
|
||||
self.Destroy()
|
||||
|
||||
def OnButton(self, event):
|
||||
self.Close(true)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
class TestSelectionPanel(wxPanel):
|
||||
def __init__(self, parent, frame=NULL):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.frame = frame
|
||||
|
||||
self.list = wxListBox(self, 401,
|
||||
wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 60),
|
||||
[])
|
||||
EVT_LISTBOX(self, 401, self.OnSelect)
|
||||
EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
|
||||
|
||||
wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
|
||||
EVT_BUTTON(self, 402, self.OnDClick)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "",
|
||||
wxDLG_PNT(self, 10, 80),
|
||||
wxDLG_SZE(self, 200, 60),
|
||||
wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
for item in theTests:
|
||||
self.list.Append(item[0])
|
||||
|
||||
|
||||
|
||||
def OnSelect(self, event):
|
||||
pos = self.list.GetSelection()
|
||||
self.text.SetValue(theTests[pos][2])
|
||||
|
||||
|
||||
def OnDClick(self, event):
|
||||
pos = self.list.GetSelection()
|
||||
title = theTests[pos][0]
|
||||
func = theTests[pos][1]
|
||||
|
||||
if func:
|
||||
win = TestFrame(self, title, func)
|
||||
win.CentreOnParent(wxBOTH)
|
||||
win.Show(true)
|
||||
win.MakeModal(true)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestSelectionPanel(nb, frame)
|
||||
return win
|
||||
|
||||
overview = wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBorderSizer.__doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
class MainFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, NULL, -1, "Testing...")
|
||||
|
||||
self.CreateStatusBar()
|
||||
mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(200, 'E&xit', 'Get the heck outta here!')
|
||||
mainmenu.Append(menu, "&File")
|
||||
self.SetMenuBar(mainmenu)
|
||||
EVT_MENU(self, 200, self.OnExit)
|
||||
self.panel = TestSelectionPanel(self, self)
|
||||
self.SetSize(wxSize(400, 380))
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def OnExit(self, event):
|
||||
self.Close(true)
|
||||
|
||||
|
||||
class TestApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = MainFrame()
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
app = TestApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
23
wxPython/demo/PyCrustWithFilling.py
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
from wxPython.wx import wxSplitterWindow
|
||||
from wxPython.lib.PyCrust import shell, version, filling
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % version.VERSION
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxSplitterWindow(nb, -1, size=(640, 480))
|
||||
shellWin = shell.Shell(win, -1, introText=intro)
|
||||
fillingWin = filling.Filling(win, -1, size=(640, 480),
|
||||
rootObject=shellWin.interp.locals,
|
||||
rootIsNamespace=1
|
||||
)
|
||||
win.SplitHorizontally(shellWin, fillingWin)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = filling.__doc__
|
||||
|
||||
379
wxPython/demo/SlashDot.py
Normal file
@@ -0,0 +1,379 @@
|
||||
#!/usr/bin/python
|
||||
"""This is SlashDot 1.2
|
||||
|
||||
It's the obligatory Slashdot.org headlines reader that
|
||||
any modern widget set/library must have in order to be taken
|
||||
seriously :-)
|
||||
|
||||
Usage is quite simple; wxSlash attempts to download the
|
||||
'ultramode.txt' file from http://slashdot.org, which
|
||||
contains the headlines in a computer friendly format. It
|
||||
then displays said headlines in a wxWindows list control.
|
||||
|
||||
You can read articles using either Python's html library
|
||||
or an external browser. Uncheck the 'browser->internal' menu
|
||||
item to use the latter option. Use the settings dialog box
|
||||
to set which external browser is started.
|
||||
|
||||
This code is available under the wxWindows license, see
|
||||
elsewhere. If you modify this code, be aware of the fact
|
||||
that slashdot.org's maintainer, CmdrTaco, explicitly asks
|
||||
'ultramode.txt' downloaders not to do this automatically
|
||||
more than twice per hour. If this feature is abused,
|
||||
CmdrTaco may remove the ultramode file completely and that
|
||||
will make a *lot* of people unhappy.
|
||||
|
||||
I want to thank Alex Shnitman whose slashes.pl
|
||||
(Perl/GTK) script gave me the idea for this applet.
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
from httplib import HTTP
|
||||
from htmllib import HTMLParser
|
||||
import os
|
||||
import re
|
||||
import formatter
|
||||
|
||||
class HTMLTextView(wxFrame):
|
||||
def __init__(self, parent, id, title='HTMLTextView', url=None):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(600,400))
|
||||
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(201, '&Open URL...', 'Open URL')
|
||||
EVT_MENU(self, 201, self.OnFileOpen)
|
||||
menu.Append(209, 'E&xit', 'Exit viewer')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.CreateStatusBar(1)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "", wxPyDefaultPosition,
|
||||
wxPyDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
if (url):
|
||||
self.OpenURL(url)
|
||||
|
||||
def logprint(self, x):
|
||||
self.SetStatusText(x)
|
||||
|
||||
def OpenURL(self, url):
|
||||
self.url = url
|
||||
m = re.match('file:(\S+)\s*', url)
|
||||
if m:
|
||||
f = open(m.groups()[0],'r')
|
||||
else:
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = RetrieveAsFile(host,path,self.logprint)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('tmphtml.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
tmp = open('tmphtml.txt', 'r')
|
||||
self.text.SetValue(tmp.read())
|
||||
self.SetTitle(url)
|
||||
self.logprint(url)
|
||||
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter URL to open:", "")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
url = dlg.GetValue()
|
||||
else:
|
||||
url = None
|
||||
if url:
|
||||
self.OpenURL(url)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
def ParseSlashdot(f):
|
||||
art_sep = re.compile('%%\r?\n')
|
||||
line_sep = re.compile('\r?\n')
|
||||
data = f.read()
|
||||
list = art_sep.split(data)
|
||||
art_list = []
|
||||
for i in range(1,len(list)-1):
|
||||
art_list.append(line_sep.split(list[i]))
|
||||
return art_list
|
||||
|
||||
def myprint(x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(host, path='', logprint = myprint):
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
# f = open('/home/harm/ultramode.txt','r')
|
||||
return f
|
||||
|
||||
|
||||
class AppStatusBar(wxStatusBar):
|
||||
def __init__(self, parent):
|
||||
wxStatusBar.__init__(self,parent, -1)
|
||||
self.SetFieldsCount(2)
|
||||
self.SetStatusWidths([-1, 100])
|
||||
self.but = wxButton(self, 1001, "Refresh")
|
||||
EVT_BUTTON(self, 1001, parent.OnViewRefresh)
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
self.OnSize(None)
|
||||
|
||||
def logprint(self,x):
|
||||
self.SetStatusText(x,0)
|
||||
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.but.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.but.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
# This is a simple timer class to start a function after a short delay;
|
||||
class QuickTimer(wxTimer):
|
||||
def __init__(self, func, wait=100):
|
||||
wxTimer.__init__(self)
|
||||
self.callback = func
|
||||
self.Start(wait); # wait .1 second (.001 second doesn't work. why?)
|
||||
def Notify(self):
|
||||
self.Stop();
|
||||
apply(self.callback, ());
|
||||
|
||||
class AppFrame(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(650, 250))
|
||||
|
||||
# if the window manager closes the window:
|
||||
EVT_CLOSE(self, self.OnCloseWindow);
|
||||
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(209, 'E&xit', 'Enough of this already!')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
menu = wxMenu()
|
||||
menu.Append(210, '&Refresh', 'Refresh headlines')
|
||||
EVT_MENU(self, 210, self.OnViewRefresh)
|
||||
menu.Append(211, '&Slashdot Index', 'View Slashdot index')
|
||||
EVT_MENU(self, 211, self.OnViewIndex)
|
||||
menu.Append(212, 'Selected &Article', 'View selected article')
|
||||
EVT_MENU(self, 212, self.OnViewArticle)
|
||||
self.mainmenu.Append(menu, '&View')
|
||||
menu = wxMenu()
|
||||
menu.Append(220, '&Internal', 'Use internal text browser',TRUE)
|
||||
menu.Check(220, true)
|
||||
self.UseInternal = 1;
|
||||
EVT_MENU(self, 220, self.OnBrowserInternal)
|
||||
menu.Append(222, '&Settings...', 'External browser Settings')
|
||||
EVT_MENU(self, 222, self.OnBrowserSettings)
|
||||
self.mainmenu.Append(menu, '&Browser')
|
||||
menu = wxMenu()
|
||||
menu.Append(230, '&About', 'Some documentation');
|
||||
EVT_MENU(self, 230, self.OnAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
if wxPlatform == '__WXGTK__':
|
||||
# I like lynx. Also Netscape 4.5 doesn't react to my cmdline opts
|
||||
self.BrowserSettings = "xterm -e lynx %s &"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
# netscape 4.x likes to hang out here...
|
||||
self.BrowserSettings = '\\progra~1\\Netscape\\Communicator\\Program\\netscape.exe %s'
|
||||
else:
|
||||
# a wild guess...
|
||||
self.BrowserSettings = 'netscape %s'
|
||||
|
||||
# A status bar to tell people what's happening
|
||||
self.sb = AppStatusBar(self)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
self.list = wxListCtrl(self, 1100, style=wxLC_REPORT)
|
||||
self.list.InsertColumn(0, 'Subject')
|
||||
self.list.InsertColumn(1, 'Date')
|
||||
self.list.InsertColumn(2, 'Posted by')
|
||||
self.list.InsertColumn(3, 'Comments')
|
||||
self.list.SetColumnWidth(0, 300)
|
||||
self.list.SetColumnWidth(1, 150)
|
||||
self.list.SetColumnWidth(2, 100)
|
||||
self.list.SetColumnWidth(3, 100)
|
||||
|
||||
EVT_LIST_ITEM_SELECTED(self, 1100, self.OnItemSelected)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnLeftDClick)
|
||||
|
||||
self.logprint("Connecting to slashdot... Please wait.")
|
||||
# wxYield doesn't yet work here. That's why we use a timer
|
||||
# to make sure that we see some GUI stuff before the slashdot
|
||||
# file is transfered.
|
||||
self.timer = QuickTimer(self.DoRefresh, 1000)
|
||||
|
||||
def logprint(self, x):
|
||||
self.sb.logprint(x)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def DoRefresh(self):
|
||||
f = RetrieveAsFile('slashdot.org','/ultramode.txt',self.sb.logprint)
|
||||
art_list = ParseSlashdot(f)
|
||||
self.list.DeleteAllItems()
|
||||
self.url = []
|
||||
self.current = -1
|
||||
i = 0;
|
||||
for article in art_list:
|
||||
self.list.InsertStringItem(i, article[0])
|
||||
self.list.SetStringItem(i, 1, article[2])
|
||||
self.list.SetStringItem(i, 2, article[3])
|
||||
self.list.SetStringItem(i, 3, article[6])
|
||||
self.url.append(article[1])
|
||||
i = i + 1
|
||||
self.logprint("File retrieved OK.")
|
||||
|
||||
def OnViewRefresh(self, event):
|
||||
self.logprint("Connecting to slashdot... Please wait.");
|
||||
wxYield()
|
||||
self.DoRefresh()
|
||||
|
||||
def DoViewIndex(self):
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, 'slashdot.org',
|
||||
'http://slashdot.org')
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % ('http://slashdot.org'))
|
||||
#os.system(self.BrowserSettings % ('http://slashdot.org'))
|
||||
wxExecute(self.BrowserSettings % ('http://slashdot.org'))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewIndex(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewIndex()
|
||||
|
||||
def DoViewArticle(self):
|
||||
if self.current<0: return
|
||||
url = self.url[self.current]
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, url, url)
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % (url))
|
||||
os.system(self.BrowserSettings % (url))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewArticle(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
|
||||
def OnBrowserInternal(self, event):
|
||||
if self.mainmenu.Checked(220):
|
||||
self.UseInternal = 1
|
||||
else:
|
||||
self.UseInternal = 0
|
||||
|
||||
def OnBrowserSettings(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter command to view URL.\nUse %s as a placeholder for the URL.", "", self.BrowserSettings);
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.BrowserSettings = dlg.GetValue()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.current = event.m_itemIndex
|
||||
self.logprint("URL: %s" % (self.url[self.current]))
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
# Actually, we should convert x,y to logical coords using
|
||||
# a dc, but only for a wxScrolledWindow widget.
|
||||
# Now wxGTK derives wxListCtrl from wxScrolledWindow,
|
||||
# and wxMSW from wxControl... So that doesn't work.
|
||||
#dc = wxClientDC(self.list)
|
||||
##self.list.PrepareDC(dc)
|
||||
#x = dc.DeviceToLogicalX( event.GetX() )
|
||||
#y = dc.DeviceToLogicalY( event.GetY() )
|
||||
id = self.list.HitTest(wxPoint(x,y))
|
||||
#print "Double click at %d %d" % (x,y), id
|
||||
# Okay, we got a double click. Let's assume it's the current selection
|
||||
wxYield()
|
||||
self.OnViewArticle(event)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == '__main__':
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = AppFrame(None, -1, "Slashdot Breaking News")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
82
wxPython/demo/VirtualListCtrl.py
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestVirtualList(wxListCtrl):
|
||||
def __init__(self, parent, log):
|
||||
wxListCtrl.__init__(self, parent, -1,
|
||||
style=wxLC_REPORT|wxLC_VIRTUAL|wxLC_HRULES|wxLC_VRULES)
|
||||
self.log = log
|
||||
|
||||
self.InsertColumn(0, "First")
|
||||
self.InsertColumn(1, "Second")
|
||||
self.InsertColumn(2, "Third")
|
||||
self.SetColumnWidth(0, 175)
|
||||
self.SetColumnWidth(1, 175)
|
||||
self.SetColumnWidth(2, 175)
|
||||
|
||||
self.SetItemCount(1000000)
|
||||
|
||||
self.attr1 = wxListItemAttr()
|
||||
self.attr1.SetBackgroundColour("yellow")
|
||||
|
||||
self.attr2 = wxListItemAttr()
|
||||
self.attr2.SetBackgroundColour("light blue")
|
||||
|
||||
EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected)
|
||||
EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
|
||||
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText('OnItemSelected: "%s", "%s", "%s", "%s"\n' %
|
||||
(self.currentItem,
|
||||
self.GetItemText(self.currentItem),
|
||||
self.getColumnText(self.currentItem, 1),
|
||||
self.getColumnText(self.currentItem, 2)))
|
||||
|
||||
def OnItemActivated(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemActivated: %s\n" % self.GetItemText(self.currentItem))
|
||||
|
||||
def getColumnText(self, index, col):
|
||||
item = self.GetItem(index, col)
|
||||
return item.GetText()
|
||||
|
||||
#---------------------------------------------------
|
||||
# These methods are callbacks for implementing the
|
||||
# "virtualness" of the list...
|
||||
def OnGetItemText(self, item, col):
|
||||
return "Item %d, column %d" % (item, col)
|
||||
|
||||
def OnGetItemImage(self, item):
|
||||
return 0
|
||||
|
||||
def OnGetItemAttr(self, item):
|
||||
if item % 3 == 1:
|
||||
return self.attr1
|
||||
elif item % 3 == 2:
|
||||
return self.attr2
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestVirtualList(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
49
wxPython/demo/XML_Resource.py
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.xrc import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
RESFILE = "data/resource_wdr.xrc"
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
# make the components
|
||||
label = wxStaticText(self, -1, "The lower panel was built from this XML:")
|
||||
label.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
|
||||
|
||||
text = wxTextCtrl(self, -1, open(RESFILE).read(),
|
||||
style=wxTE_READONLY|wxTE_MULTILINE)
|
||||
text.SetInsertionPoint(0)
|
||||
|
||||
line = wxStaticLine(self, -1)
|
||||
|
||||
res = wxXmlResource(RESFILE)
|
||||
panel = res.LoadPanel(self, "MyPanel")
|
||||
|
||||
# and do the layout
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(label, 0, wxEXPAND|wxTOP|wxLEFT, 5)
|
||||
sizer.Add(text, 1, wxEXPAND|wxALL, 5)
|
||||
sizer.Add(line, 0, wxEXPAND)
|
||||
sizer.Add(panel, 1, wxEXPAND|wxALL, 5)
|
||||
|
||||
self.SetSizer(sizer)
|
||||
self.SetAutoLayout(true)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """
|
||||
"""
|
||||
BIN
wxPython/demo/bitmaps/01c.gif
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
wxPython/demo/bitmaps/10s.gif
Normal file
|
After Width: | Height: | Size: 990 B |
BIN
wxPython/demo/bitmaps/12h.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
wxPython/demo/bitmaps/13d.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
wxPython/demo/bitmaps/Calend.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/DbDec.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/DbInc.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/Dec.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/Inc.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/Pt.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bitmaps/backgrnd.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
wxPython/demo/bitmaps/copy.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bitmaps/lb1.bmp
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
wxPython/demo/bitmaps/lb2.bmp
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
wxPython/demo/bitmaps/mondrian.ico
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
wxPython/demo/bitmaps/new.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bitmaps/noicon.png
Normal file
|
After Width: | Height: | Size: 255 B |
BIN
wxPython/demo/bitmaps/open.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bitmaps/paste.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bitmaps/robin.jpg
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
wxPython/demo/bitmaps/smiles.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bitmaps/smiles.ico
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
wxPython/demo/bitmaps/splash.gif
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
wxPython/demo/bitmaps/test2.bmp
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
wxPython/demo/bitmaps/test_image.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
wxPython/demo/bitmaps/test_mask.bmp
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
wxPython/demo/bitmaps/tog1.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bitmaps/tog2.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bmp_source/01c.gif
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
wxPython/demo/bmp_source/10s.gif
Normal file
|
After Width: | Height: | Size: 990 B |
BIN
wxPython/demo/bmp_source/12h.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
wxPython/demo/bmp_source/13d.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
wxPython/demo/bmp_source/Calend.bmp
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
wxPython/demo/bmp_source/Tux.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
wxPython/demo/bmp_source/copy.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bmp_source/copy2.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/eclouds.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
wxPython/demo/bmp_source/file1.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/file2.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/folder1.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/folder2.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/folder3.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/lb1.bmp
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
wxPython/demo/bmp_source/lb2.bmp
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
wxPython/demo/bmp_source/new.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bmp_source/open.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bmp_source/paste.bmp
Normal file
|
After Width: | Height: | Size: 238 B |
BIN
wxPython/demo/bmp_source/smiles.bmp
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
wxPython/demo/bmp_source/toblom01.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
wxPython/demo/bmp_source/toblom02.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom03.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom04.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom05.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
wxPython/demo/bmp_source/toblom06.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom07.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
wxPython/demo/bmp_source/toblom08.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom09.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom10.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
wxPython/demo/bmp_source/toblom11.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom12.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
wxPython/demo/bmp_source/toblom13.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/toblom14.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
wxPython/demo/bmp_source/toblom15.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
1799
wxPython/demo/data/grid.i
Normal file
BIN
wxPython/demo/data/pic2.gif
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
627
wxPython/demo/data/stc.h
Normal file
@@ -0,0 +1,627 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Name: stc.h
|
||||
// Purpose: A wxWindows implementation of Scintilla. This class is the
|
||||
// one meant to be used directly by wx applications. It does not
|
||||
// derive directly from the Scintilla classes, and in fact there
|
||||
// is no mention of Scintilla classes at all in this header.
|
||||
// This class delegates all method calls and events to the
|
||||
// Scintilla objects and so forth. This allows the use of
|
||||
// Scintilla without polluting the namespace with all the
|
||||
// classes and itentifiers from Scintilla.
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 13-Jan-2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __stc_h__
|
||||
#define __stc_h__
|
||||
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// constants and stuff
|
||||
|
||||
enum wxSTC_UndoType {
|
||||
wxSTC_UndoCollectNone,
|
||||
wxSTC_UndoCollectAutoStart
|
||||
};
|
||||
|
||||
|
||||
enum wxSTC_EOL {
|
||||
wxSTC_EOL_CRLF,
|
||||
wxSTC_EOL_CR,
|
||||
wxSTC_EOL_LF
|
||||
};
|
||||
|
||||
enum wxSTC_EDGE {
|
||||
wxSTC_EDGE_NONE,
|
||||
wxSTC_EDGE_LINE,
|
||||
wxSTC_EDGE_BACKGROUND
|
||||
};
|
||||
|
||||
|
||||
|
||||
const int wxSTC_LEX_STYLE_MAX = 31;
|
||||
const int wxSTC_STYLE_DEFAULT = 32;
|
||||
const int wxSTC_STYLE_LINENUMBER = 33;
|
||||
const int wxSTC_STYLE_BRACELIGHT = 34;
|
||||
const int wxSTC_STYLE_BRACEBAD = 35;
|
||||
const int wxSTC_STYLE_CONTROLCHAR = 36;
|
||||
const int wxSTC_STYLE_MAX = 127;
|
||||
const int wxSTC_STYLE_MASK = 31;
|
||||
|
||||
const int wxSTC_MARKER_MAX = 31;
|
||||
const int wxSTC_MARK_CIRCLE = 0;
|
||||
const int wxSTC_MARK_ROUNDRECT = 1;
|
||||
const int wxSTC_MARK_ARROW = 2;
|
||||
const int wxSTC_MARK_SMALLRECT = 3;
|
||||
const int wxSTC_MARK_SHORTARROW = 4;
|
||||
const int wxSTC_MARK_EMPTY = 5;
|
||||
const int wxSTC_MARK_ARROWDOWN = 6;
|
||||
const int wxSTC_MARK_MINUS = 7;
|
||||
const int wxSTC_MARK_PLUS = 8;
|
||||
|
||||
const int wxSTC_MARKNUM_FOLDER = 30;
|
||||
const int wxSTC_MARKNUM_FOLDEROPEN= 31;
|
||||
const int wxSTC_MASK_FOLDERS = ((1 << wxSTC_MARKNUM_FOLDER) | (1 << wxSTC_MARKNUM_FOLDEROPEN));
|
||||
|
||||
const int wxSTC_INDIC_MAX = 7;
|
||||
const int wxSTC_INDIC_PLAIN = 0;
|
||||
const int wxSTC_INDIC_SQUIGGLE = 1;
|
||||
const int wxSTC_INDIC_TT = 2;
|
||||
const int wxSTC_INDIC0_MASK = 32;
|
||||
const int wxSTC_INDIC1_MASK = 64;
|
||||
const int wxSTC_INDIC2_MASK = 128;
|
||||
const int wxSTC_INDICS_MASK = (wxSTC_INDIC0_MASK | wxSTC_INDIC1_MASK | wxSTC_INDIC2_MASK);
|
||||
|
||||
|
||||
const int wxSTC_FOLDLEVELBASE = 0x0400;
|
||||
const int wxSTC_FOLDLEVELWHITEFLAG = 0x1000;
|
||||
const int wxSTC_FOLDLEVELHEADERFLAG = 0x2000;
|
||||
const int wxSTC_FOLDLEVELNUMBERMASK = 0x0FFF;
|
||||
|
||||
|
||||
// key commands
|
||||
enum {
|
||||
wxSTC_CMD_LINEDOWN = 2300,
|
||||
wxSTC_CMD_LINEDOWNEXTEND,
|
||||
wxSTC_CMD_LINEUP,
|
||||
wxSTC_CMD_LINEUPEXTEND,
|
||||
wxSTC_CMD_CHARLEFT,
|
||||
wxSTC_CMD_CHARLEFTEXTEND,
|
||||
wxSTC_CMD_CHARRIGHT,
|
||||
wxSTC_CMD_CHARRIGHTEXTEND,
|
||||
wxSTC_CMD_WORDLEFT,
|
||||
wxSTC_CMD_WORDLEFTEXTEND,
|
||||
wxSTC_CMD_WORDRIGHT,
|
||||
wxSTC_CMD_WORDRIGHTEXTEND,
|
||||
wxSTC_CMD_HOME,
|
||||
wxSTC_CMD_HOMEEXTEND,
|
||||
wxSTC_CMD_LINEEND,
|
||||
wxSTC_CMD_LINEENDEXTEND,
|
||||
wxSTC_CMD_DOCUMENTSTART,
|
||||
wxSTC_CMD_DOCUMENTSTARTEXTEND,
|
||||
wxSTC_CMD_DOCUMENTEND,
|
||||
wxSTC_CMD_DOCUMENTENDEXTEND,
|
||||
wxSTC_CMD_PAGEUP,
|
||||
wxSTC_CMD_PAGEUPEXTEND,
|
||||
wxSTC_CMD_PAGEDOWN,
|
||||
wxSTC_CMD_PAGEDOWNEXTEND,
|
||||
wxSTC_CMD_EDITTOGGLEOVERTYPE,
|
||||
wxSTC_CMD_CANCEL,
|
||||
wxSTC_CMD_DELETEBACK,
|
||||
wxSTC_CMD_TAB,
|
||||
wxSTC_CMD_BACKTAB,
|
||||
wxSTC_CMD_NEWLINE,
|
||||
wxSTC_CMD_FORMFEED,
|
||||
wxSTC_CMD_VCHOME,
|
||||
wxSTC_CMD_VCHOMEEXTEND,
|
||||
wxSTC_CMD_ZOOMIN,
|
||||
wxSTC_CMD_ZOOMOUT,
|
||||
wxSTC_CMD_DELWORDLEFT,
|
||||
wxSTC_CMD_DELWORDRIGHT,
|
||||
wxSTC_CMD_LINECUT,
|
||||
wxSTC_CMD_LINEDELETE,
|
||||
wxSTC_CMD_LINETRANSPOSE,
|
||||
wxSTC_CMD_LOWERCASE,
|
||||
wxSTC_CMD_UPPERCASE,
|
||||
wxSTC_CMD_LINESCROLLDOWN,
|
||||
wxSTC_CMD_LINESCROLLUP
|
||||
};
|
||||
|
||||
|
||||
enum wxSTC_LEX {
|
||||
wxSTC_LEX_CONTAINER=0,
|
||||
wxSTC_LEX_NULL,
|
||||
wxSTC_LEX_PYTHON,
|
||||
wxSTC_LEX_CPP,
|
||||
wxSTC_LEX_HTML,
|
||||
wxSTC_LEX_XML,
|
||||
wxSTC_LEX_PERL,
|
||||
wxSTC_LEX_SQL,
|
||||
wxSTC_LEX_VB,
|
||||
wxSTC_LEX_PROPERTIES,
|
||||
wxSTC_LEX_ERRORLIST,
|
||||
wxSTC_LEX_MAKEFILE,
|
||||
wxSTC_LEX_BATCH,
|
||||
};
|
||||
|
||||
|
||||
|
||||
const int wxSTC_CARET_SLOP = 0x01;
|
||||
const int WXSTC_CARET_CENTER = 0x02;
|
||||
const int wxSTC_CARET_STRICT = 0x04;
|
||||
|
||||
const int wxSTC_MARGIN_SYMBOL = 0;
|
||||
const int wxSTC_MARGIN_NUMBER = 1;
|
||||
|
||||
|
||||
class ScintillaWX; // forward declare
|
||||
class WordList;
|
||||
struct SCNotification;
|
||||
|
||||
|
||||
extern const wxChar* wxSTCNameStr;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextCtrl : public wxControl {
|
||||
public:
|
||||
|
||||
#ifdef SWIG
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const char* name = wxSTCNameStr);
|
||||
#else
|
||||
wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = wxSTCNameStr);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
~wxStyledTextCtrl();
|
||||
#endif
|
||||
|
||||
|
||||
// Text retrieval and modification
|
||||
wxString GetText();
|
||||
bool SetText(const wxString& text);
|
||||
wxString GetLine(int line);
|
||||
void ReplaceSelection(const wxString& text);
|
||||
void SetReadOnly(bool readOnly);
|
||||
bool GetReadOnly();
|
||||
wxString GetTextRange(int startPos, int endPos);
|
||||
wxString GetStyledTextRange(int startPos, int endPos);
|
||||
#ifndef SWIG
|
||||
void GetTextRange(int startPos, int endPos, char* buff);
|
||||
void GetStyledTextRange(int startPos, int endPos, char* buff);
|
||||
#endif
|
||||
void AddText(const wxString& text);
|
||||
void AddStyledText(const wxString& text);
|
||||
void InsertText(int pos, const wxString& text);
|
||||
void ClearAll();
|
||||
char GetCharAt(int pos);
|
||||
char GetStyleAt(int pos);
|
||||
void SetStyleBits(int bits);
|
||||
int GetStyleBits();
|
||||
|
||||
|
||||
// Clipboard
|
||||
void Cut();
|
||||
void Copy();
|
||||
void Paste();
|
||||
bool CanPaste();
|
||||
void ClearClipbrd(); // avoiding name conflict with virtual in wxWindow
|
||||
|
||||
|
||||
// Undo and Redo
|
||||
void Undo();
|
||||
bool CanUndo();
|
||||
void EmptyUndoBuffer();
|
||||
void Redo();
|
||||
bool CanRedo();
|
||||
void SetUndoCollection(wxSTC_UndoType type);
|
||||
wxSTC_UndoType GetUndoCollection();
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
|
||||
|
||||
// Selection and information
|
||||
#ifdef SWIG
|
||||
void GetSelection(int* OUTPUT, int* OUTPUT);
|
||||
#else
|
||||
void GetSelection(int* startPos, int* endPos);
|
||||
#endif
|
||||
void SetSelection(int startPos, int endPos);
|
||||
wxString GetSelectedText();
|
||||
void HideSelection(bool hide);
|
||||
bool GetHideSelection();
|
||||
|
||||
int GetTextLength();
|
||||
int GetFirstVisibleLine();
|
||||
bool GetModified();
|
||||
int GetLineCount();
|
||||
wxRect GetRect();
|
||||
int GetLineFromPos(int pos);
|
||||
int GetLineStartPos(int line);
|
||||
int GetLineLengthAtPos(int pos);
|
||||
int GetLineLength(int line);
|
||||
#ifdef SWIG
|
||||
wxString GetCurrentLineText(int* OUTPUT);
|
||||
#else
|
||||
wxString GetCurrentLineText(int* linePos);
|
||||
#endif
|
||||
int GetCurrentLine();
|
||||
int PositionFromPoint(wxPoint pt);
|
||||
int LineFromPoint(wxPoint pt);
|
||||
wxPoint PointFromPosition(int pos);
|
||||
int GetCurrentPos();
|
||||
int GetAnchor();
|
||||
void SelectAll();
|
||||
void SetCurrentPosition(int pos);
|
||||
void SetAnchor(int pos);
|
||||
void GotoPos(int pos);
|
||||
void GotoLine(int line);
|
||||
void ChangePosition(int delta, bool extendSelection);
|
||||
void PageMove(int cmdKey, bool extendSelection);
|
||||
|
||||
void ScrollBy(int columnDelta, int lineDelta);
|
||||
void ScrollToLine(int line);
|
||||
void ScrollToColumn(int column);
|
||||
void EnsureCaretVisible();
|
||||
void SetCaretPolicy(int policy, int slop=0);
|
||||
int GetSelectionType();
|
||||
int GetLinesOnScreen();
|
||||
bool IsSelectionRectangle();
|
||||
void SetUseHorizontalScrollBar(bool use);
|
||||
bool GetUseHorizontalScrollBar();
|
||||
|
||||
|
||||
// Searching
|
||||
int FindText(int minPos, int maxPos, const wxString& text,
|
||||
bool caseSensitive, bool wholeWord);
|
||||
void SearchAnchor();
|
||||
int SearchNext(const wxString& text, bool caseSensitive, bool wholeWord);
|
||||
int SearchPrev(const wxString& text, bool caseSensitive, bool wholeWord);
|
||||
|
||||
|
||||
// Visible whitespace
|
||||
bool GetViewWhitespace();
|
||||
void SetViewWhitespace(bool visible);
|
||||
|
||||
|
||||
// Line endings
|
||||
wxSTC_EOL GetEOLMode();
|
||||
void SetEOLMode(wxSTC_EOL mode);
|
||||
bool GetViewEOL();
|
||||
void SetViewEOL(bool visible);
|
||||
void ConvertEOL(wxSTC_EOL mode);
|
||||
|
||||
|
||||
// Styling
|
||||
int GetEndStyled();
|
||||
void StartStyling(int pos, int mask);
|
||||
void SetStyleFor(int length, int style);
|
||||
void SetStyleBytes(int length, char* styleBytes);
|
||||
void SetLineState(int line, int value);
|
||||
int GetLineState(int line);
|
||||
|
||||
|
||||
// Style Definition
|
||||
void StyleClearAll();
|
||||
void StyleResetDefault();
|
||||
void StyleSetSpec(int styleNum, const wxString& spec);
|
||||
void StyleSetForeground(int styleNum, const wxColour& colour);
|
||||
void StyleSetBackground(int styleNum, const wxColour& colour);
|
||||
void StyleSetFont(int styleNum, wxFont& font);
|
||||
void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold, bool italic);
|
||||
void StyleSetBold(int styleNum, bool bold);
|
||||
void StyleSetItalic(int styleNum, bool italic);
|
||||
void StyleSetFaceName(int styleNum, const wxString& faceName);
|
||||
void StyleSetSize(int styleNum, int pointSize);
|
||||
void StyleSetEOLFilled(int styleNum, bool fillEOL);
|
||||
|
||||
|
||||
// Margins in the edit area
|
||||
int GetLeftMargin();
|
||||
int GetRightMargin();
|
||||
void SetMargins(int left, int right);
|
||||
|
||||
|
||||
// Margins for selection, markers, etc.
|
||||
void SetMarginType(int margin, int type);
|
||||
int GetMarginType(int margin);
|
||||
void SetMarginWidth(int margin, int pixelWidth);
|
||||
int GetMarginWidth(int margin);
|
||||
void SetMarginMask(int margin, int mask);
|
||||
int GetMarginMask(int margin);
|
||||
void SetMarginSensitive(int margin, bool sensitive);
|
||||
bool GetMarginSensitive(int margin);
|
||||
|
||||
|
||||
// Selection and Caret styles
|
||||
void SetSelectionForeground(const wxColour& colour);
|
||||
void SetSelectionBackground(const wxColour& colour);
|
||||
void SetCaretForeground(const wxColour& colour);
|
||||
int GetCaretPeriod();
|
||||
void SetCaretPeriod(int milliseconds);
|
||||
|
||||
|
||||
// Other settings
|
||||
void SetBufferedDraw(bool isBuffered);
|
||||
void SetTabWidth(int numChars);
|
||||
void SetIndent(int numChars);
|
||||
void SetUseTabs(bool usetabs);
|
||||
void SetLineIndentation(int line, int indentation);
|
||||
int GetLineIndentation(int line);
|
||||
int GetLineIndentationPos(int line);
|
||||
void SetWordChars(const wxString& wordChars);
|
||||
|
||||
void SetUsePop(bool usepopup);
|
||||
|
||||
|
||||
// Brace highlighting
|
||||
void BraceHighlight(int pos1, int pos2);
|
||||
void BraceBadlight(int pos);
|
||||
int BraceMatch(int pos, int maxReStyle=0);
|
||||
|
||||
|
||||
// Markers
|
||||
void MarkerDefine(int markerNumber, int markerSymbol,
|
||||
const wxColour& foreground,
|
||||
const wxColour& background);
|
||||
void MarkerSetType(int markerNumber, int markerSymbol);
|
||||
void MarkerSetForeground(int markerNumber, const wxColour& colour);
|
||||
void MarkerSetBackground(int markerNumber, const wxColour& colour);
|
||||
int MarkerAdd(int line, int markerNumber);
|
||||
void MarkerDelete(int line, int markerNumber);
|
||||
void MarkerDeleteAll(int markerNumber);
|
||||
int MarkerGet(int line);
|
||||
int MarkerGetNextLine(int lineStart, int markerMask);
|
||||
int MarkerGetPrevLine(int lineStart, int markerMask);
|
||||
int MarkerLineFromHandle(int handle);
|
||||
void MarkerDeleteHandle(int handle);
|
||||
|
||||
|
||||
// Indicators
|
||||
void IndicatorSetStyle(int indicNum, int indicStyle);
|
||||
int IndicatorGetStyle(int indicNum);
|
||||
void IndicatorSetColour(int indicNum, const wxColour& colour);
|
||||
|
||||
|
||||
// Auto completion
|
||||
void AutoCompShow(const wxString& listOfWords);
|
||||
void AutoCompCancel();
|
||||
bool AutoCompActive();
|
||||
int AutoCompPosAtStart();
|
||||
void AutoCompComplete();
|
||||
void AutoCompStopChars(const wxString& stopChars);
|
||||
void AutoCompSetSeparator(char separator);
|
||||
char AutoCompGetSeparator();
|
||||
void AutoCompSelect(const wxString& stringtoselect);
|
||||
|
||||
// Call tips
|
||||
void CallTipShow(int pos, const wxString& text);
|
||||
void CallTipCancel();
|
||||
bool CallTipActive();
|
||||
int CallTipPosAtStart();
|
||||
void CallTipSetHighlight(int start, int end);
|
||||
void CallTipSetBackground(const wxColour& colour);
|
||||
|
||||
|
||||
// Key bindings
|
||||
void CmdKeyAssign(int key, int modifiers, int cmd);
|
||||
void CmdKeyClear(int key, int modifiers);
|
||||
void CmdKeyClearAll();
|
||||
void CmdKeyExecute(int cmd);
|
||||
|
||||
|
||||
// Print formatting
|
||||
int FormatRange(bool doDraw,
|
||||
int startPos,
|
||||
int endPos,
|
||||
wxDC* draw,
|
||||
wxDC* target, // Why does it use two? Can they be the same?
|
||||
wxRect renderRect,
|
||||
wxRect pageRect);
|
||||
|
||||
|
||||
// Document Sharing (multiple views)
|
||||
void* GetDocument();
|
||||
void SetDocument(void* document);
|
||||
// TODO: create a wx wrapper for Scintilla's document class
|
||||
|
||||
|
||||
// Folding
|
||||
int VisibleFromDocLine(int docLine);
|
||||
int DocLineFromVisible(int displayLine);
|
||||
int SetFoldLevel(int line, int level);
|
||||
int GetFoldLevel(int line);
|
||||
int GetLastChild(int line, int level);
|
||||
int GetFoldParent(int line);
|
||||
void ShowLines(int lineStart, int lineEnd);
|
||||
void HideLines(int lineStart, int lineEnd);
|
||||
bool GetLineVisible(int line);
|
||||
void SetFoldExpanded(int line, bool expanded);
|
||||
bool GetFoldExpanded(int line);
|
||||
void ToggleFold(int line);
|
||||
void EnsureVisible(int line);
|
||||
void SetFoldFlags(int flags);
|
||||
|
||||
|
||||
// Long Lines
|
||||
int GetEdgeColumn();
|
||||
void SetEdgeColumn(int column);
|
||||
wxSTC_EDGE GetEdgeMode();
|
||||
void SetEdgeMode(wxSTC_EDGE mode);
|
||||
wxColour GetEdgeColour();
|
||||
void SetEdgeColour(const wxColour& colour);
|
||||
|
||||
|
||||
// Lexer
|
||||
void SetLexer(wxSTC_LEX lexer);
|
||||
wxSTC_LEX GetLexer();
|
||||
void Colourise(int start, int end);
|
||||
void SetProperty(const wxString& key, const wxString& value);
|
||||
void SetKeywords(int keywordSet, const wxString& keywordList);
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
private:
|
||||
// Event handlers
|
||||
void OnPaint(wxPaintEvent& evt);
|
||||
void OnScrollWin(wxScrollWinEvent& evt);
|
||||
void OnSize(wxSizeEvent& evt);
|
||||
void OnMouseLeftDown(wxMouseEvent& evt);
|
||||
void OnMouseMove(wxMouseEvent& evt);
|
||||
void OnMouseLeftUp(wxMouseEvent& evt);
|
||||
void OnMouseRightUp(wxMouseEvent& evt);
|
||||
void OnChar(wxKeyEvent& evt);
|
||||
void OnKeyDown(wxKeyEvent& evt);
|
||||
void OnLoseFocus(wxFocusEvent& evt);
|
||||
void OnGainFocus(wxFocusEvent& evt);
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& evt);
|
||||
void OnEraseBackground(wxEraseEvent& evt);
|
||||
void OnMenu(wxCommandEvent& evt);
|
||||
void OnListBox(wxCommandEvent& evt);
|
||||
|
||||
|
||||
// Turn notifications from Scintilla into events
|
||||
void NotifyChange();
|
||||
void NotifyParent(SCNotification* scn);
|
||||
|
||||
long SendMsg(int msg, long wp=0, long lp=0);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxStyledTextCtrl)
|
||||
|
||||
ScintillaWX* m_swx;
|
||||
wxStopWatch m_stopWatch;
|
||||
bool m_readOnly;
|
||||
wxSTC_UndoType m_undoType;
|
||||
|
||||
|
||||
friend class ScintillaWX;
|
||||
friend class Platform;
|
||||
#endif
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class wxStyledTextEvent : public wxCommandEvent {
|
||||
public:
|
||||
wxStyledTextEvent(wxEventType commandType=0, int id=0);
|
||||
~wxStyledTextEvent() {}
|
||||
|
||||
void SetPosition(int pos) { m_position = pos; }
|
||||
void SetKey(int k) { m_key = k; }
|
||||
void SetModifiers(int m) { m_modifiers = m; }
|
||||
void SetModificationType(int t) { m_modificationType = t; }
|
||||
void SetText(const char* t) { m_text = t; }
|
||||
void SetLength(int len) { m_length = len; }
|
||||
void SetLinesAdded(int num) { m_linesAdded = num; }
|
||||
void SetLine(int val) { m_line = val; }
|
||||
void SetFoldLevelNow(int val) { m_foldLevelNow = val; }
|
||||
void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; }
|
||||
void SetMargin(int val) { m_margin = val; }
|
||||
void SetMessage(int val) { m_message = val; }
|
||||
void SetWParam(int val) { m_wParam = val; }
|
||||
void SetLParam(int val) { m_lParam = val; }
|
||||
|
||||
int GetPosition() const { return m_position; }
|
||||
int GetKey() const { return m_key; }
|
||||
int GetModifiers() const { return m_modifiers; }
|
||||
int GetModificationType() const { return m_modificationType; }
|
||||
wxString GetText() const { return m_text; }
|
||||
int GetLength() const { return m_length; }
|
||||
int GetLinesAdded() const { return m_linesAdded; }
|
||||
int GetLine() const { return m_line; }
|
||||
int GetFoldLevelNow() const { return m_foldLevelNow; }
|
||||
int GetFoldLevelPrev() const { return m_foldLevelPrev; }
|
||||
int GetMargin() const { return m_margin; }
|
||||
int GetMessage() const { return m_message; }
|
||||
int GetWParam() const { return m_wParam; }
|
||||
int GetLParam() const { return m_lParam; }
|
||||
|
||||
bool GetShift() const;
|
||||
bool GetControl() const;
|
||||
bool GetAlt() const;
|
||||
|
||||
void CopyObject(wxObject& obj) const;
|
||||
|
||||
#ifndef SWIG
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxStyledTextEvent)
|
||||
|
||||
int m_position;
|
||||
int m_key;
|
||||
int m_modifiers;
|
||||
|
||||
int m_modificationType; // wxEVT_STC_MODIFIED
|
||||
wxString m_text;
|
||||
int m_length;
|
||||
int m_linesAdded;
|
||||
int m_line;
|
||||
int m_foldLevelNow;
|
||||
int m_foldLevelPrev;
|
||||
|
||||
int m_margin; // wxEVT_STC_MARGINCLICK
|
||||
|
||||
int m_message; // wxEVT_STC_MACRORECORD
|
||||
int m_wParam;
|
||||
int m_lParam;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
wxEVT_STC_CHANGE = 1650,
|
||||
wxEVT_STC_STYLENEEDED,
|
||||
wxEVT_STC_CHARADDED,
|
||||
wxEVT_STC_UPDATEUI,
|
||||
wxEVT_STC_SAVEPOINTREACHED,
|
||||
wxEVT_STC_SAVEPOINTLEFT,
|
||||
wxEVT_STC_ROMODIFYATTEMPT,
|
||||
wxEVT_STC_DOUBLECLICK,
|
||||
wxEVT_STC_MODIFIED,
|
||||
wxEVT_STC_KEY,
|
||||
wxEVT_STC_MACRORECORD,
|
||||
wxEVT_STC_MARGINCLICK,
|
||||
wxEVT_STC_NEEDSHOWN
|
||||
};
|
||||
|
||||
#ifndef SWIG
|
||||
typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
|
||||
|
||||
#define EVT_STC_CHANGE(id, fn) { wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_STYLENEEDED(id, fn) { wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_CHARADDED(id, fn) { wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_UPDATEUI(id, fn) { wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_SAVEPOINTREACHED(id, fn) { wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_SAVEPOINTLEFT(id, fn) { wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
#define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
|
||||
125
wxPython/demo/demoMainLoop.py
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env python
|
||||
#---------------------------------------------------------------------------
|
||||
# 11/9/2003 - Jeff Grimmett (grimmtooth@softhome.net
|
||||
#
|
||||
# o Updated for V2.5
|
||||
# o Mainloop is freezing up app.
|
||||
#
|
||||
|
||||
"""
|
||||
This demo attempts to override the C++ MainLoop and implement it
|
||||
in Python. This is not part of the demo framework.
|
||||
|
||||
|
||||
THIS FEATURE IS STILL EXPERIMENTAL...
|
||||
"""
|
||||
|
||||
import time
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wx.Frame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
wx.Frame.__init__(self, parent, id, title,
|
||||
(100, 100), (160, 150))
|
||||
|
||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||
self.Bind(wx.EVT_MOVE, self.OnMove)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_IDLE, self.OnIdle)
|
||||
|
||||
self.count = 0
|
||||
|
||||
panel = wx.Panel(self, -1)
|
||||
wx.StaticText(panel, -1, "Size:",
|
||||
wx.DLG_PNT(panel, (4, 4)), wx.DefaultSize)
|
||||
wx.StaticText(panel, -1, "Pos:",
|
||||
wx.DLG_PNT(panel, (4, 16)), wx.DefaultSize)
|
||||
|
||||
wx.StaticText(panel, -1, "Idle:",
|
||||
wx.DLG_PNT(panel, (4, 28)), wx.DefaultSize)
|
||||
|
||||
self.sizeCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, (24, 4)),
|
||||
wx.DLG_SZE(panel, (36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
self.posCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, (24, 16)),
|
||||
wx.DLG_SZE(panel, (36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
self.idleCtrl = wx.TextCtrl(panel, -1, "",
|
||||
wx.DLG_PNT(panel, (24, 28)),
|
||||
wx.DLG_SZE(panel, (36, -1)),
|
||||
wx.TE_READONLY)
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
app.keepGoing = False
|
||||
self.Destroy()
|
||||
|
||||
def OnIdle(self, event):
|
||||
self.idleCtrl.SetValue(str(self.count))
|
||||
self.count = self.count + 1
|
||||
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
|
||||
event.Skip()
|
||||
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wx.App):
|
||||
def MainLoop(self):
|
||||
# This outer loop determines when to exit the application, for
|
||||
# this example we let the main frame reset this flag when it
|
||||
# closes.
|
||||
while self.keepGoing:
|
||||
# At this point in the outer loop you could do whatever you
|
||||
# implemented your own MainLoop for. It should be quick and
|
||||
# non-blocking, otherwise your GUI will freeze. For example,
|
||||
# call Fnorb's reactor.do_one_event(0), etc.
|
||||
|
||||
# call_your_code_here()
|
||||
|
||||
|
||||
# This inner loop will process any GUI events until there
|
||||
# are no more waiting.
|
||||
while self.Pending():
|
||||
self.Dispatch()
|
||||
|
||||
# Send idle events to idle handlers. You may want to throttle
|
||||
# this back a bit so there is not too much CPU time spent in
|
||||
# the idle handlers. For this example, I'll just snooze a
|
||||
# little...
|
||||
time.sleep(0.25)
|
||||
self.ProcessIdle()
|
||||
|
||||
|
||||
|
||||
def OnInit(self):
|
||||
frame = MyFrame(None, -1, "This is a test")
|
||||
frame.Show(True)
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
self.keepGoing = True
|
||||
|
||||
return True
|
||||
|
||||
|
||||
app = MyApp(False)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
468
wxPython/demo/hangman.py
Normal file
@@ -0,0 +1,468 @@
|
||||
"""Hangman.py, a simple wxPython game, inspired by the
|
||||
old bsd game by Ken Arnold.
|
||||
From the original man page:
|
||||
|
||||
In hangman, the computer picks a word from the on-line
|
||||
word list and you must try to guess it. The computer
|
||||
keeps track of which letters have been guessed and how
|
||||
many wrong guesses you have made on the screen in a
|
||||
graphic fashion.
|
||||
|
||||
That says it all, doesn't it?
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
|
||||
|
||||
import random,re,string
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
|
||||
class WordFetcher:
|
||||
builtin_words = ' albatros banana electrometer eggshell'
|
||||
|
||||
def __init__(self, filename, min_length = 5):
|
||||
self.min_length = min_length
|
||||
print "Trying to open file %s" % (filename,)
|
||||
try:
|
||||
f = open(filename, "r")
|
||||
except:
|
||||
print "Couldn't open dictionary file %s, using builtins" % (filename,)
|
||||
self.words = self.builtin_words
|
||||
self.filename = None
|
||||
return
|
||||
self.words = f.read()
|
||||
self.filename = filename
|
||||
print "Got %d bytes." % (len(self.words),)
|
||||
|
||||
def SetMinLength(min_length):
|
||||
self.min_length = min_length
|
||||
|
||||
def Get(self):
|
||||
reg = re.compile('\s+([a-zA-Z]+)\s+')
|
||||
n = 50 # safety valve; maximum number of tries to find a suitable word
|
||||
while n:
|
||||
index = int(random.random()*len(self.words))
|
||||
m = reg.search(self.words[index:])
|
||||
if m and len(m.groups()[0]) >= self.min_length: break
|
||||
n = n - 1
|
||||
if n: return string.lower(m.groups()[0])
|
||||
return "error"
|
||||
|
||||
|
||||
|
||||
def stdprint(x):
|
||||
print x
|
||||
|
||||
|
||||
|
||||
class URLWordFetcher(WordFetcher):
|
||||
def __init__(self, url):
|
||||
self.OpenURL(url)
|
||||
WordFetcher.__init__(self, "hangman_dict.txt")
|
||||
|
||||
def logprint(self,x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(self, host, path=''):
|
||||
from httplib import HTTP
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
self.logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
self.logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
return f
|
||||
|
||||
def OpenURL(self,url):
|
||||
from htmllib import HTMLParser
|
||||
import formatter
|
||||
self.url = url
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = self.RetrieveAsFile(host,path)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('hangman_dict.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
|
||||
|
||||
|
||||
class HangmanWnd(wxWindow):
|
||||
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
||||
wxWindow.__init__(self, parent, id, pos, size)
|
||||
self.SetBackgroundColour(wxNamedColour('white'))
|
||||
if wxPlatform == '__WXGTK__':
|
||||
self.font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
else:
|
||||
self.font = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
self.SetFocus()
|
||||
EVT_PAINT(self, self.OnPaint)
|
||||
|
||||
|
||||
def StartGame(self, word):
|
||||
self.word = word
|
||||
self.guess = []
|
||||
self.tries = 0
|
||||
self.misses = 0
|
||||
self.Draw()
|
||||
|
||||
def EndGame(self):
|
||||
self.misses = 7;
|
||||
self.guess = map(chr, range(ord('a'),ord('z')+1))
|
||||
self.Draw()
|
||||
|
||||
def HandleKey(self, key):
|
||||
self.message = ""
|
||||
if self.guess.count(key):
|
||||
self.message = 'Already guessed %s' % (key,)
|
||||
return 0
|
||||
self.guess.append(key)
|
||||
self.guess.sort()
|
||||
self.tries = self.tries+1
|
||||
if not key in self.word:
|
||||
self.misses = self.misses+1
|
||||
if self.misses == 7:
|
||||
self.EndGame()
|
||||
return 1
|
||||
has_won = 1
|
||||
for letter in self.word:
|
||||
if not self.guess.count(letter):
|
||||
has_won = 0
|
||||
break
|
||||
if has_won:
|
||||
self.Draw()
|
||||
return 2
|
||||
self.Draw()
|
||||
return 0
|
||||
|
||||
def Draw(self, dc = None):
|
||||
if not dc:
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.font)
|
||||
dc.Clear()
|
||||
(x,y) = self.GetSizeTuple()
|
||||
x1 = x-200; y1 = 20
|
||||
for letter in self.word:
|
||||
if self.guess.count(letter):
|
||||
dc.DrawText(letter, x1, y1)
|
||||
else:
|
||||
dc.DrawText('.', x1, y1)
|
||||
x1 = x1 + 10
|
||||
x1 = x-200
|
||||
dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
|
||||
guesses = ""
|
||||
for letter in self.guess:
|
||||
guesses = guesses + letter
|
||||
dc.DrawText("guessed:", x1, 70)
|
||||
dc.DrawText(guesses[:13], x1+80, 70)
|
||||
dc.DrawText(guesses[13:], x1+80, 90)
|
||||
dc.SetUserScale(x/1000.0, y/1000.0)
|
||||
self.DrawVictim(dc)
|
||||
|
||||
def DrawVictim(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('black'), 20))
|
||||
dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
|
||||
(720,980), (900,980)])
|
||||
dc.DrawLines([(100,900), (100, 100), (300,100)])
|
||||
dc.DrawLine(100,200,200,100)
|
||||
if ( self.misses == 0 ): return
|
||||
dc.SetPen(wxPen(wxNamedColour('blue'), 10))
|
||||
dc.DrawLine(300,100,300,200)
|
||||
if ( self.misses == 1 ): return
|
||||
dc.DrawEllipse(250,200,100,100)
|
||||
if ( self.misses == 2 ): return
|
||||
dc.DrawLine(300,300,300,600)
|
||||
if ( self.misses == 3) : return
|
||||
dc.DrawLine(300,300,250,550)
|
||||
if ( self.misses == 4) : return
|
||||
dc.DrawLine(300,300,350,550)
|
||||
if ( self.misses == 5) : return
|
||||
dc.DrawLine(300,600,350,850)
|
||||
if ( self.misses == 6) : return
|
||||
dc.DrawLine(300,600,250,850)
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.Draw(dc)
|
||||
|
||||
|
||||
|
||||
class HangmanDemo(HangmanWnd):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
HangmanWnd.__init__(self, parent, id, pos, size)
|
||||
self.StartGame("dummy")
|
||||
self.start_new = 1
|
||||
self.wf = wf
|
||||
self.delay = 500
|
||||
self.timer = self.PlayTimer(self.MakeMove)
|
||||
|
||||
def MakeMove(self):
|
||||
self.timer.Stop()
|
||||
if self.start_new:
|
||||
self.StartGame(self.wf.Get())
|
||||
self.start_new = 0
|
||||
self.left = list('aaaabcdeeeeefghiiiiijklmnnnoooopqrssssttttuuuuvwxyz')
|
||||
else:
|
||||
key = self.left[int(random.random()*len(self.left))]
|
||||
while self.left.count(key): self.left.remove(key)
|
||||
self.start_new = self.HandleKey(key)
|
||||
self.timer.Start(self.delay)
|
||||
|
||||
def Stop(self):
|
||||
self.timer.Stop()
|
||||
|
||||
class PlayTimer(wxTimer):
|
||||
def __init__(self,func):
|
||||
wxTimer.__init__(self)
|
||||
self.func = func
|
||||
self.Start(1000)
|
||||
|
||||
def Notify(self):
|
||||
apply(self.func, ())
|
||||
|
||||
|
||||
|
||||
class HangmanDemoFrame(wxFrame):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
wxFrame.__init__(self, parent, id, "Hangman demo", pos, size)
|
||||
self.demo = HangmanDemo(wf, self, -1, wxDefaultPosition, wxDefaultSize)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.demo.timer.Stop()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class AboutBox(wxDialog):
|
||||
def __init__(self, parent,wf):
|
||||
wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
|
||||
self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
|
||||
self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
|
||||
self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
|
||||
EVT_BUTTON(self, 2001, self.OnOK)
|
||||
|
||||
def OnOK(self, event):
|
||||
self.wnd.Stop()
|
||||
self.EndModal(wxID_OK)
|
||||
|
||||
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, wf):
|
||||
self.wf = wf
|
||||
wxFrame.__init__(self, parent, -1, "hangman", wxDefaultPosition, wxSize(400,300))
|
||||
self.wnd = HangmanWnd(self, -1)
|
||||
menu = wxMenu()
|
||||
menu.Append(1001, "New")
|
||||
menu.Append(1002, "End")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1003, "Reset")
|
||||
menu.Append(1004, "Demo...")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1005, "Exit")
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Game")
|
||||
menu = wxMenu()
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
|
||||
menu.Append(1011, "ASCII File...")
|
||||
urls = [ 'wxPython home', 'http://alldunn.com/wxPython/main.html',
|
||||
'slashdot.org', 'http://slashdot.org/',
|
||||
'cnn.com', 'http://cnn.com',
|
||||
'The New York Times', 'http://www.nytimes.com',
|
||||
'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
|
||||
'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
|
||||
'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
|
||||
urlmenu = wxMenu()
|
||||
for item in range(0,len(urls),2):
|
||||
urlmenu.Append(1020+item/2, urls[item], urls[item+1])
|
||||
urlmenu.Append(1080, 'Other...', 'Enter an URL')
|
||||
menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
|
||||
menu.Append(1013, 'Dump', 'Write contents to stdout')
|
||||
menubar.Append(menu, "Dictionary")
|
||||
self.urls = urls
|
||||
self.urloffset = 1020
|
||||
menu = wxMenu()
|
||||
menu.Append(1090, "About...")
|
||||
menubar.Append(menu, "Help")
|
||||
self.SetMenuBar(menubar)
|
||||
self.CreateStatusBar(2)
|
||||
EVT_MENU(self, 1001, self.OnGameNew)
|
||||
EVT_MENU(self, 1002, self.OnGameEnd)
|
||||
EVT_MENU(self, 1003, self.OnGameReset)
|
||||
EVT_MENU(self, 1004, self.OnGameDemo)
|
||||
EVT_MENU(self, 1005, self.OnWindowClose)
|
||||
EVT_MENU(self, 1011, self.OnDictFile)
|
||||
EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
|
||||
EVT_MENU(self, 1080, self.OnDictURLSel)
|
||||
EVT_MENU(self, 1013, self.OnDictDump)
|
||||
EVT_MENU(self, 1090, self.OnHelpAbout)
|
||||
EVT_CHAR(self.wnd, self.OnChar)
|
||||
self.OnGameReset()
|
||||
|
||||
def OnGameNew(self, event):
|
||||
word = self.wf.Get()
|
||||
self.in_progress = 1
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.StartGame(word)
|
||||
|
||||
def OnGameEnd(self, event):
|
||||
self.UpdateAverages(0)
|
||||
self.in_progress = 0
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.EndGame()
|
||||
|
||||
def OnGameReset(self, event=None):
|
||||
self.played = 0
|
||||
self.won = 0
|
||||
self.history = []
|
||||
self.average = 0.0
|
||||
self.OnGameNew(None)
|
||||
|
||||
def OnGameDemo(self, event):
|
||||
frame = HangmanDemoFrame(self.wf, self, -1, wxDefaultPosition, self.GetSize())
|
||||
frame.Show(TRUE)
|
||||
|
||||
def OnDictFile(self, event):
|
||||
fd = wxFileDialog(self)
|
||||
if (self.wf.filename):
|
||||
fd.SetFilename(self.wf.filename)
|
||||
if fd.ShowModal() == wxID_OK:
|
||||
file = fd.GetPath()
|
||||
self.wf = WordFetcher(file)
|
||||
|
||||
def OnDictURL(self, event):
|
||||
item = (event.GetId() - self.urloffset)*2
|
||||
print "Trying to open %s at %s" % (self.urls[item], self.urls[item+1])
|
||||
self.wf = URLWordFetcher(self.urls[item+1])
|
||||
|
||||
def OnDictURLSel(self, event):
|
||||
msg = wxTextEntryDialog(self, "Enter the URL of the dictionary document", "Enter URL")
|
||||
if msg.ShowModal() == wxID_OK:
|
||||
url = msg.GetValue()
|
||||
self.wf = URLWordFetcher(url)
|
||||
def OnDictDump(self, event):
|
||||
print self.wf.words
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = AboutBox(self, self.wf)
|
||||
about.ShowModal()
|
||||
about.wnd.Stop() # that damn timer won't stop!
|
||||
|
||||
def UpdateAverages(self, has_won):
|
||||
if has_won:
|
||||
self.won = self.won + 1
|
||||
self.played = self.played+1
|
||||
self.history.append(self.wnd.misses) # ugly
|
||||
total = 0.0
|
||||
for m in self.history:
|
||||
total = total + m
|
||||
self.average = float(total/len(self.history))
|
||||
|
||||
def OnChar(self, event):
|
||||
if not self.in_progress:
|
||||
#print "new"
|
||||
self.OnGameNew(None)
|
||||
return
|
||||
key = event.KeyCode();
|
||||
#print key
|
||||
if key >= ord('A') and key <= ord('Z'):
|
||||
key = key + ord('a') - ord('A')
|
||||
key = chr(key)
|
||||
if key < 'a' or key > 'z':
|
||||
event.Skip()
|
||||
return
|
||||
res = self.wnd.HandleKey(key)
|
||||
if res == 0:
|
||||
self.SetStatusText(self.wnd.message)
|
||||
elif res == 1:
|
||||
self.UpdateAverages(0)
|
||||
self.SetStatusText("Too bad, you're dead!",0)
|
||||
self.in_progress = 0
|
||||
elif res == 2:
|
||||
self.in_progress = 0
|
||||
self.UpdateAverages(1)
|
||||
self.SetStatusText("Congratulations!",0)
|
||||
if self.played:
|
||||
percent = (100.*self.won)/self.played
|
||||
else:
|
||||
percent = 0.0
|
||||
self.SetStatusText("p %d, w %d (%g %%), av %g" % (self.played,self.won, percent, self.average),1)
|
||||
|
||||
def OnWindowClose(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
if wxPlatform == '__WXGTK__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
frame = MyFrame(None, wf)
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXGTK__' or wxPlatform == '__WXMOTIF__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
win = MyFrame(frame, wf)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
wxPython/demo/joystick.wdr
Normal file
305
wxPython/demo/joystick_wdr.py
Normal file
@@ -0,0 +1,305 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# Python source generated by wxDesigner from file: joystick.wdr
|
||||
# Do not modify this file, all changes will be lost!
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Include wxWindows' modules
|
||||
from wxPython.wx import *
|
||||
|
||||
# Window functions
|
||||
|
||||
ID_TEXT = 10000
|
||||
ID_X_Position_Ctrl = 10001
|
||||
ID_Y_Position_Ctrl = 10002
|
||||
ID_Z_Position_Ctrl = 10003
|
||||
ID_Button_State_Ctrl = 10004
|
||||
ID_POV_Position_Ctrl = 10005
|
||||
ID_POV_CTS_Pos_Ctrl = 10006
|
||||
ID_Rudder_Pos_Ctrl = 10007
|
||||
ID_U_Position_Ctrl = 10008
|
||||
ID_V_Position_Ctrl = 10009
|
||||
ID_Has_Rudder_Ctrl = 10010
|
||||
ID_Has_Z_Ctrl = 10011
|
||||
ID_Has_U_Ctrl = 10012
|
||||
ID_Has_V_Ctrl = 10013
|
||||
ID_Has_POV_Ctrl = 10014
|
||||
ID_Has_POV_4DIR_Ctrl = 10015
|
||||
ID_Has_POV_CTS_Ctrl = 10016
|
||||
ID_Num_Sticks_Ctrl = 10017
|
||||
ID_Mfg_ID_Ctrl = 10018
|
||||
ID_Prod_Name_Ctrl = 10019
|
||||
ID_X_Min_Ctrl = 10020
|
||||
ID_Y_Min_Ctrl = 10021
|
||||
ID_Z_Min_Ctrl = 10022
|
||||
ID_X_Max_Ctrl = 10023
|
||||
ID_Y_Max_Ctrl = 10024
|
||||
ID_Z_Max_Ctrl = 10025
|
||||
ID_Num_Buttons_Ctrl = 10026
|
||||
ID_Num_Axes_Ctrl = 10027
|
||||
ID_Max_Buttons_Ctrl = 10028
|
||||
ID_Max_Axes_Ctrl = 10029
|
||||
ID_Polling_Min_Ctrl = 10030
|
||||
ID_Polling_Max_Ctrl = 10031
|
||||
ID_Rudder_Min_Ctrl = 10032
|
||||
ID_Rudder_Max_Ctrl = 10033
|
||||
ID_U_Min_Ctrl = 10034
|
||||
ID_U_Max_Ctrl = 10035
|
||||
ID_V_Min_Ctrl = 10036
|
||||
ID_V_Max_Ctrl = 10037
|
||||
|
||||
def MakeJoystickTestPanel( parent, call_fit = true, set_sizer = true ):
|
||||
item0 = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
item1 = wxFlexGridSizer( 0, 8, 0, 0 )
|
||||
|
||||
item2 = wxStaticText( parent, ID_TEXT, "X Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item2, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item3 = wxTextCtrl( parent, ID_X_Position_Ctrl, "", wxDefaultPosition, wxSize(45,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item4 = wxStaticText( parent, ID_TEXT, "Y Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item4, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item5 = wxTextCtrl( parent, ID_Y_Position_Ctrl, "", wxDefaultPosition, wxSize(45,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item6 = wxStaticText( parent, ID_TEXT, "Z Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item6, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item7 = wxTextCtrl( parent, ID_Z_Position_Ctrl, "", wxDefaultPosition, wxSize(45,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item8 = wxStaticText( parent, ID_TEXT, "Button State:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item9 = wxTextCtrl( parent, ID_Button_State_Ctrl, "", wxDefaultPosition, wxSize(45,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item9, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item10 = wxStaticText( parent, ID_TEXT, "POV Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item11 = wxTextCtrl( parent, ID_POV_Position_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item11, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item12 = wxStaticText( parent, ID_TEXT, "POV CTS Pos:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item12, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item13 = wxTextCtrl( parent, ID_POV_CTS_Pos_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item14 = wxStaticText( parent, ID_TEXT, "Rudder Pos:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item14, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item15 = wxTextCtrl( parent, ID_Rudder_Pos_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item16 = wxStaticText( parent, ID_TEXT, "U Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item16, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item17 = wxTextCtrl( parent, ID_U_Position_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item17, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item18 = wxStaticText( parent, ID_TEXT, "V Position:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item18, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item19 = wxTextCtrl( parent, ID_V_Position_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item19, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item1.AddSpacer( 20, 10, 0, wxALIGN_CENTRE, 5 )
|
||||
|
||||
item20 = wxStaticText( parent, ID_TEXT, "HasRudder:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item20, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item21 = wxTextCtrl( parent, ID_Has_Rudder_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item21, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item22 = wxStaticText( parent, ID_TEXT, "HasZ:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item22, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item23 = wxTextCtrl( parent, ID_Has_Z_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item23, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item24 = wxStaticText( parent, ID_TEXT, "HasU:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item24, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item25 = wxTextCtrl( parent, ID_Has_U_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item25, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item26 = wxStaticText( parent, ID_TEXT, "HasV:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item27 = wxTextCtrl( parent, ID_Has_V_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item27, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item28 = wxStaticText( parent, ID_TEXT, "HasPOV:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item28, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item29 = wxTextCtrl( parent, ID_Has_POV_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item29, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item30 = wxStaticText( parent, ID_TEXT, "HasPOV4Dir:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item30, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item31 = wxTextCtrl( parent, ID_Has_POV_4DIR_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item31, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item32 = wxStaticText( parent, ID_TEXT, "HasPOVCTS:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item32, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item33 = wxTextCtrl( parent, ID_Has_POV_CTS_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item33, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item34 = wxStaticText( parent, ID_TEXT, "# Joysticks:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item34, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item35 = wxTextCtrl( parent, ID_Num_Sticks_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item35, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item36 = wxStaticText( parent, ID_TEXT, "Mfg ID:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item36, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item37 = wxTextCtrl( parent, ID_Mfg_ID_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item37, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item38 = wxStaticText( parent, ID_TEXT, "Prod Name:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item38, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item39 = wxTextCtrl( parent, ID_Prod_Name_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item39, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item40 = wxStaticText( parent, ID_TEXT, "X Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item40, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item41 = wxTextCtrl( parent, ID_X_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item41, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item42 = wxStaticText( parent, ID_TEXT, "Y Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item43 = wxTextCtrl( parent, ID_Y_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item43, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item44 = wxStaticText( parent, ID_TEXT, "Z Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item44, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item45 = wxTextCtrl( parent, ID_Z_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item45, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item46 = wxStaticText( parent, ID_TEXT, "X Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item46, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item47 = wxTextCtrl( parent, ID_X_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item47, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item48 = wxStaticText( parent, ID_TEXT, "Y Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item48, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item49 = wxTextCtrl( parent, ID_Y_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item49, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item50 = wxStaticText( parent, ID_TEXT, "Z Max", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item50, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item51 = wxTextCtrl( parent, ID_Z_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item51, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item52 = wxStaticText( parent, ID_TEXT, "# Buttons:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item52, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item53 = wxTextCtrl( parent, ID_Num_Buttons_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item53, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item54 = wxStaticText( parent, ID_TEXT, "Num Axes:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item54, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item55 = wxTextCtrl( parent, ID_Num_Axes_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item55, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item56 = wxStaticText( parent, ID_TEXT, "Max Buttons:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item56, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item57 = wxTextCtrl( parent, ID_Max_Buttons_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item57, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item58 = wxStaticText( parent, ID_TEXT, "Max Axes:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item58, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item59 = wxTextCtrl( parent, ID_Max_Axes_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item59, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item60 = wxStaticText( parent, ID_TEXT, "Polling Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item60, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item61 = wxTextCtrl( parent, ID_Polling_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item61, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item62 = wxStaticText( parent, ID_TEXT, "Polling Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item62, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item63 = wxTextCtrl( parent, ID_Polling_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item63, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item64 = wxStaticText( parent, ID_TEXT, "Rudder Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item64, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item65 = wxTextCtrl( parent, ID_Rudder_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item65, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item66 = wxStaticText( parent, ID_TEXT, "Rudder Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item66, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item67 = wxTextCtrl( parent, ID_Rudder_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item67, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item68 = wxStaticText( parent, ID_TEXT, "U Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item68, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item69 = wxTextCtrl( parent, ID_U_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item69, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item70 = wxStaticText( parent, ID_TEXT, "U Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item70, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item71 = wxTextCtrl( parent, ID_U_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item71, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item72 = wxStaticText( parent, ID_TEXT, "V Min:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item72, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item73 = wxTextCtrl( parent, ID_V_Min_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item73, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item74 = wxStaticText( parent, ID_TEXT, "V Max:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT )
|
||||
item1.AddWindow( item74, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 )
|
||||
|
||||
item75 = wxTextCtrl( parent, ID_V_Max_Ctrl, "", wxDefaultPosition, wxSize(35,-1), wxTE_READONLY )
|
||||
item1.AddWindow( item75, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 )
|
||||
|
||||
item0.AddSizer( item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15 )
|
||||
|
||||
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
|
||||
BIN
wxPython/demo/mimetypes.wdr
Normal file
155
wxPython/demo/mimetypes_wdr.py
Normal file
@@ -0,0 +1,155 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# Python source generated by wxDesigner from file: mimetypes.wdr
|
||||
# Do not modify this file, all changes will be lost!
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Include wxWindows' modules
|
||||
from wxPython.wx import *
|
||||
|
||||
# Window functions
|
||||
|
||||
ID_INPUT_TEXT = 10000
|
||||
ID_EXTENSION_Btn = 10001
|
||||
ID_MIME_BTN = 10002
|
||||
ID_LOOKUP_BTN = 10003
|
||||
ID_LINE = 10004
|
||||
ID_TEXT = 10005
|
||||
ID_ICON_BMP = 10006
|
||||
ID_ICON_FILE_TXT = 10007
|
||||
ID_ICON_INDEX_TXT = 10008
|
||||
ID_MIME_TYPE_TXT = 10009
|
||||
ID_MIME_TYPES_TXT = 10010
|
||||
ID_EXTENSIONS_TXT = 10011
|
||||
ID_DESCRIPTION_TXT = 10012
|
||||
ID_OPEN_CMD_TXT = 10013
|
||||
ID_PRINT_CMD_TXT = 10014
|
||||
ID_ALL_CMDS_TXT = 10015
|
||||
ID_LISTBOX = 10016
|
||||
|
||||
def MakeMimeTypesTestPanel( parent, call_fit = true, set_sizer = true ):
|
||||
item0 = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
item1 = wxBoxSizer( wxHORIZONTAL )
|
||||
|
||||
item2 = wxTextCtrl( parent, ID_INPUT_TEXT, "", wxDefaultPosition, wxSize(100,-1), 0 )
|
||||
item1.AddWindow( item2, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item3 = wxRadioButton( parent, ID_EXTENSION_Btn, "By extension", wxDefaultPosition, wxDefaultSize, wxRB_GROUP )
|
||||
item3.SetValue( true )
|
||||
item1.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item4 = wxRadioButton( parent, ID_MIME_BTN, "By mime type", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item1.AddWindow( item4, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item5 = wxButton( parent, ID_LOOKUP_BTN, "Lookup", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item5.SetDefault()
|
||||
item1.AddWindow( item5, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item0.AddSizer( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
item6 = wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL )
|
||||
item0.AddWindow( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
item7 = wxBoxSizer( wxHORIZONTAL )
|
||||
|
||||
item8 = wxFlexGridSizer( 0, 2, 0, 0 )
|
||||
item8.AddGrowableCol( 1 )
|
||||
item8.AddGrowableRow( 8 )
|
||||
|
||||
item9 = wxStaticText( parent, ID_TEXT, "wxFileType:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item9.SetFont( wxFont( 14, wxSWISS, wxNORMAL, wxBOLD ) )
|
||||
item8.AddWindow( item9, 0, wxALL, 5 )
|
||||
|
||||
item8.AddSpacer( 20, 20, 0, wxALIGN_CENTRE|wxALL, 5 )
|
||||
|
||||
item10 = wxStaticText( parent, ID_TEXT, "GetIconInfo:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
item11 = wxBoxSizer( wxHORIZONTAL )
|
||||
|
||||
item12 = wxStaticBitmap( parent, ID_ICON_BMP, MyBitmapsFunc( 0 ), wxDefaultPosition, wxDefaultSize )
|
||||
item11.AddWindow( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
item13 = wxTextCtrl( parent, ID_ICON_FILE_TXT, "", wxDefaultPosition, wxSize(120,-1), wxTE_READONLY )
|
||||
item11.AddWindow( item13, 1, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
|
||||
item14 = wxTextCtrl( parent, ID_ICON_INDEX_TXT, "", wxDefaultPosition, wxSize(30,-1), wxTE_READONLY )
|
||||
item11.AddWindow( item14, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
|
||||
item8.AddSizer( item11, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 )
|
||||
|
||||
item15 = wxStaticText( parent, ID_TEXT, "GetMimeType:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item15, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item16 = wxTextCtrl( parent, ID_MIME_TYPE_TXT, "", wxDefaultPosition, wxSize(310,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item16, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item17 = wxStaticText( parent, ID_TEXT, "GetMimeTypes:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item17, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item18 = wxTextCtrl( parent, ID_MIME_TYPES_TXT, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item18, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item19 = wxStaticText( parent, ID_TEXT, "GetExtensions:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item19, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item20 = wxTextCtrl( parent, ID_EXTENSIONS_TXT, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item20, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item21 = wxStaticText( parent, ID_TEXT, "GetDescription:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item21, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item22 = wxTextCtrl( parent, ID_DESCRIPTION_TXT, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item22, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item23 = wxStaticText( parent, ID_TEXT, "GetOpenCommand:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item24 = wxTextCtrl( parent, ID_OPEN_CMD_TXT, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item24, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item25 = wxStaticText( parent, ID_TEXT, "GetPrintCommand:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item25, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item26 = wxTextCtrl( parent, ID_PRINT_CMD_TXT, "", wxDefaultPosition, wxSize(80,-1), wxTE_READONLY )
|
||||
item8.AddWindow( item26, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item27 = wxStaticText( parent, ID_TEXT, "GetAllCommands:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item8.AddWindow( item27, 0, wxALIGN_RIGHT|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item28 = wxTextCtrl( parent, ID_ALL_CMDS_TXT, "", wxDefaultPosition, wxSize(80,100), wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL )
|
||||
item8.AddWindow( item28, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item7.AddSizer( item8, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 )
|
||||
|
||||
item29 = wxBoxSizer( wxVERTICAL )
|
||||
|
||||
item30 = wxStaticText( parent, ID_TEXT, "Known mime types:", wxDefaultPosition, wxDefaultSize, 0 )
|
||||
item29.AddWindow( item30, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
|
||||
item31 = wxListBox( parent, ID_LISTBOX, wxDefaultPosition, wxSize(150,100), [], wxLB_SINGLE|wxLB_SORT|wxLB_HSCROLL )
|
||||
item29.AddWindow( item31, 1, wxALIGN_CENTRE|wxRIGHT|wxBOTTOM, 5 )
|
||||
|
||||
item7.AddSizer( item29, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxTOP|wxBOTTOM, 5 )
|
||||
|
||||
item0.AddSizer( item7, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 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
|
||||
|
||||
def MyBitmapsFunc( index ):
|
||||
if index == 0:
|
||||
return wxImage( "mimetypes_wdr/MyBitmapsFunc_0.png", wxBITMAP_TYPE_PNG ).ConvertToBitmap()
|
||||
return wxNullBitmap
|
||||
|
||||
# End of generated file
|
||||
25
wxPython/demo/redemo.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""Basic regular expression demostration facility (Perl style syntax)."""
|
||||
|
||||
from wxPython.wx import *
|
||||
import re
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class ReDemoPanel(wxPanel):
|
||||
def __init__(self, parent):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
rePrompt = wxStaticText(self, -1, "Enter a Perl-style regular expression")
|
||||
reText = wxTextCtrl(self, 101, "")
|
||||
|
||||
options = self.AddOptions()
|
||||
|
||||
sPrompt = wxStaticText(self, -1, "Enter a string to search")
|
||||
sText = wxTextCtrl(self, 102, "", style=wxTE_MULTILINE)
|
||||
|
||||
dispPrompt = wxStaticText(self, -1, "Groups:")
|
||||
dispText = wxTextCtrl(self, 103, "", style=wxTE_MULTILINE|wxTE_READONLY)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
55
wxPython/demo/simple.py
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# A very simple wxPython example. Just a wxFrame, wxPanel,
|
||||
# wxStaticText, wxButton, and a wxBoxSizer, but it shows the basic
|
||||
# structure of any wxPython application.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
"""
|
||||
This is MyFrame. It just shows a few controls on a wxPanel,
|
||||
and has a simple menu.
|
||||
"""
|
||||
def __init__(self, parent, title):
|
||||
wxFrame.__init__(self, parent, -1, title, size=(350, 200))
|
||||
|
||||
menuBar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(101, "E&xit\tAlt-X", "Exit demo")
|
||||
EVT_MENU(self, 101, self.OnButton)
|
||||
menuBar.Append(menu, "&File")
|
||||
self.SetMenuBar(menuBar)
|
||||
|
||||
panel = wxPanel(self, -1)
|
||||
if wxPlatform == "__WXMAC__":
|
||||
text = wxStaticText(panel, -1,
|
||||
"Hello World!\nWhere is my menu?")
|
||||
else:
|
||||
text = wxStaticText(panel, -1, "Hello World!")
|
||||
text.SetFont(wxFont(12, wxSWISS, wxNORMAL, wxBOLD))
|
||||
text.SetSize(text.GetBestSize())
|
||||
btn = wxButton(panel, -1, "Close")
|
||||
btn.SetDefault()
|
||||
|
||||
sizer = wxBoxSizer(wxVERTICAL)
|
||||
sizer.Add(text, 0, wxALL, 10)
|
||||
sizer.Add(btn, 0, wxALL, 10)
|
||||
panel.SetSizer(sizer)
|
||||
panel.SetAutoLayout(true)
|
||||
panel.Layout()
|
||||
|
||||
EVT_BUTTON(self, btn.GetId(), self.OnButton)
|
||||
|
||||
|
||||
def OnButton(self, evt):
|
||||
"""Event handler for the button click."""
|
||||
print "OnButton"
|
||||
self.Close()
|
||||
|
||||
app = wxPySimpleApp()
|
||||
frame = MyFrame(None, "Simple wxPython App")
|
||||
frame.Show(true)
|
||||
app.MainLoop()
|
||||
|
||||
33
wxPython/demo/templateold.py
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Say something nice here</center></h2>
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
||||
59
wxPython/demo/wxButton.py
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
b = wxButton(self, 10, "Hello", wxPoint(20, 20))
|
||||
EVT_BUTTON(self, 10, self.OnClick)
|
||||
b.SetBackgroundColour(wxBLUE)
|
||||
b.SetForegroundColour(wxWHITE)
|
||||
b.SetDefault()
|
||||
|
||||
b = wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(90, 45))
|
||||
EVT_BUTTON(self, 20, self.OnClick)
|
||||
|
||||
b.SetToolTipString("This is a Hello button...")
|
||||
|
||||
bmp = images.getTest2Bitmap()
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
|
||||
##print bmp.GetWidth(), bmp.GetHeight()
|
||||
|
||||
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
|
||||
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
||||
EVT_BUTTON(self, 30, self.OnClick)
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.WriteText("Click! (%d)\n" % event.GetId())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
638
wxPython/demo/wxCalendar.py
Normal file
@@ -0,0 +1,638 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: wxCalendar.py
|
||||
# Purpose: Calendar control display testing on panel for wxPython demo
|
||||
#
|
||||
# Author: Lorne White (email: lwhite1@planet.eon.net)
|
||||
#
|
||||
# Version 0.9
|
||||
# Date: Feb 26, 2001
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.calendar import wxCalendar, Month, PrtCalDraw, CalenDlg
|
||||
|
||||
import images
|
||||
import os
|
||||
|
||||
|
||||
# highlighted days in month
|
||||
|
||||
test_days ={ 0: [],
|
||||
1: [3, 7, 9, 21],
|
||||
2: [2, 10, 4, 9],
|
||||
3: [4, 20, 29],
|
||||
4: [1, 12, 22],
|
||||
5: [2, 10, 15],
|
||||
6: [4, 8, 17],
|
||||
7: [6, 7, 8],
|
||||
8: [5, 10, 20],
|
||||
9: [1, 2, 5, 29],
|
||||
10: [2, 4, 6, 22],
|
||||
11: [6, 9, 12, 28, 29],
|
||||
12: [8, 9, 10, 11, 20] }
|
||||
|
||||
# test of full window calendar control functions
|
||||
|
||||
def GetMonthList():
|
||||
monthlist = []
|
||||
for i in range(13):
|
||||
name = Month[i]
|
||||
if name != None:
|
||||
monthlist.append(name)
|
||||
return monthlist
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log, frame):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
self.frame = frame
|
||||
|
||||
self.calend = wxCalendar(self, -1, wxPoint(100, 50), wxSize(200, 180))
|
||||
|
||||
# start_month = 2 # preselect the date for calendar
|
||||
# start_year = 2001
|
||||
|
||||
start_month = self.calend.GetMonth() # get the current month & year
|
||||
start_year = self.calend.GetYear()
|
||||
|
||||
# month list from DateTime module
|
||||
|
||||
monthlist = GetMonthList()
|
||||
|
||||
mID = NewId()
|
||||
self.date = wxComboBox(self, mID, Month[start_month], wxPoint(100, 20), wxSize(90, -1), monthlist, wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, mID, self.EvtComboBox)
|
||||
|
||||
# set start month and year
|
||||
|
||||
self.calend.SetMonth(start_month)
|
||||
self.calend.SetYear(start_year)
|
||||
|
||||
# set attributes of calendar
|
||||
|
||||
self.calend.hide_title = TRUE
|
||||
self.calend.HideGrid()
|
||||
self.calend.SetWeekColor('WHITE', 'BLACK')
|
||||
|
||||
# display routine
|
||||
|
||||
self.ResetDisplay()
|
||||
|
||||
# mouse click event
|
||||
|
||||
self.Connect(self.calend.GetId(), -1, 2100, self.MouseClick)
|
||||
|
||||
# scroll bar for month selection
|
||||
|
||||
mID = NewId()
|
||||
self.scroll = wxScrollBar(self, mID, wxPoint(100, 240), wxSize(200, 20), wxSB_HORIZONTAL)
|
||||
self.scroll.SetScrollbar(start_month-1, 1, 12, 1, TRUE)
|
||||
EVT_COMMAND_SCROLL(self, mID, self.Scroll)
|
||||
|
||||
# spin control for year selection
|
||||
|
||||
self.dtext = wxTextCtrl(self, -1, str(start_year), wxPoint(200, 20), wxSize(60, -1))
|
||||
h = self.dtext.GetSize().height
|
||||
|
||||
mID = NewId()
|
||||
self.spin = wxSpinButton(self, mID, wxPoint(270, 20), wxSize(h*2, h))
|
||||
self.spin.SetRange(1980, 2010)
|
||||
self.spin.SetValue(start_year)
|
||||
EVT_SPIN(self, mID, self.OnSpin)
|
||||
|
||||
# button for calendar dialog test
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Dialog", wxPoint(350, 50), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
bmp = images.getCalendarBitmap()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 80))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestDlg)
|
||||
|
||||
# button for calendar window test
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Window", wxPoint(350, 150), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 180))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.TestFrame)
|
||||
|
||||
wxStaticText(self, -1, "Test Calendar Print", wxPoint(350, 250), wxSize(150, -1))
|
||||
|
||||
mID = NewId()
|
||||
self.but = wxBitmapButton(self, mID, bmp, wxPoint(380, 280))#, wxSize(30, 30))
|
||||
EVT_BUTTON(self, mID, self.OnPreview)
|
||||
|
||||
# calendar dialog
|
||||
|
||||
def TestDlg(self, event): # test the date dialog
|
||||
dlg = CalenDlg(self)
|
||||
dlg.Centre()
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
result = dlg.result
|
||||
day = result[1]
|
||||
month = result[2]
|
||||
year = result[3]
|
||||
new_date = str(month) + '/'+ str(day) + '/'+ str(year)
|
||||
self.log.WriteText('Date Selected: %s\n' % new_date)
|
||||
else:
|
||||
self.log.WriteText('No Date Selected')
|
||||
|
||||
# calendar window test
|
||||
|
||||
def TestFrame(self, event):
|
||||
frame = CalendFrame(self, -1, "Test Calendar", self.log)
|
||||
frame.Show(true)
|
||||
return true
|
||||
|
||||
# calendar print preview
|
||||
|
||||
def OnPreview(self, event):
|
||||
month = self.calend.GetMonth()
|
||||
year = self.calend.GetYear()
|
||||
|
||||
prt = PrintCalend(self.frame, month, year)
|
||||
prt.Preview()
|
||||
|
||||
# month and year control events
|
||||
|
||||
def OnSpin(self, event):
|
||||
year = event.GetPosition()
|
||||
self.dtext.SetValue(str(year))
|
||||
self.calend.SetYear(year)
|
||||
self.calend.Refresh()
|
||||
|
||||
def EvtComboBox(self, event):
|
||||
name = event.GetString()
|
||||
self.log.WriteText('EvtComboBox: %s\n' % name)
|
||||
monthval = self.date.FindString(name)
|
||||
self.scroll.SetScrollbar(monthval, 1, 12, 1, TRUE)
|
||||
|
||||
self.calend.SetMonth(monthval+1)
|
||||
self.ResetDisplay()
|
||||
|
||||
def Scroll(self, event):
|
||||
value = self.scroll.GetThumbPosition()
|
||||
monthval = int(value)+1
|
||||
self.calend.SetMonth(monthval)
|
||||
self.ResetDisplay()
|
||||
self.log.WriteText('Month: %s\n' % value)
|
||||
|
||||
name = Month[monthval]
|
||||
self.date.SetValue(name)
|
||||
|
||||
# log mouse events
|
||||
|
||||
def MouseClick(self, evt):
|
||||
text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date
|
||||
self.log.WriteText('Date Selected: ' + text + '\n')
|
||||
|
||||
|
||||
# set the highlighted days for the calendar
|
||||
|
||||
def ResetDisplay(self):
|
||||
month = self.calend.GetMonth()
|
||||
try:
|
||||
set_days = test_days[month]
|
||||
except:
|
||||
set_days = [1, 5, 12]
|
||||
|
||||
self.calend.AddSelect([4, 11], 'BLUE', 'WHITE')
|
||||
self.calend.SetSelDay(set_days)
|
||||
self.calend.Refresh()
|
||||
|
||||
# increment and decrement toolbar controls
|
||||
|
||||
def OnIncYear(self, event):
|
||||
self.calend.IncYear()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnDecYear(self, event):
|
||||
self.calend.DecYear()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnIncMonth(self, event):
|
||||
self.calend.IncMonth()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnDecMonth(self, event):
|
||||
self.calend.DecMonth()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnCurrent(self, event):
|
||||
self.calend.SetCurrentDay()
|
||||
self.ResetDisplay()
|
||||
|
||||
# test of full window calendar control functions
|
||||
|
||||
class CalendFrame(wxFrame):
|
||||
def __init__(self, parent, id, title, log):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition, wxSize(400, 400))
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
self.log = log
|
||||
self.CreateStatusBar()
|
||||
self.mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
|
||||
menu = self.MakeFileMenu()
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
self.MakeToolMenu() # toolbar
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.calend = wxCalendar(self, -1)
|
||||
self.calend.SetCurrentDay()
|
||||
self.calend.grid_color = 'BLUE'
|
||||
self.calend.SetBusType()
|
||||
# self.calend.ShowWeekEnd()
|
||||
|
||||
self.ResetDisplay()
|
||||
|
||||
self.Connect(self.calend.GetId(), -1, 2100, self.MouseClick)
|
||||
|
||||
def MouseClick(self, evt):
|
||||
text = '%s CLICK %02d/%02d/%d' % (evt.click, evt.day, evt.month, evt.year) # format date
|
||||
self.log.WriteText('Date Selected: ' + text + '\n')
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def ResetDisplay(self):
|
||||
month = self.calend.GetMonth()
|
||||
try:
|
||||
set_days = test_days[month]
|
||||
except:
|
||||
set_days = [1, 5, 12]
|
||||
|
||||
self.calend.AddSelect([2, 16], 'GREEN', 'WHITE')
|
||||
|
||||
self.calend.SetSelDay(set_days)
|
||||
self.calend.Refresh()
|
||||
|
||||
def OnIncYear(self, event):
|
||||
self.calend.IncYear()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnDecYear(self, event):
|
||||
self.calend.DecYear()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnIncMonth(self, event):
|
||||
self.calend.IncMonth()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnDecMonth(self, event):
|
||||
self.calend.DecMonth()
|
||||
self.ResetDisplay()
|
||||
|
||||
def OnCurrent(self, event):
|
||||
self.calend.SetCurrentDay()
|
||||
self.ResetDisplay()
|
||||
|
||||
def MakeFileMenu(self):
|
||||
menu = wxMenu()
|
||||
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'Decrement', 'Next')
|
||||
EVT_MENU(self, mID, self.OnDecMonth)
|
||||
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'Increment', 'Dec')
|
||||
EVT_MENU(self, mID, self.OnIncMonth)
|
||||
|
||||
menu.AppendSeparator()
|
||||
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'E&xit', 'Exit')
|
||||
EVT_MENU(self, mID, self.OnCloseWindow)
|
||||
|
||||
return menu
|
||||
|
||||
def MakeToolMenu(self):
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, images.getDbDecBitmap(), 'Dec Year')
|
||||
EVT_TOOL(self, mID, self.OnDecYear)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, images.getDecBitmap(), 'Dec Month')
|
||||
EVT_TOOL(self, mID, self.OnDecMonth)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, images.getPtBitmap(), 'Current Month')
|
||||
EVT_TOOL(self, mID, self.OnCurrent)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, images.getIncBitmap(), 'Inc Month')
|
||||
EVT_TOOL(self, mID, self.OnIncMonth)
|
||||
|
||||
mID = NewId()
|
||||
SetToolPath(self, tb, mID, images.getDbIncBitmap(), 'Inc Year')
|
||||
EVT_TOOL(self, mID, self.OnIncYear)
|
||||
|
||||
tb.Realize()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# example class for printing/previewing calendars
|
||||
|
||||
class PrintCalend:
|
||||
def __init__(self, parent, month, year):
|
||||
self.frame = parent
|
||||
self.month = month
|
||||
self.year = year
|
||||
|
||||
self.SetParms()
|
||||
self.SetCal()
|
||||
self.printData = wxPrintData()
|
||||
|
||||
def SetCal(self):
|
||||
self.grid_color = 'BLUE'
|
||||
self.back_color = 'WHITE'
|
||||
self.sel_color = 'RED'
|
||||
self.high_color = 'LIGHT BLUE'
|
||||
self.font = wxSWISS
|
||||
self.bold = wxNORMAL
|
||||
|
||||
self.sel_key = None # last used by
|
||||
self.sel_lst = [] # highlighted selected days
|
||||
|
||||
self.size = None
|
||||
self.hide_title = FALSE
|
||||
self.hide_grid = FALSE
|
||||
self.set_day = None
|
||||
|
||||
def SetParms(self):
|
||||
self.ymax = 1
|
||||
self.xmax = 1
|
||||
self.page = 1
|
||||
self.total_pg = 1
|
||||
|
||||
self.preview = None
|
||||
self.scale = 1.0
|
||||
|
||||
self.pagew = 8.5
|
||||
self.pageh = 11.0
|
||||
|
||||
self.txt_marg = 0.1
|
||||
self.lf_marg = 0
|
||||
self.top_marg = 0
|
||||
|
||||
self.page = 0
|
||||
|
||||
def SetDates(self, month, year):
|
||||
self.month = month
|
||||
self.year = year
|
||||
|
||||
def SetStyleDef(self, desc):
|
||||
self.style = desc
|
||||
|
||||
def SetCopies(self, copies): # number of copies of label
|
||||
self.copies = copies
|
||||
|
||||
def SetStart(self, start): # start position of label
|
||||
self.start = start
|
||||
|
||||
def Preview(self):
|
||||
printout = SetPrintout(self)
|
||||
printout2 = SetPrintout(self)
|
||||
self.preview = wxPrintPreview(printout, printout2, self.printData)
|
||||
if not self.preview.Ok():
|
||||
wxMessageBox("There was a problem printing!", "Printing", wxOK)
|
||||
return
|
||||
|
||||
self.preview.SetZoom(60) # initial zoom value
|
||||
|
||||
frame = wxPreviewFrame(self.preview, self.frame, "Print preview")
|
||||
|
||||
frame.Initialize()
|
||||
frame.SetPosition(self.frame.GetPosition())
|
||||
frame.SetSize(self.frame.GetSize())
|
||||
frame.Show(true)
|
||||
|
||||
def Print(self):
|
||||
pdd = wxPrintDialogData()
|
||||
pdd.SetPrintData(self.printData)
|
||||
printer = wxPrinter(pdd)
|
||||
printout = SetPrintout(self)
|
||||
frame = wxFrame(None, -1, "Test")
|
||||
if not printer.Print(frame, printout):
|
||||
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK)
|
||||
else:
|
||||
self.printData = printer.GetPrintDialogData().GetPrintData()
|
||||
printout.Destroy()
|
||||
|
||||
def DoDrawing(self, DC):
|
||||
size = DC.GetSizeTuple()
|
||||
DC.BeginDrawing()
|
||||
|
||||
cal = PrtCalDraw(self)
|
||||
|
||||
if self.preview is None:
|
||||
cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh)
|
||||
cal.SetPreview(FALSE)
|
||||
|
||||
else:
|
||||
if self.preview == 1:
|
||||
cal.SetPSize(size[0]/self.pagew, size[1]/self.pageh)
|
||||
else:
|
||||
cal.SetPSize(self.pwidth, self.pheight)
|
||||
|
||||
cal.SetPreview(self.preview)
|
||||
|
||||
cal.hide_title = self.hide_title # set the calendar parameters
|
||||
cal.hide_grid = self.hide_grid
|
||||
|
||||
cal.grid_color = self.grid_color
|
||||
cal.high_color = self.high_color
|
||||
cal.back_color = self.back_color
|
||||
cal.outer_border = FALSE
|
||||
cal.font = self.font
|
||||
cal.bold = self.bold
|
||||
|
||||
cal_size = wxSize(3.0, 3.0)
|
||||
cal.SetSize(cal_size)
|
||||
|
||||
year, month = self.year, self.month
|
||||
|
||||
x = 1.0
|
||||
for i in range(2):
|
||||
y = 0.5
|
||||
for j in range(3):
|
||||
cal.SetCal(year, month) # current month
|
||||
cal.SetPos(x, y)
|
||||
|
||||
try:
|
||||
set_days = test_days[month]
|
||||
except:
|
||||
set_days = [1, 5, 12]
|
||||
|
||||
cal.AddSelect([2, 16], 'GREEN', 'WHITE')
|
||||
|
||||
cal.DrawCal(DC, set_days)
|
||||
|
||||
year, month = self.IncMonth(year, month)
|
||||
y = y + 3.5
|
||||
x = x + 4.0 # next colum
|
||||
|
||||
DC.EndDrawing()
|
||||
|
||||
self.ymax = DC.MaxY()
|
||||
self.xmax = DC.MaxX()
|
||||
|
||||
def IncMonth(self, year, month): # next month
|
||||
month = month + 1
|
||||
if month > 12:
|
||||
month = 1
|
||||
year = year + 1
|
||||
|
||||
return year, month
|
||||
|
||||
def GetTotalPages(self):
|
||||
self.pg_cnt = 1
|
||||
return self.pg_cnt
|
||||
|
||||
def SetPage(self, page):
|
||||
self.page = page
|
||||
|
||||
def SetPageSize(self, width, height):
|
||||
self.pwidth, self.pheight = width, height
|
||||
|
||||
def SetTotalSize(self, width, height):
|
||||
self.ptwidth, self.ptheight = width, height
|
||||
|
||||
def SetPreview(self, preview, scale):
|
||||
self.preview = preview
|
||||
self.scale = scale
|
||||
|
||||
def SetTotalSize(self, width, height):
|
||||
self.ptwidth = width
|
||||
self.ptheight = height
|
||||
|
||||
def SetToolPath(self, tb, id, bmp, title):
|
||||
tb.AddSimpleTool(id, bmp, title, title)
|
||||
|
||||
class SetPrintout(wxPrintout):
|
||||
def __init__(self, canvas):
|
||||
wxPrintout.__init__(self)
|
||||
self.canvas = canvas
|
||||
self.end_pg = 1
|
||||
|
||||
def OnBeginDocument(self, start, end):
|
||||
return self.base_OnBeginDocument(start, end)
|
||||
|
||||
def OnEndDocument(self):
|
||||
self.base_OnEndDocument()
|
||||
|
||||
def HasPage(self, page):
|
||||
if page <= self.end_pg:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
def GetPageInfo(self):
|
||||
self.end_pg = self.canvas.GetTotalPages()
|
||||
str_pg = 1
|
||||
try:
|
||||
end_pg = self.end_pg
|
||||
except:
|
||||
end_pg = 1
|
||||
return (str_pg, end_pg, str_pg, end_pg)
|
||||
|
||||
def OnPreparePrinting(self):
|
||||
self.base_OnPreparePrinting()
|
||||
|
||||
def OnBeginPrinting(self):
|
||||
dc = self.GetDC()
|
||||
|
||||
self.preview = self.IsPreview()
|
||||
if (self.preview):
|
||||
self.pixelsPerInch = self.GetPPIScreen()
|
||||
else:
|
||||
self.pixelsPerInch = self.GetPPIPrinter()
|
||||
|
||||
(w, h) = dc.GetSizeTuple()
|
||||
scaleX = float(w) / 1000
|
||||
scaleY = float(h) / 1000
|
||||
self.printUserScale = min(scaleX, scaleY)
|
||||
|
||||
self.base_OnBeginPrinting()
|
||||
|
||||
def GetSize(self):
|
||||
self.psizew, self.psizeh = self.GetPPIPrinter()
|
||||
return self.psizew, self.psizeh
|
||||
|
||||
def GetTotalSize(self):
|
||||
self.ptsizew, self.ptsizeh = self.GetPageSizePixels()
|
||||
return self.ptsizew, self.ptsizeh
|
||||
|
||||
def OnPrintPage(self, page):
|
||||
dc = self.GetDC()
|
||||
(w, h) = dc.GetSizeTuple()
|
||||
scaleX = float(w) / 1000
|
||||
scaleY = float(h) / 1000
|
||||
self.printUserScale = min(scaleX, scaleY)
|
||||
dc.SetUserScale(self.printUserScale, self.printUserScale)
|
||||
|
||||
self.preview = self.IsPreview()
|
||||
|
||||
self.canvas.SetPreview(self.preview, self.printUserScale)
|
||||
self.canvas.SetPage(page)
|
||||
|
||||
self.ptsizew, self.ptsizeh = self.GetPageSizePixels()
|
||||
self.canvas.SetTotalSize(self.ptsizew, self.ptsizeh)
|
||||
|
||||
self.psizew, self.psizeh = self.GetPPIPrinter()
|
||||
self.canvas.SetPageSize(self.psizew, self.psizeh)
|
||||
|
||||
self.canvas.DoDrawing(dc)
|
||||
return true
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = CalendFrame(None, -1, "Test Calendar")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def MessageDlg(self, message, type = 'Message'):
|
||||
dlg = wxMessageDialog(self, message, type, wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def main():
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log, frame)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """\
|
||||
This control provides a calendar control class for displaying and selecting dates. In addition, the class is extended and can now be used for printing/previewing.
|
||||
|
||||
Additional features include weekend highlighting and business type Monday-Sunday format.
|
||||
|
||||
See example for various methods used to set display month, year, and highlighted dates (different font and background colours).
|
||||
|
||||
by Lorne White
|
||||
|
||||
"""
|
||||
40
wxPython/demo/wxCalendarCtrl.py
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.calendar import *
|
||||
from wxPython.utils import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, ID, log):
|
||||
wxPanel.__init__(self, parent, ID)
|
||||
self.log = log
|
||||
|
||||
cal = wxCalendarCtrl(self, 101, wxDateTime_Now(), pos = (25,50),
|
||||
style = wxCAL_SHOW_HOLIDAYS | wxCAL_SUNDAY_FIRST)
|
||||
|
||||
EVT_CALENDAR(self, 101, self.OnCalSelected)
|
||||
|
||||
|
||||
def OnCalSelected(self, evt):
|
||||
self.log.write('OnCalSelected: %s\n' % evt.GetDate())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, -1, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """\
|
||||
<html><body>
|
||||
<h2>wxCalendarCtrl</h2>
|
||||
|
||||
Yet <i>another</i> calendar control. This one is a wrapper around the C++
|
||||
version described in the docs. This one will probably be a bit more efficient
|
||||
than the one in wxPython.lib.calendar, but I like a few things about it better,
|
||||
so I think both will stay in wxPython.
|
||||
"""
|
||||
53
wxPython/demo/wxCheckBox.py
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestCheckBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckBox control.",
|
||||
wxPoint(10, 10))
|
||||
|
||||
cID = NewId()
|
||||
cb1 = wxCheckBox(self, cID, " Apples", wxPoint(65, 40), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2 = wxCheckBox(self, cID+1, " Oranges", wxPoint(65, 60), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2.SetValue(true)
|
||||
cb3 = wxCheckBox(self, cID+2, " Pears", wxPoint(65, 80), wxSize(150, 20), wxNO_BORDER)
|
||||
|
||||
EVT_CHECKBOX(self, cID, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+1, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+2, self.EvtCheckBox)
|
||||
|
||||
|
||||
def EvtCheckBox(self, event):
|
||||
self.log.WriteText('EvtCheckBox: %d\n' % event.Checked())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestCheckBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).
|
||||
|
||||
"""
|
||||
73
wxPython/demo/wxCheckListBox.py
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
||||
'twelve', 'thirteen', 'fourteen']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckListBox control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
lb = wxCheckListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
|
||||
sampleList)
|
||||
EVT_LISTBOX(self, 60, self.EvtListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
|
||||
lb.SetSelection(0)
|
||||
|
||||
EVT_RIGHT_UP(self, self.OnDoPopup)
|
||||
|
||||
|
||||
def EvtListBox(self, event):
|
||||
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
||||
|
||||
def EvtListBoxDClick(self, event):
|
||||
self.log.WriteText('EvtListBoxDClick:\n')
|
||||
|
||||
def OnDoPopup(self, evt):
|
||||
menu = wxMenu()
|
||||
# Make this first item bold
|
||||
item = wxMenuItem(menu, wxNewId(), "If supported, this is bold")
|
||||
df = wxSystemSettings_GetSystemFont(wxSYS_DEFAULT_GUI_FONT)
|
||||
nf = wxFont(df.GetPointSize(), df.GetFamily(), df.GetStyle(), wxBOLD,
|
||||
false, df.GetFaceName())
|
||||
item.SetFont(nf)
|
||||
menu.AppendItem(item)
|
||||
|
||||
menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &1"))
|
||||
menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &2"))
|
||||
menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &3"))
|
||||
menu.AppendItem(wxMenuItem(menu, wxNewId(), "Normal Item &4"))
|
||||
|
||||
self.PopupMenu(menu, evt.GetPosition())
|
||||
menu.Destroy()
|
||||
evt.Skip()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
48
wxPython/demo/wxChoice.py
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestChoice(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxChoice control.",
|
||||
wxPoint(15, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
|
||||
self.ch = wxChoice(self, 40, (80, 50), choices = sampleList)
|
||||
EVT_CHOICE(self, 40, self.EvtChoice)
|
||||
|
||||
|
||||
def EvtChoice(self, event):
|
||||
self.log.WriteText('EvtChoice: %s\n' % event.GetString())
|
||||
self.ch.Append("A new item")
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestChoice(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices.
|
||||
"""
|
||||
31
wxPython/demo/wxColourDialog.py
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxColourDialog(frame)
|
||||
dlg.GetColourData().SetChooseFull(true)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetColourData()
|
||||
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the colour chooser dialog.
|
||||
|
||||
|
||||
"""
|
||||
70
wxPython/demo/wxComboBox.py
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestComboBox(wxPanel):
|
||||
def OnSetFocus(self, evt):
|
||||
print "OnSetFocus"
|
||||
evt.Skip()
|
||||
def OnKillFocus(self, evt):
|
||||
print "OnKillFocus"
|
||||
evt.Skip()
|
||||
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxComboBox control.",
|
||||
wxPoint(8, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
|
||||
cb = wxComboBox(self, 500, "default value", wxPoint(80, 50), wxSize(95, -1),
|
||||
sampleList, wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, 500, self.EvtComboBox)
|
||||
EVT_TEXT(self, 500, self.EvtText)
|
||||
EVT_SET_FOCUS(cb, self.OnSetFocus)
|
||||
EVT_KILL_FOCUS(cb, self.OnKillFocus)
|
||||
|
||||
cb.Append("foo", "This is some client data for this item")
|
||||
|
||||
wxComboBox(self, 501, "default value", wxPoint(80, 80), wxSize(95, -1),
|
||||
sampleList, wxCB_SIMPLE)
|
||||
EVT_COMBOBOX(self, 501, self.EvtComboBox)
|
||||
EVT_TEXT(self, 501, self.EvtText)
|
||||
|
||||
|
||||
def EvtComboBox(self, evt):
|
||||
cb = evt.GetEventObject()
|
||||
data = cb.GetClientData(cb.GetSelection())
|
||||
self.log.WriteText('EvtComboBox: %s\nClientData: %s\n' % (evt.GetString(), data))
|
||||
|
||||
def EvtText(self, evt):
|
||||
self.log.WriteText('EvtText: %s\n' % evt.GetString())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestComboBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
|
||||
|
||||
"""
|
||||
33
wxPython/demo/wxDialog.py
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", wxDefaultPosition, wxSize(350, 200))
|
||||
|
||||
wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20))
|
||||
wxButton(win, wxID_OK, " OK ", wxPoint(75, 120), wxDefaultSize).SetDefault()
|
||||
wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(200, 120), wxDefaultSize)
|
||||
|
||||
val = win.ShowModal()
|
||||
if val == wxID_OK:
|
||||
log.WriteText("You pressed OK\n")
|
||||
else:
|
||||
log.WriteText("You pressed Cancel\n")
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
53
wxPython/demo/wxDirDialog.py
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxDirDialog(frame)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the directory chooser dialog.
|
||||
|
||||
wxDirDialog()
|
||||
------------------------
|
||||
|
||||
wxDirDialog(wxWindow* parent, const wxString& message = "Choose a directory", const wxString& defaultPath = "", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxDirDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultPath = The default path, or the empty string.
|
||||
|
||||
style = A dialog style, currently unused.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
||||
268
wxPython/demo/wxDragImage.py
Normal file
@@ -0,0 +1,268 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import images
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class DragShape:
|
||||
def __init__(self, bmp):
|
||||
self.bmp = bmp
|
||||
self.pos = wxPoint(0,0)
|
||||
self.shown = true
|
||||
self.text = None
|
||||
self.fullscreen = false
|
||||
|
||||
|
||||
def HitTest(self, pt):
|
||||
rect = self.GetRect()
|
||||
return rect.Inside(pt.x, pt.y)
|
||||
|
||||
|
||||
def GetRect(self):
|
||||
return wxRect(self.pos.x, self.pos.y,
|
||||
self.bmp.GetWidth(), self.bmp.GetHeight())
|
||||
|
||||
|
||||
def Draw(self, dc, op = wxCOPY):
|
||||
if self.bmp.Ok():
|
||||
memDC = wxMemoryDC()
|
||||
memDC.SelectObject(self.bmp)
|
||||
|
||||
dc.Blit(self.pos.x, self.pos.y,
|
||||
self.bmp.GetWidth(), self.bmp.GetHeight(),
|
||||
memDC, 0, 0, op, true)
|
||||
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class DragCanvas(wxScrolledWindow):
|
||||
def __init__(self, parent, ID):
|
||||
wxScrolledWindow.__init__(self, parent, ID)
|
||||
self.shapes = []
|
||||
self.dragImage = None
|
||||
self.dragShape = None
|
||||
self.hiliteShape = None
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_ARROW))
|
||||
self.bg_bmp = images.getBackgroundBitmap()
|
||||
|
||||
|
||||
# Make a shape from an image and mask. This one will demo
|
||||
# dragging outside the window
|
||||
bmp = images.getTestStarBitmap()
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(5, 5)
|
||||
shape.fullscreen = true
|
||||
self.shapes.append(shape)
|
||||
|
||||
|
||||
# Make a shape from some text
|
||||
text = "Some Text"
|
||||
font = wxFont(15, wxROMAN, wxNORMAL, wxBOLD)
|
||||
textExtent = self.GetFullTextExtent(text, font)
|
||||
bmp = wxEmptyBitmap(textExtent[0], textExtent[1])
|
||||
dc = wxMemoryDC()
|
||||
dc.SelectObject(bmp)
|
||||
dc.Clear()
|
||||
dc.SetTextForeground(wxRED)
|
||||
dc.SetFont(font)
|
||||
dc.DrawText(text, 0, 0)
|
||||
dc.SelectObject(wxNullBitmap)
|
||||
del dc
|
||||
mask = wxMaskColour(bmp, wxWHITE)
|
||||
bmp.SetMask(mask)
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(5, 100)
|
||||
shape.text = "Some dragging text"
|
||||
self.shapes.append(shape)
|
||||
|
||||
|
||||
# Make some shapes from some playing card images.
|
||||
x = 200
|
||||
for card in ['_01c_', '_12h_', '_13d_', '_10s_']:
|
||||
bmpFunc = getattr(images, "get%sBitmap" % card)
|
||||
bmp = bmpFunc()
|
||||
shape = DragShape(bmp)
|
||||
shape.pos = wxPoint(x, 5)
|
||||
self.shapes.append(shape)
|
||||
x = x + 80
|
||||
|
||||
|
||||
EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
|
||||
EVT_PAINT(self, self.OnPaint)
|
||||
EVT_LEFT_DOWN(self, self.OnLeftDown)
|
||||
EVT_LEFT_UP(self, self.OnLeftUp)
|
||||
EVT_MOTION(self, self.OnMotion)
|
||||
|
||||
|
||||
|
||||
def TileBackground(self, dc):
|
||||
# tile the background bitmap
|
||||
sz = self.GetClientSize()
|
||||
w = self.bg_bmp.GetWidth()
|
||||
h = self.bg_bmp.GetHeight()
|
||||
|
||||
x = 0
|
||||
while x < sz.width:
|
||||
y = 0
|
||||
while y < sz.height:
|
||||
dc.DrawBitmap(self.bg_bmp, x, y)
|
||||
y = y + h
|
||||
x = x + w
|
||||
|
||||
|
||||
def DrawShapes(self, dc):
|
||||
for shape in self.shapes:
|
||||
if shape.shown:
|
||||
shape.Draw(dc)
|
||||
|
||||
|
||||
def FindShape(self, pt):
|
||||
for shape in self.shapes:
|
||||
if shape.HitTest(pt):
|
||||
return shape
|
||||
return None
|
||||
|
||||
|
||||
def EraseShape(self, shape, dc):
|
||||
r = shape.GetRect()
|
||||
dc.SetClippingRegion(r.x, r.y, r.width, r.height)
|
||||
self.TileBackground(dc)
|
||||
self.DrawShapes(dc)
|
||||
dc.DestroyClippingRegion()
|
||||
|
||||
|
||||
def OnEraseBackground(self, evt):
|
||||
dc = evt.GetDC()
|
||||
if not dc:
|
||||
dc = wxClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRegion(rect.x, rect.y, rect.width, rect.height)
|
||||
self.TileBackground(dc)
|
||||
|
||||
|
||||
def OnPaint(self, evt):
|
||||
dc = wxPaintDC(self)
|
||||
self.PrepareDC(dc)
|
||||
self.DrawShapes(dc)
|
||||
|
||||
|
||||
def OnLeftDown(self, evt):
|
||||
shape = self.FindShape(evt.GetPosition())
|
||||
if shape:
|
||||
# get ready to start dragging, but wait for the user to
|
||||
# move it a bit first
|
||||
self.dragShape = shape
|
||||
self.dragStartPos = evt.GetPosition()
|
||||
|
||||
|
||||
def OnLeftUp(self, evt):
|
||||
if not self.dragImage or not self.dragShape:
|
||||
self.dragImage = None
|
||||
self.dragShape = None
|
||||
return
|
||||
|
||||
# end the dragging
|
||||
self.dragImage.Hide()
|
||||
self.dragImage.EndDrag()
|
||||
self.dragImage = None
|
||||
|
||||
dc = wxClientDC(self)
|
||||
if self.hiliteShape:
|
||||
self.hiliteShape.Draw(dc)
|
||||
self.hiliteShape = None
|
||||
|
||||
# reposition and draw the shape
|
||||
self.dragShape.pos = self.dragShape.pos + evt.GetPosition() - self.dragStartPos
|
||||
self.dragShape.shown = true
|
||||
self.dragShape.Draw(dc)
|
||||
self.dragShape = None
|
||||
|
||||
|
||||
def OnMotion(self, evt):
|
||||
if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown():
|
||||
return
|
||||
|
||||
# if we have a shape, but havn't started dragging yet
|
||||
if self.dragShape and not self.dragImage:
|
||||
|
||||
# only start the drag after having moved a couple pixels
|
||||
tolerance = 2
|
||||
pt = evt.GetPosition()
|
||||
dx = abs(pt.x - self.dragStartPos.x)
|
||||
dy = abs(pt.y - self.dragStartPos.y)
|
||||
if dx <= tolerance and dy <= tolerance:
|
||||
return
|
||||
|
||||
# erase the shape since it will be drawn independently now
|
||||
dc = wxClientDC(self)
|
||||
self.dragShape.shown = false
|
||||
self.EraseShape(self.dragShape, dc)
|
||||
|
||||
|
||||
if self.dragShape.text:
|
||||
self.dragImage = wxDragString(self.dragShape.text,
|
||||
wxStockCursor(wxCURSOR_HAND))
|
||||
else:
|
||||
self.dragImage = wxDragImage(self.dragShape.bmp,
|
||||
wxStockCursor(wxCURSOR_HAND))
|
||||
|
||||
hotspot = self.dragStartPos - self.dragShape.pos
|
||||
self.dragImage.BeginDrag(hotspot, self, self.dragShape.fullscreen)
|
||||
|
||||
self.dragImage.Move(pt)
|
||||
self.dragImage.Show()
|
||||
|
||||
|
||||
# if we have shape and image then move it, posibly highlighting another shape.
|
||||
elif self.dragShape and self.dragImage:
|
||||
onShape = self.FindShape(evt.GetPosition())
|
||||
unhiliteOld = false
|
||||
hiliteNew = false
|
||||
|
||||
# figure out what to hilite and what to unhilite
|
||||
if self.hiliteShape:
|
||||
if onShape is None or self.hiliteShape is not onShape:
|
||||
unhiliteOld = true
|
||||
|
||||
if onShape and onShape is not self.hiliteShape and onShape.shown:
|
||||
hiliteNew = TRUE
|
||||
|
||||
# if needed, hide the drag image so we can update the window
|
||||
if unhiliteOld or hiliteNew:
|
||||
self.dragImage.Hide()
|
||||
|
||||
if unhiliteOld:
|
||||
dc = wxClientDC(self)
|
||||
self.hiliteShape.Draw(dc)
|
||||
self.hiliteShape = None
|
||||
|
||||
if hiliteNew:
|
||||
dc = wxClientDC(self)
|
||||
self.hiliteShape = onShape
|
||||
self.hiliteShape.Draw(dc, wxINVERT)
|
||||
|
||||
# now move it and show it again if needed
|
||||
self.dragImage.Move(evt.GetPosition())
|
||||
if unhiliteOld or hiliteNew:
|
||||
self.dragImage.Show()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = DragCanvas(nb, -1)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
151
wxPython/demo/wxDynamicSashWindow.py
Normal file
@@ -0,0 +1,151 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.gizmos import *
|
||||
from wxPython.stc import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# This is an example of the complex view that manages its own scrollbars
|
||||
# as described in the overview below.
|
||||
|
||||
class TestView(wxStyledTextCtrl):
|
||||
def __init__(self, parent, ID, log):
|
||||
wxStyledTextCtrl.__init__(self, parent, ID, style=wxNO_BORDER)
|
||||
self.dyn_sash = parent
|
||||
self.log = log
|
||||
self.SetupScrollBars()
|
||||
self.SetMarginWidth(1,0)
|
||||
self.StyleSetFont(wxSTC_STYLE_DEFAULT,
|
||||
wxFont(10, wxMODERN, wxNORMAL, wxNORMAL))
|
||||
EVT_DYNAMIC_SASH_SPLIT(self, -1, self.OnSplit)
|
||||
EVT_DYNAMIC_SASH_UNIFY(self, -1, self.OnUnify)
|
||||
|
||||
|
||||
def SetupScrollBars(self):
|
||||
# hook the scrollbars provided by the wxDynamicSashWindow
|
||||
# to this view
|
||||
v_bar = self.dyn_sash.GetVScrollBar(self)
|
||||
h_bar = self.dyn_sash.GetHScrollBar(self)
|
||||
EVT_SCROLL(v_bar, self.OnSBScroll)
|
||||
EVT_SCROLL(h_bar, self.OnSBScroll)
|
||||
EVT_SET_FOCUS(v_bar, self.OnSBFocus)
|
||||
EVT_SET_FOCUS(h_bar, self.OnSBFocus)
|
||||
|
||||
# And set the wxStyledText to use these scrollbars instead
|
||||
# of its built-in ones.
|
||||
self.SetVScrollBar(v_bar)
|
||||
self.SetHScrollBar(h_bar)
|
||||
|
||||
|
||||
def __del__(self):
|
||||
self.log.write("TestView.__del__\n")
|
||||
|
||||
def OnSplit(self, evt):
|
||||
self.log.write("TestView.OnSplit\n");
|
||||
newview = TestView(self.dyn_sash, -1, self.log)
|
||||
newview.SetDocPointer(self.GetDocPointer()) # use the same document
|
||||
self.SetupScrollBars()
|
||||
|
||||
|
||||
def OnUnify(self, evt):
|
||||
self.log.write("TestView.OnUnify\n");
|
||||
self.SetupScrollBars()
|
||||
|
||||
|
||||
def OnSBScroll(self, evt):
|
||||
# redirect the scroll events from the dyn_sash's scrollbars to the STC
|
||||
self.GetEventHandler().ProcessEvent(evt)
|
||||
|
||||
def OnSBFocus(self, evt):
|
||||
# when the scrollbar gets the focus move it back to the STC
|
||||
self.SetFocus()
|
||||
|
||||
|
||||
sampleText="""\
|
||||
You can drag the little tabs above the vertical scrollbar, or to the
|
||||
left of the horizontal scrollbar to split this view, and you can
|
||||
continue splitting the new views as much as you like. Try it and see.
|
||||
|
||||
In this case the views also share the same document so changes in one
|
||||
are instantly seen in the others. This is a feature of the
|
||||
wxStyledTextCtrl that is used for the view class in this sample.
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# This one is simpler, but doesn't do anything with the scrollbars
|
||||
# except the default wxDynamicSashWindow behaviour
|
||||
|
||||
class SimpleView(wxPanel):
|
||||
def __init__(self, parent, ID, log):
|
||||
wxPanel.__init__(self, parent, ID)
|
||||
self.dyn_sash = parent
|
||||
self.log = log
|
||||
self.SetBackgroundColour("LIGHT BLUE")
|
||||
EVT_DYNAMIC_SASH_SPLIT(self, -1, self.OnSplit)
|
||||
|
||||
def OnSplit(self, evt):
|
||||
v = SimpleView(self.dyn_sash, -1, self.log)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if 1:
|
||||
win = wxDynamicSashWindow(nb, -1, style = 0
|
||||
| wxCLIP_CHILDREN
|
||||
#| wxDS_MANAGE_SCROLLBARS
|
||||
#| wxDS_DRAG_CORNER
|
||||
)
|
||||
win.SetFont(wxFont(10, wxMODERN, wxNORMAL, wxNORMAL))
|
||||
view = TestView(win, -1, log)
|
||||
view.SetText(sampleText)
|
||||
else:
|
||||
win = wxDynamicSashWindow(nb, -1)
|
||||
view = SimpleView(win, -1, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = """\
|
||||
<html><body>
|
||||
<h2>wxDynamicSashWindow</h2>
|
||||
<p>
|
||||
wxDynamicSashWindow widgets manages the way other widgets are viewed.
|
||||
When a wxDynamicSashWindow is first shown, it will contain one child
|
||||
view, a viewport for that child, and a pair of scrollbars to allow the
|
||||
user to navigate the child view area. Next to each scrollbar is a small
|
||||
tab. By clicking on either tab and dragging to the appropriate spot, a
|
||||
user can split the view area into two smaller views separated by a
|
||||
draggable sash. Later, when the user wishes to reunify the two subviews,
|
||||
the user simply drags the sash to the side of the window.
|
||||
wxDynamicSashWindow will automatically reparent the appropriate child
|
||||
view back up the window hierarchy, and the wxDynamicSashWindow will have
|
||||
only one child view once again.
|
||||
<p>
|
||||
As an application developer, you will simply create a wxDynamicSashWindow
|
||||
using either the Create() function or the more complex constructor
|
||||
provided below, and then create a view window whose parent is the
|
||||
wxDynamicSashWindow. The child should respond to
|
||||
wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
|
||||
constructing a new view window whose parent is also the
|
||||
wxDynamicSashWindow. That's it! Now your users can dynamically split
|
||||
and reunify the view you provided.
|
||||
<p>
|
||||
If you wish to handle the scrollbar events for your view, rather than
|
||||
allowing wxDynamicSashWindow to do it for you, things are a bit more
|
||||
complex. (You might want to handle scrollbar events yourself, if,
|
||||
for instance, you wish to scroll a subwindow of the view you add to
|
||||
your wxDynamicSashWindow object, rather than scrolling the whole view.)
|
||||
In this case, you will need to construct your wxDynamicSashWindow without
|
||||
the wxDS_MANAGE_SCROLLBARS style and you will need to use the
|
||||
GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
|
||||
controls and call SetEventHanler() on them to redirect the scrolling
|
||||
events whenever your window is reparented by wxDyanmicSashWindow.
|
||||
You will need to set the scrollbars' event handler at three times:
|
||||
<p>
|
||||
<ul>
|
||||
<li> When your view is created
|
||||
<li> When your view receives a wxDynamicSashSplitEvent
|
||||
<li> When your view receives a wxDynamicSashUnifyEvent
|
||||
</ul>
|
||||
</body></html>
|
||||
"""
|
||||
40
wxPython/demo/wxEditableListBox.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.gizmos import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
self.elb = wxEditableListBox(self, -1, "List of Stuff",
|
||||
(50,50), (250, 250))
|
||||
|
||||
self.elb.SetStrings(["This is a nifty ListBox widget",
|
||||
"that is editable by the user.",
|
||||
"",
|
||||
"Use the buttons above to",
|
||||
"manipulate items in the list",
|
||||
"Or to add new ones.",
|
||||
])
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class provides a composite control that lets the
|
||||
user easily enter and edit a list of strings.
|
||||
"""
|
||||
64
wxPython/demo/wxEditor.py
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.editor import wxEditor
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxPanel(nb, -1)
|
||||
ed = wxEditor(win, -1, style=wxSUNKEN_BORDER)
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(ed, 1, wxALL|wxGROW, 1)
|
||||
win.SetSizer(box)
|
||||
win.SetAutoLayout(true)
|
||||
|
||||
ed.SetText(["",
|
||||
"This is a simple text editor, the class name is",
|
||||
"wxEditor. Type a few lines and try it out.",
|
||||
"",
|
||||
"It uses Windows-style key commands that can be overriden by subclassing.",
|
||||
"Mouse select works. Here are the key commands:",
|
||||
"",
|
||||
"Cursor movement: Arrow keys or mouse",
|
||||
"Beginning of line: Home",
|
||||
"End of line: End",
|
||||
"Beginning of buffer: Control-Home",
|
||||
"End of the buffer: Control-End",
|
||||
"Select text: Hold down Shift while moving the cursor",
|
||||
"Copy: Control-Insert, Control-C",
|
||||
"Cut: Shift-Delete, Control-X",
|
||||
"Paste: Shift-Insert, Control-V",
|
||||
""])
|
||||
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
overview = """
|
||||
The wxEditor class implements a simple text editor using wxPython. You
|
||||
can create a custom editor by subclassing wxEditor. Even though much of
|
||||
the editor is implemented in Python, it runs surprisingly smoothly on
|
||||
normal hardware with small files.
|
||||
|
||||
How to use it
|
||||
-------------
|
||||
The demo code (demo/wxEditor.py) shows how to use wxEditor as a simple text
|
||||
box. Use the SetText() and GetText() methods to set or get text from
|
||||
the component; these both use a list of strings.
|
||||
|
||||
The samples/FrogEdit directory has an example of a simple text editor
|
||||
application that uses the wxEditor component.
|
||||
|
||||
Subclassing
|
||||
-----------
|
||||
To add or change functionality, you can subclass this
|
||||
component. One example of this might be to change the key
|
||||
Alt key commands. In that case you would (for example) override the
|
||||
SetAltFuncs() method.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
31
wxPython/demo/wxFileDialog.py
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN|wxMULTIPLE)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
for path in dlg.GetPaths():
|
||||
log.WriteText('You selected: %s\n' % path)
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the file chooser dialog.
|
||||
|
||||
"""
|
||||