Merged the wxPy_newswig branch into the HEAD branch (main trunk)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-11-12 21:34:20 +00:00
parent eb6a4098a0
commit d14a1e2856
987 changed files with 671143 additions and 783083 deletions

View File

@@ -20,10 +20,10 @@ class TestPanel(wxPanel):
def OnPaint(self, evt):
dc = wxPaintDC(self)
sz = fancytext.getExtent(test_str, dc)
fancytext.renderToDC(test_str, dc, 20, 20)
w, h = fancytext.GetExtent(test_str, dc)
fancytext.RenderToDC(test_str, dc, 20, 20)
fancytext.renderToDC(test_str2, dc, 20, 20 + sz.height + 10)
fancytext.RenderToDC(test_str2, dc, 20, 20 + h + 10)
#----------------------------------------------------------------------

View File

@@ -46,7 +46,7 @@ class CustomDataTable(wxPyGridTableBase):
try:
return not self.data[row][col]
except IndexError:
return true
return True
# Get/Set values in the table. The Python version of these
# methods can handle any data-type, (as long as the Editor and
@@ -93,7 +93,7 @@ class CustomDataTable(wxPyGridTableBase):
def CanGetValueAs(self, row, col, typeName):
colType = self.dataTypes[col].split(':')[0]
if typeName == colType:
return true
return True
else:
return False
@@ -117,7 +117,7 @@ class CustTableGrid(wxGrid):
# The second parameter means that the grid is to take ownership of the
# table and will destroy it when done. Otherwise you would need to keep
# a reference to it and call it's Destroy method later.
self.SetTable(table, true)
self.SetTable(table, True)
self.SetRowLabelSize(0)
self.SetMargins(0,0)
@@ -163,7 +163,7 @@ if __name__ == '__main__':
import sys
app = wxPySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(true)
frame.Show(True)
app.MainLoop()

View File

@@ -56,7 +56,7 @@ class MyParentFrame(wxMDIParentFrame):
while x < sz.width:
y = 0
while y < sz.height:
dc.DrawBitmap(self.bg_bmp, x, y)
dc.DrawBitmap(self.bg_bmp, (x, y))
y = y + h
x = x + w

View File

@@ -18,16 +18,17 @@ import wx.html
import images
##wx.Trap()
##raw_input("Press a key...")
# For debugging
##wx.Trap();
##print os.getpid(); raw_input("Press a key...")
# Use Python's bool constants if available, make aliases if not
try:
True
except NameError:
True = 1==1
False = 1==0
__builtins__.True = 1==1
__builtins__.False = 1==0
#---------------------------------------------------------------------------
@@ -40,6 +41,7 @@ _treeList = [
'wxMaskedNumCtrl',
'FloatCanvas',
'wxXmlResourceSubclass',
'wxGridBagSizer',
]),
# managed windows == things with a (optional) caption you can close
@@ -84,7 +86,6 @@ _treeList = [
'wxChoice',
'wxComboBox',
'wxGauge',
'wxGenericDirCtrl',
'wxGrid',
'wxGrid_MegaExample',
'wxListbook',
@@ -112,18 +113,28 @@ _treeList = [
'wxValidator',
]),
('Custom Controls', [
'AnalogClockWindow',
'ColourSelect',
'GenericButtons',
'wxEditor',
'wxGenericDirCtrl',
'wxLEDNumberCtrl',
'wxMultiSash',
'wxPopupControl',
'wxPyColourChooser',
'wxTreeListCtrl',
]),
# controls coming from other libraries
('More Windows/Controls', [
#'wxFloatBar', deprecated
#'wxMVCTree', deprecated
#'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
'AnalogClockWindow',
'ColourSelect',
'ContextHelp',
'FancyText',
'FloatCanvas',
'FileBrowseButton',
'GenericButtons',
'MaskedEditControls',
'PyShell',
'PyCrust',
@@ -132,22 +143,16 @@ _treeList = [
'Throbber',
'wxCalendar',
'wxCalendarCtrl',
'wxPyColourChooser',
'wxDynamicSashWindow',
'wxEditableListBox',
'wxEditor',
'wxHtmlWindow',
'wxIEHtmlWin',
'wxIntCtrl',
'wxLEDNumberCtrl',
'wxMimeTypesManager',
'wxMaskedNumCtrl',
'wxMultiSash',
'wxPopupControl',
'wxStyledTextCtrl_1',
'wxStyledTextCtrl_2',
'wxTimeCtrl',
'wxTreeListCtrl',
'wxVListBox',
]),
@@ -157,6 +162,7 @@ _treeList = [
'Layoutf',
'RowColSizer',
'Sizers',
'wxGridBagSizer',
'wxLayoutConstraints',
'wxScrolledPanel',
'wxXmlResource',
@@ -809,7 +815,7 @@ def main():
os.chdir(demoPath)
except:
pass
app = MyApp(wx.Platform == "__WXMAC__")
app = MyApp(0) #wx.Platform == "__WXMAC__")
app.MainLoop()

View File

@@ -44,7 +44,7 @@ class TestFrame(wxFrame):
self.SetWindowShape()
dc = wxClientDC(self)
dc.DrawBitmap(self.bmp, 0,0, True)
dc.DrawBitmap(self.bmp, (0,0), True)
def SetWindowShape(self, *evt):
@@ -63,7 +63,7 @@ class TestFrame(wxFrame):
def OnPaint(self, evt):
dc = wxPaintDC(self)
dc.DrawBitmap(self.bmp, 0,0, True)
dc.DrawBitmap(self.bmp, (0,0), True)
def OnExit(self, evt):
self.Close()

View File

@@ -1,153 +1,146 @@
<?xml version="1.0"?>
<!-- XML resource generated by wxDesigner from file: resource.wdr -->
<!-- Do not modify this file, all changes will be lost! -->
<?xml version="1.0" ?>
<resource>
<object class="wxPanel" name="MyPanel">
<object class="wxFlexGridSizer">
<cols>2</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>0</hgap>
<object class="sizeritem">
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<object class="wxPanel" name="MyPanel">
<object class="wxGridBagSizer">
<vgap>0</vgap>
<hgap>0</hgap>
<object class="sizeritem">
<cellpos>0,0</cellpos>
<cellspan>4,1</cellspan>
<object class="wxFlexGridSizer">
<cols>2</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>0</hgap>
<object class="sizeritem">
<flag>wxTOP|wxLEFT|wxRIGHT|wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
<object class="wxStaticText" name="ID_TEXT">
<label>Name:</label>
<label>Name:</label>
</object>
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
</object>
<object class="sizeritem">
<flag>wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxGROW|wxALIGN_CENTRE_VERTICAL</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_NameField">
<size>80,-1</size>
<value></value>
<size>80,-1</size>
<value></value>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxStaticText" name="ID_TEXT">
<label>Address:</label>
<label>Address:</label>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_Addr1Field">
<size>80,-1</size>
<value></value>
<size>80,-1</size>
<value></value>
</object>
</object>
<object class="spacer">
<flag>wxALIGN_CENTRE</flag>
<border>5</border>
<size>20,20</size>
</object>
<object class="sizeritem">
</object>
<object class="spacer">
<size>20,20</size>
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_TEXTCTRL">
<size>80,-1</size>
<value></value>
<size>80,-1</size>
<value></value>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxStaticText" name="ID_TEXT">
<label>City, State, Zip:</label>
<label>City, State, Zip:</label>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_CityField">
<size>100,-1</size>
<value></value>
</object>
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_CityField">
<size>100,-1</size>
<value></value>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_StateField">
<size>30,-1</size>
<value></value>
</object>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_StateField">
<size>30,-1</size>
<value></value>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_ZipField">
<size>50,-1</size>
<value></value>
</object>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_ZipField">
<size>50,-1</size>
<value></value>
</object>
</object>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<object class="wxStaticText" name="ID_TEXT">
<label>Phone:</label>
<label>Phone:</label>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_PhoneField">
<size>80,-1</size>
<value></value>
<size>80,-1</size>
<value></value>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
<object class="wxStaticText" name="ID_TEXT">
<label>Email:</label>
<label>Email:</label>
</object>
</object>
<object class="sizeritem">
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP</flag>
<border>5</border>
<object class="wxTextCtrl" name="ID_EmailField">
<size>80,-1</size>
<value></value>
<size>80,-1</size>
<value></value>
</object>
</object>
</object>
<object class="spacer">
<flag>wxALIGN_CENTRE|wxALL</flag>
<border>5</border>
<size>20,20</size>
</object>
<object class="spacer">
<flag>wxALIGN_CENTRE|wxALL</flag>
<border>5</border>
<size>20,20</size>
<cellpos>0,1</cellpos>
</object>
<object class="sizeritem">
<cellpos>1,2</cellpos>
<object class="wxButton" name="wxID_OK">
<label>Save</label>
</object>
<object class="sizeritem">
<flag>wxGROW|wxALIGN_CENTER_VERTICAL</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxALL</flag>
<border>5</border>
<object class="wxButton" name="wxID_OK">
<label>Save</label>
</object>
</object>
<object class="sizeritem">
<flag>wxALIGN_CENTRE|wxALL</flag>
<border>5</border>
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<cellpos>2,2</cellpos>
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
</object>
</object>
</object>
</resource>
</object>
</resource>

View File

@@ -47,7 +47,7 @@ ID_U_Max_Ctrl = 10035
ID_V_Min_Ctrl = 10036
ID_V_Max_Ctrl = 10037
def MakeJoystickTestPanel( parent, call_fit = true, set_sizer = true ):
def MakeJoystickTestPanel( parent, call_fit = True, set_sizer = True ):
item0 = wxBoxSizer( wxVERTICAL )
item1 = wxFlexGridSizer( 0, 8, 0, 0 )
@@ -288,10 +288,10 @@ def MakeJoystickTestPanel( parent, call_fit = true, set_sizer = true ):
item0.AddSizer( item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 15 )
if set_sizer == true:
parent.SetAutoLayout( true )
if set_sizer == True:
parent.SetAutoLayout( True )
parent.SetSizer( item0 )
if call_fit == true:
if call_fit == True:
item0.Fit( parent )
item0.SetSizeHints( parent )

View File

@@ -26,7 +26,7 @@ ID_PRINT_CMD_TXT = 10014
ID_ALL_CMDS_TXT = 10015
ID_LISTBOX = 10016
def MakeMimeTypesTestPanel( parent, call_fit = true, set_sizer = true ):
def MakeMimeTypesTestPanel( parent, call_fit = True, set_sizer = True ):
item0 = wxBoxSizer( wxVERTICAL )
item1 = wxBoxSizer( wxHORIZONTAL )
@@ -35,7 +35,7 @@ def MakeMimeTypesTestPanel( parent, call_fit = true, set_sizer = true ):
item1.AddWindow( item2, 0, wxALIGN_CENTRE|wxALL, 5 )
item3 = wxRadioButton( parent, ID_EXTENSION_Btn, "By extension", wxDefaultPosition, wxDefaultSize, wxRB_GROUP )
item3.SetValue( true )
item3.SetValue( True )
item1.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 )
item4 = wxRadioButton( parent, ID_MIME_BTN, "By mime type", wxDefaultPosition, wxDefaultSize, 0 )
@@ -60,7 +60,7 @@ def MakeMimeTypesTestPanel( parent, call_fit = true, set_sizer = true ):
item9.SetFont( wxFont( 14, wxSWISS, wxNORMAL, wxBOLD ) )
item8.AddWindow( item9, 0, wxALL, 5 )
item8.AddSpacer( 20, 20, 0, wxALIGN_CENTRE|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 )
@@ -134,10 +134,10 @@ def MakeMimeTypesTestPanel( parent, call_fit = true, set_sizer = true ):
item0.AddSizer( item7, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5 )
if set_sizer == true:
parent.SetAutoLayout( true )
if set_sizer == True:
parent.SetAutoLayout( True )
parent.SetSizer( item0 )
if call_fit == true:
if call_fit == True:
item0.Fit( parent )
item0.SetSizeHints( parent )

View File

@@ -0,0 +1,60 @@
#----------------------------------------------------------------------
# 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 *
print "wxVERSION_STRING = ", wxVERSION_STRING
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)
text = wxStaticText(panel, -1, "Hello World!")
text.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxBOLD))
text.SetSize(text.GetBestSize())
btn = wxButton(panel, -1, "Close")
btn.SetDefault()
btn2 = wxButton(panel, -1, "Just for fun...")
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(text, 0, wxALL, 10)
sizer.Add(btn, 0, wxALL, 10)
sizer.Add(btn2, 0, wxALL, 10)
panel.SetSizer(sizer)
panel.SetAutoLayout(True)
panel.Layout()
EVT_BUTTON(self, btn.GetId(), self.OnButton)
EVT_BUTTON(self, btn2.GetId(), self.OnFunButton)
def OnButton(self, evt):
"""Event handler for the button click."""
print "OnButton"
self.Close()
def OnFunButton(self, evt):
"""Event handler for the button click."""
print "Having fun yet?"
app = wxPySimpleApp()
frame = MyFrame(None, "Simple wxPython App")
frame.Show(True)
app.MainLoop()

View File

@@ -20,6 +20,9 @@ on the command line.
import wx # This module uses the new wx namespace
print "wx.VERSION_STRING = ", wx.VERSION_STRING
assertMode = wx.PYAPP_ASSERT_DIALOG
##assertMode = wx.PYAPP_ASSERT_EXCEPTION
import sys, os
#----------------------------------------------------------------------------
@@ -43,7 +46,7 @@ class RunDemoApp(wx.App):
wx.InitAllImageHandlers()
wx.Log_SetActiveTarget(wx.LogStderr())
#self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
self.SetAssertMode(assertMode)
frame = wx.Frame(None, -1, "RunDemo: " + self.name, pos=(50,50), size=(0,0),
style=wx.NO_FULL_REPAINT_ON_RESIZE|wx.DEFAULT_FRAME_STYLE)
@@ -71,8 +74,11 @@ class RunDemoApp(wx.App):
# otherwise the demo made its own frame, so just put a
# button in this one
if hasattr(frame, 'otherWin'):
b = wx.Button(frame, -1, " Exit ")
frame.SetSize((200, 100))
p = wx.Panel(frame, -1)
b = wx.Button(p, -1, " Exit ", (10,10))
p.Fit()
frame.SetClientSize(p.GetSize())
#frame.SetSize((200, 100))
wx.EVT_BUTTON(frame, b.GetId(), self.OnButton)
else:
# It was probably a dialog or something that is already

View File

@@ -6,6 +6,10 @@
#----------------------------------------------------------------------
import wx # This module uses the new wx namespace
print "wx.VERSION_STRING = ", wx.VERSION_STRING
#import os; print os.getpid(); raw_input("press a key...")
class MyFrame(wx.Frame):
"""

View File

@@ -23,7 +23,7 @@ class TestCheckBox(wxPanel):
def EvtCheckBox(self, event):
self.log.WriteText('EvtCheckBox: %d\n' % event.Checked())
self.log.WriteText('EvtCheckBox: %d\n' % event.IsChecked())
#---------------------------------------------------------------------------

View File

@@ -1,6 +1,6 @@
from wxPython.wx import *
from wxPython.help import *
##from wxPython.help import *
#---------------------------------------------------------------------------
# Create and set a help provider. Normally you would do this in
@@ -28,10 +28,7 @@ class TestDialog(wxDialog):
# This next step is the most important, it turns this Python
# object into the real wrapper of the dialog (instead of pre)
# as far as the wxPython extension is concerned.
self.this = pre.this
self.thisown = pre.thisown
pre.thisown = 0
self.PostCreate(pre)
# Now continue with the normal construction of the dialog
# contents
@@ -83,7 +80,7 @@ class TestDialog(wxDialog):
btn.SetHelpText("The Cancel button cnacels the dialog. (Duh!)")
box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
sizer.AddSizer(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
sizer.Add(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
self.SetSizer(sizer)
self.SetAutoLayout(True)

View File

@@ -30,7 +30,7 @@ class TestPanel(wxPanel):
box.Add(t, 0, wxCENTER|wxALL, 5)
box.Add(wxStaticLine(self, -1), 0, wxEXPAND)
box.Add(10,20)
box.Add((10,20))
t = wxStaticText(self, -1, text)
t.SetFont(nf)

View File

@@ -0,0 +1,138 @@
import wx # This module uses the new wx namespace
#----------------------------------------------------------------------
gbsDescription = """\
The wxGridBagSizer is similar to the wxFlexGridSizer except the items are explicitly positioned
in a virtual cell of the layout grid, and column or row spanning is allowed. For example, this
static text is positioned at (0,0) and it spans 7 columns.
"""
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "wxGridBagSizer")
p = wx.Panel(self, -1)
gbs = self.gbs = wx.GridBagSizer()
gbs.Add( wx.StaticText(p, -1, gbsDescription),
(0,0), (1,7), wx.ALIGN_CENTER | wx.ALL, 5)
gbs.Add( wx.TextCtrl(p, -1, "pos(1,0)"), (1,0) )
gbs.Add( wx.TextCtrl(p, -1, "pos(1,1)"), (1,1) )
gbs.Add( wx.TextCtrl(p, -1, "pos(2,0)"), (2,0) )
gbs.Add( wx.TextCtrl(p, -1, "pos(2,1)"), (2,1) )
gbs.Add( wx.TextCtrl(p, -1, "pos(3,2), span(1,2)\nthis row and col are growable", style=wx.TE_MULTILINE),
(3,2), (1,2), flag=wx.EXPAND )
gbs.Add( wx.TextCtrl(p, -1, "pos(4,3), span(3,1)", style=wx.TE_MULTILINE),
(4,3), (3,1), wx.EXPAND)
gbs.Add( wx.TextCtrl(p, -1, "pos(5,4)"), (5,4), flag=wx.EXPAND )
gbs.Add( wx.TextCtrl(p, -1, "pos(6,5)"), (6,5), flag=wx.EXPAND )
gbs.Add( wx.TextCtrl(p, -1, "pos(7,6)"), (7,6) )
moveBtn1 = wx.Button(p, -1, "Move this to (3,6)")
moveBtn2 = wx.Button(p, -1, "Move this to (3,6)");
gbs.Add( moveBtn1, (10,2) )
gbs.Add( moveBtn2, (10,3) )
hideBtn = wx.Button(p, -1, "Hide this item -->")
gbs.Add(hideBtn, (12, 3))
hideTxt = wx.TextCtrl(p, -1, "pos(12,4), size(150, -1)", size = (150,-1))
gbs.Add( hideTxt, (12,4) )
showBtn = wx.Button(p, -1, "<-- Show it again")
gbs.Add(showBtn, (12, 5))
showBtn.Disable()
self.hideBtn = hideBtn
self.showBtn = showBtn
self.hideTxt = hideTxt
self.Bind(wx.EVT_BUTTON, self.OnHideButton, hideBtn)
self.Bind(wx.EVT_BUTTON, self.OnShowButton, showBtn)
self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn1)
self.Bind(wx.EVT_BUTTON, self.OnMoveButton, moveBtn2)
# Add a spacer at the end to ensure some extra space at the bottom
gbs.Add((10,10), (14,0))
gbs.AddGrowableRow(3)
gbs.AddGrowableCol(2)
p.SetSizerAndFit(gbs)
self.SetClientSize(p.GetSize())
def OnHideButton(self, evt):
self.gbs.Hide(self.hideTxt)
self.hideBtn.Disable()
self.showBtn.Enable()
self.gbs.Layout()
def OnShowButton(self, evt):
self.gbs.Show(self.hideTxt)
self.hideBtn.Enable()
self.showBtn.Disable()
self.gbs.Layout()
def OnMoveButton(self, evt):
btn = evt.GetEventObject()
curPos = self.gbs.GetItemPosition(btn)
# if it's already at the "other" spot then move it back
if curPos == (3,6):
self.gbs.SetItemPosition(btn, self.lastPos)
btn.SetLabel("Move this to (3,6)")
else:
if self.gbs.CheckForIntersection( (3,6), (1,1) ):
wx.MessageBox("""\
wxGridBagSizer will not allow items to be in the same cell as
another item, so this operation will fail. You will also get an assert
when compiled in debug mode.""",
"Warning", wx.OK | wx.ICON_INFORMATION)
try:
if self.gbs.SetItemPosition(btn, (3,6)):
self.lastPos = curPos
btn.SetLabel("Move it back")
except wx.PyAssertionError:
pass
self.gbs.Layout()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
win = TestFrame()
frame.otherWin = win
win.Show(True)
#----------------------------------------------------------------------
overview = """<html><body>
<h2><center>wxGridBagSizer</center></h2>
The wxGridBagSizer is more or less a port of the the RowColSizer (that
has been in the wxPython.lib package for quite some time) to C++. It
allows items to be placed at specific layout grid cells, and items can
span across more than one row or column.
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])])

View File

@@ -96,7 +96,7 @@ class MegaTable(wxPyGridTableBase):
grid.SetColSize(col, renderer.colSize)
if renderer.rowSize:
grid.SetDefaultRowSize(renderer.rowSize)
attr.SetReadOnly(true)
attr.SetReadOnly(True)
attr.SetRenderer(renderer)
grid.SetColAttr(col, attr)
col += 1

View File

@@ -7,7 +7,7 @@ from joystick_wdr import *
class JoystickTestPanel(wxPanel):
def __init__(self, parent, id,
pos = wxPyDefaultPosition, size = wxPyDefaultSize,
pos = wxDefaultPosition, size = wxDefaultSize,
style = wxTAB_TRAVERSAL ):
wxPanel.__init__(self, parent, id, pos, size, style)

View File

@@ -15,7 +15,7 @@ class TestPanel(wxPanel):
EVT_BUTTON(self, b2.GetId(), self.ShowMDISashDemo)
box = wxBoxSizer(wxVERTICAL)
box.Add(20, 30)
box.Add((20, 30))
box.Add(b1, 0, wxALIGN_CENTER|wxALL, 15)
box.Add(b2, 0, wxALIGN_CENTER|wxALL, 15)
self.SetAutoLayout(True)

View File

@@ -10,7 +10,7 @@ from Main import opj
class MimeTypesTestPanel(wxPanel):
def __init__(self, parent, id,
pos = wxPyDefaultPosition, size = wxPyDefaultSize,
pos = wxDefaultPosition, size = wxDefaultSize,
style = wxTAB_TRAVERSAL ):
wxPanel.__init__(self, parent, id, pos, size, style)
@@ -102,7 +102,7 @@ class MimeTypesTestPanel(wxPanel):
# WDR: methods for MimeTypesTestPanel
def GetListbox(self):
return wxPyTypeCast( self.FindWindowById(ID_LISTBOX), "wxListBox" )
return self.FindWindowById(ID_LISTBOX)
def GetIconIndexTxt(self):
return self.FindWindowById(ID_ICON_INDEX_TXT)

View File

@@ -4,10 +4,7 @@ from wxPython.ogl import *
import images
#----------------------------------------------------------------------
# This creates some pens and brushes that the OGL library uses.
wxOGLInitialize()
##wxTrap()
#----------------------------------------------------------------------
@@ -83,6 +80,7 @@ class DividedShape(wxDividedShape):
def OnSizingEndDragLeft(self, pt, x, y, keys, attch):
print "***", self
self.base_OnSizingEndDragLeft(pt, x, y, keys, attch)
self.SetRegionSizes()
self.ReformatRegions()
@@ -257,6 +255,11 @@ class TestWindow(wxShapeCanvas):
#----------------------------------------------------------------------
def runTest(frame, nb, log):
# This creates some pens and brushes that the OGL library uses.
# It should be called after the app object has been created, but
# before OGL is used.
wxOGLInitialize()
win = TestWindow(nb, log, frame)
return win

View File

@@ -67,19 +67,19 @@ class MyCanvas(wxScrolledWindow):
def DoDrawing(self, dc, printing=False):
dc.BeginDrawing()
dc.SetPen(wxPen('RED'))
dc.DrawRectangle(5, 5, 50, 50)
dc.DrawRectangle((5, 5), (50, 50))
dc.SetBrush(wxLIGHT_GREY_BRUSH)
dc.SetPen(wxPen('BLUE', 4))
dc.DrawRectangle(15, 15, 50, 50)
dc.DrawRectangle((15, 15), (50, 50))
dc.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL))
dc.SetTextForeground(wxColour(0xFF, 0x20, 0xFF))
te = dc.GetTextExtent("Hello World")
dc.DrawText("Hello World", 60, 65)
dc.DrawText("Hello World", (60, 65))
dc.SetPen(wxPen('VIOLET', 4))
dc.DrawLine(5, 65+te[1], 60+te[0], 65+te[1])
dc.DrawLine((5, 65+te[1]), (60+te[0], 65+te[1]))
lst = [(100,110), (150,110), (150,160), (100,160)]
dc.DrawLines(lst, -60)
@@ -88,9 +88,9 @@ class MyCanvas(wxScrolledWindow):
dc.SetPen(wxGREEN_PEN)
dc.DrawSpline(lst+[(100,100)])
dc.DrawBitmap(self.bmp, 200, 20, True)
dc.DrawBitmap(self.bmp, (200, 20), True)
dc.SetTextForeground(wxColour(0, 0xFF, 0x80))
dc.DrawText("a bitmap", 200, 85)
dc.DrawText("a bitmap", (200, 85))
## dc.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL))
## dc.SetTextForeground("BLACK")
@@ -101,15 +101,15 @@ class MyCanvas(wxScrolledWindow):
dc.SetFont(font)
dc.SetTextForeground(wxBLACK)
for a in range(0, 360, 45):
dc.DrawRotatedText("Rotated text...", 300, 300, a)
dc.DrawRotatedText("Rotated text...", (300, 300), a)
dc.SetPen(wxTRANSPARENT_PEN)
dc.SetBrush(wxBLUE_BRUSH)
dc.DrawRectangle(50,500,50,50)
dc.DrawRectangle(100,500,50,50)
dc.DrawRectangle((50,500), (50,50))
dc.DrawRectangle((100,500), (50,50))
dc.SetPen(wxPen('RED'))
dc.DrawEllipticArc(200, 500, 50, 75, 0, 90)
dc.DrawEllipticArc((200, 500), (50, 75), 0, 90)
if not printing:
# This has troubles when used on a print preview in wxGTK,
@@ -123,18 +123,18 @@ class MyCanvas(wxScrolledWindow):
pen.SetDashes([1,2])
pen.SetColour("RED")
dc.SetPen(pen)
dc.DrawLine(300, y, 400, y)
dc.DrawLine((300, y), (400, y))
y = y + 10
dc.SetBrush(wxTRANSPARENT_BRUSH)
dc.SetPen(wxPen(wxColour(0xFF, 0x20, 0xFF), 1, wxSOLID))
dc.DrawRectangle(450, 50, 100, 100)
dc.DrawRectangle((450, 50), (100, 100))
old_pen = dc.GetPen()
new_pen = wxPen("BLACK", 5)
dc.SetPen(new_pen)
dc.DrawRectangle(470, 70, 60, 60)
dc.DrawRectangle((470, 70), (60, 60))
dc.SetPen(old_pen)
dc.DrawRectangle(490, 90, 20, 20)
dc.DrawRectangle((490, 90), (20, 20))
self.DrawSavedLines(dc)
dc.EndDrawing()
@@ -144,7 +144,7 @@ class MyCanvas(wxScrolledWindow):
dc.SetPen(wxPen('MEDIUM FOREST GREEN', 4))
for line in self.lines:
for coords in line:
apply(dc.DrawLine, coords)
dc.DrawLine(*coords)
def SetXY(self, event):
@@ -177,9 +177,9 @@ class MyCanvas(wxScrolledWindow):
dc.BeginDrawing()
dc.SetPen(wxPen('MEDIUM FOREST GREEN', 4))
coords = (self.x, self.y) + self.ConvertEventCoords(event)
coords = ((self.x, self.y), self.ConvertEventCoords(event))
self.curLine.append(coords)
apply(dc.DrawLine, coords)
dc.DrawLine( *coords)
self.SetXY(event)
dc.EndDrawing()

View File

@@ -11,7 +11,7 @@ resourceText = r'''<?xml version="1.0"?>
<object class="MyBluePanel" name="MyPanel">
<size>200,100</size>
<object class="wxStaticText" name="label1" subclass="wxPython.wx.wxPreStaticText">
<object class="wxStaticText" name="label1">
<label>This blue panel is a class derived from wxPanel,\nand is loaded by a custom wxXmlResourceHandler.</label>
<pos>10,10</pos>
</object>
@@ -39,7 +39,7 @@ class MyBluePanel(wxPanel):
class PreMyBluePanel(wxPanel):
def __init__(self):
p = wxPrePanel()
self.this = p.this
self.PostCreate(p)
def Create(self, parent, id, pos, size, style, name):
wxPanel.Create(self, parent, id, pos, size, style, name)

View File

@@ -8,11 +8,12 @@ resourceText = r'''<?xml version="1.0"?>
<resource>
<!-- Notice that the class IS a standard wx class, and a custom
subclass is specified as "moduleName.ClassName" -->
subclass is specified as "moduleName.ClassName" Try changing
the classname to one that does not exist and see what happens -->
<object class="wxPanel" subclass="wxXmlResourceSubclass.MyBluePanel" name="MyPanel">
<size>200,100</size>
<object class="wxStaticText" name="label1" subclass="wxPython.wx.wxPreStaticText">
<object class="wxStaticText" name="label1">
<label>This blue panel is a class derived from wxPanel
and is loaded by a using a subclass attribute of the object tag.</label>
<pos>10,10</pos>
@@ -25,11 +26,8 @@ and is loaded by a using a subclass attribute of the object tag.</label>
class MyBluePanel(wxPanel):
def __init__(self):
#print "MyBluePanel.__init__"
p = wxPrePanel()
self.this = p.this
self.thisown = p.thisown
self._setOORInfo(self)
self.PostCreate(p)
EVT_WINDOW_CREATE(self, self.OnCreate)