getting mucked up; when the user quits, we get errors about being
unable to call del on a 'None' object.
"""
+import sys
import cPickle, os.path
from wxPython.wx import *
toolSizer = wxGridSizer(0, 2, 5, 5)
toolSizer.Add(self.selectIcon)
- toolSizer.Add(0, 0) # Gap to make tool icons line up nicely.
+ toolSizer.Add((0, 0)) # Gap to make tool icons line up nicely.
toolSizer.Add(self.lineIcon)
toolSizer.Add(self.rectIcon)
toolSizer.Add(self.ellipseIcon)
margin = wxTOP | wxLEFT | wxRIGHT | wxALIGN_CENTRE
self.toolPalette.Add(toolSizer, 0, margin, 5)
- self.toolPalette.Add(0, 0, 0, margin, 5) # Spacer.
+ self.toolPalette.Add((0, 0), 0, margin, 5) # Spacer.
self.toolPalette.Add(self.optionIndicator, 0, margin, 5)
self.toolPalette.Add(optionSizer, 0, margin, 5)
# Make the tool palette icons respond when the user clicks on them.
- EVT_LEFT_DOWN(self.selectIcon, self.onToolIconClick)
- EVT_LEFT_DOWN(self.lineIcon, self.onToolIconClick)
- EVT_LEFT_DOWN(self.rectIcon, self.onToolIconClick)
- EVT_LEFT_DOWN(self.ellipseIcon, self.onToolIconClick)
- EVT_LEFT_DOWN(self.textIcon, self.onToolIconClick)
- EVT_LEFT_DOWN(self.penOptIcon, self.onPenOptionIconClick)
- EVT_LEFT_DOWN(self.fillOptIcon, self.onFillOptionIconClick)
- EVT_LEFT_DOWN(self.lineOptIcon, self.onLineOptionIconClick)
+ EVT_BUTTON(self.selectIcon, -1, self.onToolIconClick)
+ EVT_BUTTON(self.lineIcon, -1, self.onToolIconClick)
+ EVT_BUTTON(self.rectIcon, -1, self.onToolIconClick)
+ EVT_BUTTON(self.ellipseIcon, -1, self.onToolIconClick)
+ EVT_BUTTON(self.textIcon, -1, self.onToolIconClick)
+ EVT_BUTTON(self.penOptIcon, -1, self.onPenOptionIconClick)
+ EVT_BUTTON(self.fillOptIcon, -1, self.onFillOptionIconClick)
+ EVT_BUTTON(self.lineOptIcon, -1, self.onLineOptionIconClick)
# Setup the main drawing area.
def onToolIconClick(self, event):
""" Respond to the user clicking on one of our tool icons.
"""
- iconID = wxPyTypeCast(event.GetEventObject(), "wxWindow").GetId()
+ iconID = event.GetEventObject().GetId()
+ print iconID
if iconID == id_SELECT: self.doChooseSelectTool()
elif iconID == id_LINE: self.doChooseLineTool()
elif iconID == id_RECT: self.doChooseRectTool()
elif iconID == id_ELLIPSE: self.doChooseEllipseTool()
elif iconID == id_TEXT: self.doChooseTextTool()
- else: wxBell()
+ else: wxBell(); print "1"
def onPenOptionIconClick(self, event):
selecting = False
dashedLine = True
else:
- wxBell()
+ wxBell(); print "2"
return
if event.LeftDown():
self.drawPanel.Refresh()
self._adjustMenus()
else:
- wxBell()
+ wxBell(); print "3"
def onRightClick(self, event):
btnOK = wxButton(panel, wxID_OK, "OK")
panelSizer.Add(imageSizer, 0, wxALIGN_CENTRE)
- panelSizer.Add(10, 10) # Spacer.
+ panelSizer.Add((10, 10)) # Spacer.
panelSizer.Add(lab2, 0, wxALIGN_CENTRE)
- panelSizer.Add(10, 10) # Spacer.
+ panelSizer.Add((10, 10)) # Spacer.
panelSizer.Add(lab3, 0, wxALIGN_CENTRE)
panelSizer.Add(lab4, 0, wxALIGN_CENTRE)
- panelSizer.Add(10, 10) # Spacer.
+ panelSizer.Add((10, 10)) # Spacer.
panelSizer.Add(lab5, 0, wxALIGN_CENTRE)
- panelSizer.Add(10, 10) # Spacer.
+ panelSizer.Add((10, 10)) # Spacer.
panelSizer.Add(btnOK, 0, wxALL | wxALIGN_CENTRE, 5)
panel.SetAutoLayout(True)
"""
if obj.getType() == obj_TEXT:
# Not allowed to resize text objects -- they're sized to fit text.
- wxBell()
+ wxBell(); print "4"
return
self._saveUndoInfo()
elif id == id_LINESIZE_4: self._setLineSize(4)
elif id == id_LINESIZE_5: self._setLineSize(5)
else:
- wxBell()
+ wxBell(); print "5"
return
self.optionIndicator.setLineSize(self.lineSize)
#----------------------------------------------------------------------------
-class ToolPaletteIcon(wxStaticBitmap):
+class ToolPaletteIcon(wxBitmapButton):
""" An icon appearing in the tool palette area of our sketching window.
- Note that this is actually implemented as a wxStaticBitmap rather
+ Note that this is actually implemented as a wxBitmap rather
than as a wxIcon. wxIcon has a very specific meaning, and isn't
appropriate for this more general use.
"""
The icon name is used to get the appropriate bitmap for this icon.
"""
bmp = wxBitmap("images/" + iconName + "Icon.bmp", wxBITMAP_TYPE_BMP)
- wxStaticBitmap.__init__(self, parent, iconID, bmp, wxDefaultPosition,
+ wxBitmapButton.__init__(self, parent, iconID, bmp, wxDefaultPosition,
wxSize(bmp.GetWidth(), bmp.GetHeight()))
self.SetToolTip(wxToolTip(toolTip))
bmp = wxBitmap("images/" + self.iconName + "IconSel.bmp",
wxBITMAP_TYPE_BMP)
- self.SetBitmap(bmp)
+ self.SetBitmapLabel(bmp)
self.isSelected = True
bmp = wxBitmap("images/" + self.iconName + "Icon.bmp",
wxBITMAP_TYPE_BMP)
- self.SetBitmap(bmp)
+ self.SetBitmapLabel(bmp)
self.isSelected = False
#----------------------------------------------------------------------------
comboSizer = wxBoxSizer(wxHORIZONTAL)
comboSizer.Add(fontLabel, 0, gap | wxALIGN_CENTRE_VERTICAL, 5)
comboSizer.Add(self.fontCombo, 0, gap, 5)
- comboSizer.Add(5, 5) # Spacer.
+ comboSizer.Add((5, 5)) # Spacer.
comboSizer.Add(sizeLabel, 0, gap | wxALIGN_CENTRE_VERTICAL, 5)
comboSizer.Add(self.sizeCombo, 0, gap, 5)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(self.textCtrl, 1, gap | wxEXPAND, 5)
- sizer.Add(10, 10) # Spacer.
+ sizer.Add((10, 10)) # Spacer.
sizer.Add(comboSizer, 0, gap | wxALIGN_CENTRE, 5)
sizer.Add(styleSizer, 0, gap | wxALIGN_CENTRE, 5)
- sizer.Add(10, 10) # Spacer.
+ sizer.Add((10, 10)) # Spacer.
sizer.Add(btnSizer, 0, gap | wxALIGN_CENTRE, 5)
self.SetAutoLayout(True)
def Validate(self, win):
""" Validate the contents of the given text control.
"""
- textCtrl = wxPyTypeCast(self.GetWindow(), "wxTextCtrl")
+ textCtrl = self.GetWindow()
text = textCtrl.GetValue()
if len(text) == 0: