text = wx.StaticText(self, -1, "48x48")
box.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
- fgs.AddSizer(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ fgs.Add(box, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(fgs, 0, wx.ALL, 5)
self.SetSizer(sizer)
try:
bmp = wx.Bitmap("nosuchfile.bmp", wx.BITMAP_TYPE_BMP)
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
except wx.PyAssertionError:
self.log.write("Caught wx.PyAssertionError! I will fix the problem.\n")
bmp = images.getTest2Bitmap()
mask = wx.MaskColour(bmp, wx.BLUE)
else:
bmp = images.getTest2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b = wx.BitmapButton(self, 30, bmp, (20, 20),
while x < sz.width:
y = -dy
while y < sz.height:
- dc.DrawBitmap(self.bg_bmp, (x, y))
+ dc.DrawBitmap(self.bg_bmp, x, y)
y = y + h
x = x + w
clr = colours[line]
y = (line+1) * self.lineHeight + 2
- # Updated for 2.5 - now takes tuple for pos
- dc.DrawText(clr, (self.cellWidth, y))
+ dc.DrawText(clr, self.cellWidth, y)
brush = wx.Brush(clr, wx.SOLID)
dc.SetBrush(brush)
- dc.DrawRectangle((12 * self.cellWidth, y),
- (6 * self.cellWidth, self.textHeight))
+ dc.DrawRectangle(12 * self.cellWidth, y,
+ 6 * self.cellWidth, self.textHeight)
dc.EndDrawing()
dc = wx.ClientDC(self.win)
dc.SetPen(wx.Pen("RED"))
dc.SetBrush(wx.Brush("RED"))
- dc.DrawCircle(evt.GetPosition(), 4)
+ pos = evt.GetPosition()
+ dc.DrawCircle(pos.x, pos.y, 4)
#----------------------------------------------------------------------
dc = wx.ClientDC(self)
dc.BeginDrawing()
dc.SetPen(wx.Pen(wx.BLUE, 3))
- coords = ((self.x, self.y), event.GetPositionTuple())
+ coords = (self.x, self.y) + event.GetPositionTuple()
self.curLine.append(coords)
dc.DrawLine(*coords)
self.x, self.y = event.GetPositionTuple()
memDC = wx.MemoryDC()
memDC.SelectObject(self.bmp)
- dc.Blit((self.pos[0], self.pos[1]),
- (self.bmp.GetWidth(), self.bmp.GetHeight()),
- memDC, (0, 0), op, True)
+ dc.Blit(self.pos[0], self.pos[1],
+ self.bmp.GetWidth(), self.bmp.GetHeight(),
+ memDC, 0, 0, op, True)
return True
else:
dc.Clear()
dc.SetTextForeground(wx.RED)
dc.SetFont(font)
- dc.DrawText(text, (0, 0))
+ dc.DrawText(text, 0, 0)
dc.SelectObject(wx.NullBitmap)
- mask = wx.MaskColour(bmp, bg_colour)
+ mask = wx.Mask(bmp, bg_colour)
bmp.SetMask(mask)
shape = DragShape(bmp)
shape.pos = (5, 100)
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
self.fbbh = filebrowse.FileBrowseButtonWithHistory(
self, -1, (20, 50), (450, -1), changeCallback = self.fbbhCallback
)
-
+
self.dbb = filebrowse.DirBrowseButton(
self, -1, (20, 80), (450, -1), changeCallback = self.dbbCallback
)
- self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'file', 'names', 'here'])
+ self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'filenames', 'here'])
def fbbCallback(self, evt):
value = evt.GetString()
self.log.write('FileBrowseButtonWithHistory: %s\n' % value)
history = self.fbbh.GetHistory()
- history.append(value)
- self.fbbh.SetHistory(history)
+ if value not in history:
+ history.append(value)
+ self.fbbh.SetHistory(history)
+ self.fbbh.GetHistoryControl().SetStringSelection(value)
def dbbCallback(self, evt):
overview = ""
else:
- from wxPython.lib import floatcanvas
- import wxPython.lib.colourdb
+ from wx.lib import floatcanvas
+ import wx.lib.colourdb
ID_ABOUT_MENU = wx.NewId()
ID_EXIT_MENU = wx.NewId()
def OnInit(self):
global colors
- wxPython.lib.colourdb.updateColourDB()
- colors = wxPython.lib.colourdb.getColourList()
+ wx.lib.colourdb.updateColourDB()
+ colors = wx.lib.colourdb.getColourList()
frame = DrawFrame(None, -1, "FloatCanvas Demo App",
wx.DefaultPosition, (700,700))
this demo with the rest.
"""
global colors
- wxPython.lib.colourdb.updateColourDB()
- colors = wxPython.lib.colourdb.getColourList()
+ wx.lib.colourdb.updateColourDB()
+ colors = wx.lib.colourdb.getColourList()
win = DrawFrame(None, -1, "FloatCanvas Drawing Window",
wx.DefaultPosition, (500,500))
b = buttons.GenBitmapButton(self, -1, None)
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
bmp = images.getBulb1Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapLabel(bmp)
bmp = images.getBulb2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapSelected(bmp)
b.SetBestSize()
b = buttons.GenBitmapToggleButton(self, -1, None)
self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b)
bmp = images.getBulb1Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapLabel(bmp)
bmp = images.getBulb2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapSelected(bmp)
b.SetToggle(True)
b = buttons.GenBitmapTextButton(self, -1, None, "Bitmapped Text", size = (200, 45))
self.Bind(wx.EVT_BUTTON, self.OnButton, b)
bmp = images.getBulb1Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapLabel(bmp)
bmp = images.getBulb2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
b.SetBitmapSelected(bmp)
b.SetUseFocusIndicator(False)
for ch in text:
dc.SetTextForeground(random.choice(colors))
- dc.DrawText(ch, (x, y))
+ dc.DrawText(ch, x, y)
w, h = dc.GetTextExtent(ch)
x = x + w
if x > rect.right - 5:
dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
dc.DrawRectangleRect(rect)
- #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
# copy the image but only to the size of the grid cell
width, height = bmp.GetWidth(), bmp.GetHeight()
if height > rect.height-2:
height = rect.height-2
- dc.Blit((rect.x+1, rect.y+1), (width, height),
+ dc.Blit(rect.x+1, rect.y+1, width, height,
image,
- (0, 0), wx.COPY, True)
+ 0, 0, wx.COPY, True)
class MegaFontRenderer(Grid.PyGridCellRenderer):
dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
dc.DrawRectangleRect(rect)
- #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
-
text = self.table.GetValue(row, col)
dc.SetBackgroundMode(wx.SOLID)
dc.SetTextForeground(self.color)
dc.SetFont(self.font)
- dc.DrawText(text, (rect.x+1, rect.y+1))
+ dc.DrawText(text, rect.x+1, rect.y+1)
# Okay, now for the advanced class :)
# Let's add three dots "..."
if width > rect.width-2:
width, height = dc.GetTextExtent("...")
x = rect.x+1 + rect.width-2 - width
- dc.DrawRectangle((x, rect.y+1), (width+1, height))
- dc.DrawText("...", (x, rect.y+1))
+ dc.DrawRectangle(x, rect.y+1, width+1, height)
+ dc.DrawText("...", x, rect.y+1)
dc.DestroyClippingRegion()
dc.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, True))
dc.DrawText("Bitmap alpha blending (on wxMSW and wxMac only)",
- (25,25))
-
+ 25,25)
+
bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
if "__WXGTK__" in wx.PlatformInfo:
# try to make up for it a bit...
bmp.SetMaskColour("black")
- dc.DrawBitmap(bmp, (25,100), True)
+ dc.DrawBitmap(bmp, 25,100, True)
dc.SetFont(self.GetFont())
y = 75
for line in range(10):
y += dc.GetCharHeight() + 5
- dc.DrawText(msg, (200, y))
- dc.DrawBitmap(bmp, (250,100), True)
+ dc.DrawText(msg, 200, y)
+ dc.DrawBitmap(bmp, 250,100, True)
grid.Add( self.target_ctl, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
outer_box = wx.BoxSizer( wx.VERTICAL )
- outer_box.AddSizer( grid, 0, wx.ALIGN_CENTRE|wx.ALL, 20 )
+ outer_box.Add( grid, 0, wx.ALIGN_CENTRE|wx.ALL, 20 )
panel.SetAutoLayout( True )
panel.SetSizer( outer_box )
# Restrict our drawing activities to the square defined
# above.
- dc.SetClippingRegion((xorigin, yorigin), (edgeSize, edgeSize))
+ dc.SetClippingRegion(xorigin, yorigin, edgeSize, edgeSize)
# Optimize drawing a bit (for Win)
dc.BeginDrawing()
dc.SetBrush(wx.Brush(wx.Colour(251, 252, 237)))
- dc.DrawRectangle((xorigin, yorigin), (edgeSize, edgeSize))
+ dc.DrawRectangle(xorigin, yorigin, edgeSize, edgeSize)
dc.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH))
- dc.DrawLine((xorigin, yorigin + center), (xorigin + edgeSize, yorigin + center))
- dc.DrawLine((xorigin + center, yorigin), (xorigin + center, yorigin + edgeSize))
+ dc.DrawLine(xorigin, yorigin + center, xorigin + edgeSize, yorigin + center)
+ dc.DrawLine(xorigin + center, yorigin, xorigin + center, yorigin + edgeSize)
if self.stick:
# Get the joystick position as a float
# our 'raster'.
dc.SetBrush(wx.Brush(wx.WHITE))
- dc.DrawCircle((xcenter, ycenter), diameter/2)
+ dc.DrawCircle(xcenter, ycenter, diameter/2)
dc.SetBrush(wx.Brush(wx.BLACK))
- dc.DrawCircle((xcenter, ycenter), 10)
+ dc.DrawCircle(xcenter, ycenter, 10)
# fancy decorations
dc.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH))
- dc.DrawLine((xorigin, ycenter), (xorigin + diameter, ycenter))
- dc.DrawLine((xcenter, yorigin), (xcenter, yorigin + diameter))
+ dc.DrawLine(xorigin, ycenter, xorigin + diameter, ycenter)
+ dc.DrawLine(xcenter, yorigin, xcenter, yorigin + diameter)
if self.stick:
if self.avail:
# Draw the line
dc.SetPen(wx.Pen(wx.BLUE, 2))
- dc.DrawLine((xcenter, ycenter), (nx, ny))
+ dc.DrawLine(xcenter, ycenter, nx, ny)
# And a little thing to show the endpoint
dc.SetBrush(wx.Brush(wx.BLUE))
- dc.DrawCircle((nx, ny), 8)
+ dc.DrawCircle(nx, ny, 8)
# Turn off drawing optimization
dc.EndDrawing()
else:
dc.SetBrush(wx.Brush(wx.BLACK))
- dc.DrawCircle((center, center), bw/2)
+ dc.DrawCircle(center, center, bw/2)
txt = str(self.number)
# functions. The pseudo-shadow gives the text contrast
# regardless of whether the bar is under it or not.
dc.SetTextForeground(wx.WHITE)
- dc.DrawText(txt, (tx, ty))
+ dc.DrawText(txt, tx, ty)
# Turn off drawing optimization
dc.EndDrawing()
# functions. The pseudo-shadow gives the text contrast
# regardless of whether the bar is under it or not.
dc.SetTextForeground(wx.BLACK)
- dc.DrawText(txt, (tx, ty))
+ dc.DrawText(txt, tx, ty)
dc.SetTextForeground('white')
- dc.DrawText(txt, (tx-1, ty-1))
+ dc.DrawText(txt, tx-1, ty-1)
#----------------------------------------------------------------------------
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
]),
# need libs not coming with the demo
- ('Objects using an external library', [
+ ('Samples using an external library', [
'GLCanvas',
]),
# Now we'll create a mask in a bit of an easier way, by picking a
# colour in the image that is to be the transparent colour.
self.bmp_withcolourmask = images.getTestStar2Bitmap()
- mask = wx.MaskColour(self.bmp_withcolourmask, wx.WHITE)
+ mask = wx.Mask(self.bmp_withcolourmask, wx.WHITE)
self.bmp_withcolourmask.SetMask(mask)
self.SetScrollbars(20, 20, 700/20, 460/20)
# make an interesting background...
dc.SetPen(wx.MEDIUM_GREY_PEN)
for i in range(100):
- dc.DrawLine((0,i*10), (i*10,0))
+ dc.DrawLine(0,i*10, i*10,0)
# draw raw image, mask, and masked images
- dc.DrawText('original image', (0,0))
- dc.DrawBitmap(self.bmp_nomask, (0,20), 0)
- dc.DrawText('with colour mask', (0,100))
- dc.DrawBitmap(self.bmp_withcolourmask, (0,120), 1)
- dc.DrawText('the mask image', (0,200))
- dc.DrawBitmap(self.bmp_themask, (0,220), 0)
- dc.DrawText('masked image', (0,300))
- dc.DrawBitmap(self.bmp_withmask, (0,320), 1)
+ dc.DrawText('original image', 0,0)
+ dc.DrawBitmap(self.bmp_nomask, 0,20, 0)
+ dc.DrawText('with colour mask', 0,100)
+ dc.DrawBitmap(self.bmp_withcolourmask, 0,120, 1)
+ dc.DrawText('the mask image', 0,200)
+ dc.DrawBitmap(self.bmp_themask, 0,220, 0)
+ dc.DrawText('masked image', 0,300)
+ dc.DrawBitmap(self.bmp_withmask, 0,320, 1)
cx,cy = self.bmp_themask.GetWidth(), self.bmp_themask.GetHeight()
for text, code in logicList:
x,y = 120+150*(i%4), 20+100*(i/4)
- dc.DrawText(text, (x, y-20))
+ dc.DrawText(text, x, y-20)
mdc.SelectObject(self.bmp_withcolourmask)
- dc.Blit((x,y), (cx,cy), mdc, (0,0), code, True)
+ dc.Blit(x,y, cx,cy, mdc, 0,0, code, True)
i = i + 1
def runTest(frame, nb, log):
dlg = wx.MessageDialog(frame, 'Hello from Python and wxPython!',
- 'A Message Box', wx.OK | wx.ICON_INFORMATION)
- #wxYES_NO | wxNO_DEFAULT | wxCANCEL | wxICON_INFORMATION)
+ 'A Message Box',
+ wx.OK | wx.ICON_INFORMATION)
+ #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
overview = """\
-This class represents a dialog that shows a single or multi-line message, with a
-choice of OK, Yes, No and Cancel buttons.
-
-Additionally, various style flags can determine whether an icon is displayed,
-and, if so, what kind.
-
-The dialog can be modal or not; of modal, the user's response is in the return
-code of ShowModal(). If not, the response can be taken from GetReturnCode() (inherited
-from the wx.Dialog). If not modal and the return code is required, it
-must be retrieved before the dialog is destroyed.
+<html><body>
+<h2>wx.MessageDialog</h2>
+
+This class represents a dialog that shows a single or multi-line
+message, with a choice of OK, Yes, No and Cancel buttons.
+Additionally, various style flags can determine whether an icon is
+displayed, and, if so, what kind. The return value of ShowModal
+indicates which button was pressed.
"""
)
bmp = images.getTest2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
s = ogl.BitmapShape()
#-------------------------------------------
self.canvas.DoDrawing(dc, True)
- dc.DrawText("Page: %d" % page, (marginX/2, maxY-marginY))
+ dc.DrawText("Page: %d" % page, marginX/2, maxY-marginY)
return True
self.group1_ctrls.append((radio3, text3))
for radio, text in self.group1_ctrls:
- grid1.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
- grid1.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
+ grid1.Add( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
+ grid1.Add( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
- box1.AddSizer( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
- vs.AddSizer( box1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
+ box1.Add( grid1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
+ vs.Add( box1, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
box2_title = wx.StaticBox( panel, -1, "Group 2" )
box2 = wx.StaticBoxSizer( box2_title, wx.VERTICAL )
self.group2_ctrls.append((radio6, text6))
for radio, text in self.group2_ctrls:
- grid2.AddWindow( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
- grid2.AddWindow( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
+ grid2.Add( radio, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
+ grid2.Add( text, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
- box2.AddSizer( grid2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
- vs.AddSizer( box2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
+ box2.Add( grid2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
+ vs.Add( box2, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
panel.SetSizer( vs )
vs.Fit( panel )
vbox2.Add((20, 10))
hbox.Add(vbox2)
- vbox.AddSizer(hbox, 0)
+ vbox.Add(hbox, 0)
self.SetSizer(vbox)
self.SetAutoLayout(1)
self.SetupScrolling()
self.SetBackgroundColour("WHITE")
self.SetCursor(wx.StockCursor(wx.CURSOR_PENCIL))
bmp = images.getTest2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
self.bmp = bmp
def DoDrawing(self, dc, printing=False):
dc.BeginDrawing()
dc.SetPen(wx.Pen('RED'))
- dc.DrawRectangle((5, 5), (50, 50))
+ dc.DrawRectangle(5, 5, 50, 50)
dc.SetBrush(wx.LIGHT_GREY_BRUSH)
dc.SetPen(wx.Pen('BLUE', 4))
- dc.DrawRectangle((15, 15), (50, 50))
+ dc.DrawRectangle(15, 15, 50, 50)
dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL))
dc.SetTextForeground(wx.Colour(0xFF, 0x20, 0xFF))
te = dc.GetTextExtent("Hello World")
- dc.DrawText("Hello World", (60, 65))
+ dc.DrawText("Hello World", 60, 65)
dc.SetPen(wx.Pen('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)
dc.SetPen(wx.GREEN_PEN)
dc.DrawSpline(lst+[(100,100)])
- dc.DrawBitmap(self.bmp, (200, 20), True)
+ dc.DrawBitmap(self.bmp, 200, 20, True)
dc.SetTextForeground(wx.Colour(0, 0xFF, 0x80))
- dc.DrawText("a bitmap", (200, 85))
+ dc.DrawText("a bitmap", 200, 85)
## dc.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL))
## dc.SetTextForeground("BLACK")
-## dc.DrawText("TEST this STRING", (10, 200))
+## dc.DrawText("TEST this STRING", 10, 200)
## print dc.GetFullTextExtent("TEST this STRING")
font = wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL)
dc.SetTextForeground(wx.BLACK)
for a in range(0, 360, 45):
- dc.DrawRotatedText("Rotated text...", (300, 300), a)
+ dc.DrawRotatedText("Rotated text...", 300, 300, a)
dc.SetPen(wx.TRANSPARENT_PEN)
dc.SetBrush(wx.BLUE_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(wx.Pen('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,
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(wx.TRANSPARENT_BRUSH)
dc.SetPen(wx.Pen(wx.Colour(0xFF, 0x20, 0xFF), 1, wx.SOLID))
- dc.DrawRectangle((450, 50), (100, 100))
+ dc.DrawRectangle(450,50, 100,100)
old_pen = dc.GetPen()
new_pen = wx.Pen("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()
dc.BeginDrawing()
dc.SetPen(wx.Pen('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()
self.SetWindowShape()
dc = wx.ClientDC(self)
- dc.DrawBitmap(self.bmp, (0,0), True)
+ dc.DrawBitmap(self.bmp, 0,0, True)
def SetWindowShape(self, *evt):
def OnPaint(self, evt):
dc = wx.PaintDC(self)
- dc.DrawBitmap(self.bmp, (0,0), True)
+ dc.DrawBitmap(self.bmp, 0,0, True)
def OnExit(self, evt):
self.Close()
dc = wx.PaintDC(self)
w,h = dc.GetTextExtent(self.text)
dc.Clear()
- dc.DrawText(self.text, ((sz.width-w)/2, (sz.height-h)/2))
+ dc.DrawText(self.text, (sz.width-w)/2, (sz.height-h)/2)
def OnSize(self, evt):
self.Refresh()
dc.SetPen(pen)
dc.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
- dc.DrawRectangle((rect.x, rect.y), (rect.width+1, rect.height+1))
+ dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1)
dc.SetTextForeground("BLACK")
dc.SetBackgroundMode(wx.TRANSPARENT)
tw, th = dc.GetTextExtent(text)
x = 5
y = rect.y + max(0, (rect.height - th) / 2)
- dc.DrawText(text, (x, y))
+ dc.DrawText(text, x, y)
wx.StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15))
bmp = images.getTest2Bitmap()
- mask = wx.MaskColour(bmp, wx.BLUE)
+ mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
wx.StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight()))
import wx
+
+USE_GENERIC = 0
+if USE_GENERIC:
+ from wx.lib.stattext import GenStaticText as StaticText
+else:
+ StaticText = wx.StaticText
+
+
#---------------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
- wx.StaticText(self, -1, "This is an example of static text", (20, 10))
- wx.StaticText(self, -1, "using the wx.StaticText Control.", (20, 30))
+ StaticText(self, -1, "This is an example of static text", (20, 10))
+ StaticText(self, -1, "using the wx.StaticText Control.", (20, 30))
- wx.StaticText(
+ StaticText(
self, -1, "Is this yellow?", (20, 70), (90, -1)
).SetBackgroundColour('Yellow')
- wx.StaticText(
+ StaticText(
self, -1, "align center", (120, 70), (90, -1), wx.ALIGN_CENTER
).SetBackgroundColour('Yellow')
- wx.StaticText(
+ StaticText(
self, -1, "align right", (220, 70), (90, -1), wx.ALIGN_RIGHT
).SetBackgroundColour('Yellow')
str = "This is a different font."
- text = wx.StaticText(self, -1, str, (20, 100))
+ text = StaticText(self, -1, str, (20, 100))
font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL)
text.SetFont(font)
text.SetSize(text.GetBestSize())
- wx.StaticText(self, -1, "Multi-line wx.StaticText\nline 2\nline 3\n\nafter empty line", (20,150))
- wx.StaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wx.ALIGN_RIGHT)
+ StaticText(self, -1, "Multi-line wx.StaticText\nline 2\nline 3\n\nafter empty line", (20,150))
+ StaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wx.ALIGN_RIGHT)
#---------------------------------------------------------------------------
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.Clear()
dc.SetPen(wx.Pen(wx.BLACK, 3, wx.SOLID))
- dc.DrawLine((self.linePos, 0), (self.linePos, size.height-10))
+ dc.DrawLine(self.linePos, 0, self.linePos, size.height-10)
bh = ypos = self.barHeight
for x in range(len(self.values)):
label, val = self.values[x]
- dc.DrawText(label, (5, ypos))
+ dc.DrawText(label, 5, ypos)
if val:
color = self.colors[ x % len(self.colors) ]
dc.SetPen(wx.Pen(color))
dc.SetBrush(wx.Brush(color))
- dc.DrawRectangle((self.linePos+3, ypos), (val, bh))
+ dc.DrawRectangle(self.linePos+3, ypos, val, bh)
ypos = ypos + 2*bh
if ypos > size[1]-10:
wdc = wx.PaintDC(self)
wdc.BeginDrawing()
- wdc.Blit((0,0), size, dc, (0,0))
+ wdc.Blit(0,0, size[0], size[1], dc, 0,0)
wdc.EndDrawing()
dc.SelectObject(wx.NullBitmap)
]
-for line in command_lines:
- args = line.split()
- img2py.main(args)
+if __name__ == "__main__":
+ for line in command_lines:
+ args = line.split()
+ img2py.main(args)
to the sizer (or the size the window was created with) will always be
used. When a window is added to a sizer it's initial size, if any, is
set as the window's minimal size using SetSizeHints if there isn't
-already a minimal size.
-
-Added some convenience methods to wx.Bitmap: SetSize, GetSize, and
-wx.EmptyBitmap can be called with a wx.Size (or a 2-element sequence)
-object too. Similar changes were done for wx.Image as well.
+already a minimal size. You can set the window's minimal size (via
+SetSizeHints) to manually control wha tthe sizer will use when
+calculating layout.
Added new MaskedEditControl code from Will Sadkin. The modules are
now locaed in their own sub-package, wx.lib.masked. Demos updated.
+The changes that implemented the incompatible wx.DC methods in 2.5.1.5
+have been reverted. The wx.DC methods are now compatible with the 2.4
+implemetation. In addition a set of renamed methods have been added
+that take wx.Point and/or wx.Size objects instead of individual
+parameters.
+
distribution.) This has some far reaching ramifications:
All classes derive from object and so all are now "new-style
- classes"
+ classes." This also allows you to use mixin classes that are
+ new-style and to use properties, staticmethod, etc.
Public data members of the C++ classes are wrapped as Python
- properties using property() instead of using __getattr__/__setattr__
- like before. Normally you shouldn't notice any difference, but if
- you were previously doing something with __getattr__/__setattr__
- in derived classes then you may have to adjust things.
-
- Static C++ methods are wrapped using the staticmethod()
- feature of Python and so are accessible as ClassName.MethodName
- as expected. They are still available as top level functions
+ properties using property() instead of using
+ __getattr__/__setattr__ hacks like before. Normally you shouldn't
+ notice any difference, but if you were previously doing something
+ with __getattr__/__setattr__ in derived classes then you may have
+ to adjust things.
+
+ Static C++ methods are wrapped using the staticmethod() feature of
+ Python and so are accessible as ClassName.MethodName as expected.
+ They are still also available as top level functions named like
ClassName_MethodName as before.
The relationship between the wxFoo and wxFooPtr classes have
changed for the better. Specifically, all instances that you see
- will be wxFoo even if they are created internally using wxFooPtr,
- because wxFooPtr.__init__ will change the instance's __class__ as
+ will be wx.Foo even if they are created internally using wx.FooPtr,
+ because wx.FooPtr.__init__ will change the instance's __class__ as
part of the initialization. If you have any code that checks
- class type using something like isinstance(obj, wxFooPtr) you will
- need to change it to isinstance(obj, wxFoo).
+ class type using something like isinstance(obj, wx.FooPtr) you will
+ need to change it to isinstance(obj, wx.Foo).
If you create your own custom event types and EVT_* functions, and you
want to be able to use them with the Bind method above then you should
-change your EVT_* to be an instance of wxPyEventBinder instead of a
+change your EVT_* to be an instance of wx.PyEventBinder instead of a
function. For example, if you used to have something like this::
myCustomEventType = wxNewEventType()
The second parameter is an integer in [0, 1, 2] that specifies the
number of IDs that are needed to be passed to Connect.
+**[Changed in 2.5.1.6]** There is also an Unbind method added to
+wx.EvtHandler that can be used to disconenct event handlers. It looks
+like this::
+
+ def Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
+ """
+ Disconencts the event handler binding for event from self.
+ Returns True if successful.
+ """
2.4, the compatibility modules are generated at build time and contain
assignment statements like this::
- wxWindow = wx.core.Window
+ wxWindow = wx._core.Window
-Don't let the "core" in the name bother you. That and some other
+Don't let the "_core" in the name bother you. That and some other
modules are implementation details, and everything that was in the
wxPython.wx module before will still be in the wx package namespace
-after this change. So from your code you would use it as wx.Window.
+after this change. So from your code you would use it as wx.Window or
+wxWindow if you import from the wxPython.wx module.
A few notes about how all of this was accomplished might be
interesting... SWIG is now run twice for each module that it is
New wx.DC Methods
-----------------
-Many of the Draw methods of wx.DC have alternate forms in C++ that take
-wxPoint or wxSize parameters (let's call these *Type A*) instead of
-the individual x, y, width, height, etc. parameters (and we'll call
-these *Type B*). In the rest of the library I normally made the *Type
-A* forms of the methods be the default method with the "normal" name,
-and had renamed the *Type B* forms of the methods to some similar
-name. For example in wx.Window we have these Python methods::
-
- SetSize(size) # Type A
- SetSizeWH(width, height) # Type B
-
-
-For various reasons the new *Type A* methods in wx.DC were never added
-and the existing *Type B* methods were never renamed. Now that lots
-of other things are also changing in wxPython it has been decided that
-it is a good time to also do the method renaming in wx.DC too in order
-to be consistent with the rest of the library. The methods in wx.DC
-that are affected are listed here::
+**[Changed in 2.5.1.6]** In wxPython 2.5.1.5 there was a new
+implementation of the wx.DC Draw and other methods that broke
+backwards compatibility in the name of consistency. That change has
+been reverted and the wx.DC Draw methods with 2.4 compatible
+signatures have been restored. In addition a new set of methods have
+been added that take wx.Point and/or wx.Size parameters instead of
+separate integer parameters. The Draw and etc. methods now available
+are::
- FloodFillXY(x, y, colour, style = wx.FLOOD_SURFACE)
- FloodFill(point, colour, style = wx.FLOOD_SURFACE)
- GetPixelXY(x, y)
- GetPixel(point)
+ FloodFill(x, y, colour, style = wx.FLOOD_SURFACE)
+ FoodFillPoint(pt, colour, style = wx.FLOOD_SURFACE)
- DrawLineXY(x1, y1, x2, y2)
- DrawLine(point1, point2)
+ GetPixel(x,y)
+ GetPixelPoint(pt)
+
+ DrawLine(x1, y1, x2, y2)
+ DrawLinePoint(pt1, pt2)
- CrossHairXY(x, y)
- CrossHair(point)
+ CrossHair(x, y)
+ CrossHairPoint(pt)
- DrawArcXY(x1, y1, x2, y2, xc, yc)
- DrawArc(point1, point2, center)
+ DrawArc(x1, y1, x2, y2, xc, yc)
+ DrawArcPoint(pt1, pt2, centre)
- DrawCheckMarkXY(x, y, width, height)
- DrawCheckMark(rect)
+ DrawCheckMark(x, y, width, height)
+ DrawCheckMarkRect(rect)
- DrawEllipticArcXY(x, y, w, h, start_angle, end_angle)
- DrawEllipticArc(point, size, start_angle, end_angle)
+ DrawEllipticArc(x, y, w, h, sa, ea)
+ DrawEllipticArcPointSize(pt, sz, sa, ea)
- DrawPointXY(x, y)
- DrawPoint(point)
+ DrawPoint(x, y)
+ DrawPointPoint(pt)
- DrawRectangleXY(x, y, width, height)
- DrawRectangle(point, size)
+ DrawRectangle(x, y, width, height)
DrawRectangleRect(rect)
+ DrawRectanglePointSize(pt, sz)
- DrawRoundedRectangleXY(x, y, width, height, radius)
- DrawRoundedRectangle(point, size, radius)
- DrawRoundedRectangleRect(rect, radius)
+ DrawRoundedRectangle(x, y, width, height, radius)
+ DrawRoundedRectangleRect(r, radius)
+ DrawRoundedRectanglePointSize(pt, sz, radius)
- DrawCircleXY(x, y, radius)
- DrawCircle(point, radius)
+ DrawCircle(x, y, radius)
+ DrawCirclePoint(pt, radius)
- DrawEllipseXY(x, y, width, height)
- DrawEllipse(point, size)
+ DrawEllipse(x, y, width, height)
DrawEllipseRect(rect)
+ DrawEllipsePointSize(pt, sz)
- DrawIconXY(icon, x, y)
- DrawIcon(icon, point)
-
- DrawBitmapXY(bmp, x, y, useMask = FALSE)
- DrawBitmap(bmp, point, useMask = FALSE)
+ DrawIcon(icon, x, y)
+ DrawIconPoint(icon, pt)
- DrawTextXY(text, x, y)
- DrawText(text, point)
+ DrawBitmap(bmp, x, y, useMask = False)
+ DrawBitmapPoint(bmp, pt, useMask = False)
- DrawRotatedTextXY(text, x, y, angle)
- DrawRotatedText(text, point, angle)
+ DrawText(text, x, y)
+ DrawTextPoint(text, pt)
-
- BlitXY(xdest, ydest, width, height, sourceDC, xsrc, ysrc,
- rop = wxCOPY, useMask = FALSE, xsrcMask = -1, ysrcMask = -1)
- Blit(destPt, size, sourceDC, srcPt,
- rop = wxCOPY, useMask = FALSE, srcPtMask = wx.DefaultPosition)
+ DrawRotatedText(text, x, y, angle)
+ DrawRotatedTextPoint(text, pt, angle)
- SetClippingRegionXY(x, y, width, height)
- SetClippingRegion(point, size)
- SetClippingRect(rect)
- SetClippingRegionAsRegion(region);
+ bool Blit(xdest, ydest, width, height, sourceDC, xsrc, ysrc,
+ rop = wx.COPY, useMask = False, xsrcMask = -1, ysrcMask = -1)
+ BlitPointSize(destPt, sz, sourceDC, srcPt, rop = wx.COPY,
+ useMask = False, srcPtMask = wxDefaultPosition)
-
-If you have code that draws on a DC and you are using the new wx
-namespace then you **will** get errors because of these changes, but
-it should be easy to fix the code. You can either change the name of
-the *Type B* method called to the names shown above, or just add
-parentheses around the parameters as needed to turn them into tuples
-and let the SWIG typemaps turn them into the wx.Point or wx.Size
-object that is expected. Then you will be calling the new *Type A*
-method. For example, if you had this code before::
- dc.DrawRectangle(x, y, width, height)
-
-You could either continue to use the *Type B* method by changing the
-name to DrawRectangleXY, or just change it to the new *Type A* by
-adding some parentheses like this::
-
- dc.DrawRectangle((x, y), (width, height))
-
-Or if you were already using a point and size like this::
-
- dc.DrawRectangle(p.x, p.y, s.width, s.height)
-
-Then you can just simplify it like this::
+ SetClippingRegion(x, y, width, height)
+ SetClippingRegionPointSize(pt, sz)
+ SetClippingRegionAsRegion(region)
+ SetClippingRect(rect)
- dc.DrawRectangle(p, s)
-Now before you start yelling and screaming at me for breaking all your
-code, take note that up above I said, "...using the new wx
-namespace..." That's because if you are still importing from
-wxPython.wx then there are some classes defined there with Draw and
-etc. methods that have 2.4 compatible signatures. Unfortunately there
-is one exception to this behaviour. If a DC is returned from a
-function or method then an instance of the new class (with the new
-methods described above) will be returned instead of the compatibility
-class. If/When the old wxPython.wx namespace is removed then these
-compatibility classes will be removed too so you should plan on
-migrating to the new namespace and new DC Draw methods before that
-time.
The hack allowing the old "option" keyword parameter has been removed.
If you use keyword args with w.xSizer Add, Insert, or Prepend methods
-then you will need to use the ``proportion`` name instead of ``option``.
+then you will need to use the ``proportion`` name instead of
+``option``. (The ``proportion`` keyword was also allowed in 2.4.2.4.)
When adding a spacer to a sizer you now need to use a wx.Size or a
2-integer sequence instead of separate width and height parameters.
-This allows for more consistency in how you add the various types of
-items to a sizer. The first parameter defines the item (instead of
-the possibily first two, depending on if you are doing a spacer or
-not,) and that item can either be a window, a sizer or a spacer (which
-can be a sequence or a wx.Size.)
+This was optionally allowed in 2.4, but now it is required. This
+allows for more consistency in how you add the various types of items
+to a sizer. The first parameter defines the item (instead of the
+possibily first two, depending on if you are doing a spacer or not,)
+and that item can either be a window, a sizer or a spacer (which can
+be a sequence or a wx.Size.) Removing the option for separate width
+and height parameters greatly simplified the wrapper code.
The wx.GridBagSizer class (very similar to the RowColSizer in the
library) has been added to C++ and wrapped for wxPython. It can also
You should not use AddWindow, AddSizer, AddSpacer (and similar for
Insert, Prepend, and etc.) methods any longer. Just use Add and the
-wrappers will figure out what to do.
+wrappers will figure out what to do. **[Changed in 2.5.1.6]**
+AddWindow, AddSize, AddSpacer and etc. will now issue a
+DeprecationWarning.
**[Changed in 2.5.1.6]** wx.ADJUST_MINSIZE is now the default
behaviour for window items in sizers. This means that the item's
minsize that the window had when added to the sizer (or the size the
window was created with) will always be used. When a window is added
to a sizer it's initial size, if any, is set as the window's minimal
-size using SetSizeHints if there isn't already a minimal size.
+size using SetSizeHints if there isn't already a minimal size. If you
+would like the sizer to use something other than the window's initial
+size as the minimum then you can give it a new minimum by calling its
+SetSizeHints method.
+
PlatformInfo
* windows3
They have been replaced by the following, but please remember that
-these are just "implementation details" and you shoudl reall be using
-the objects in these modules via the wx or wxPython.wx packages:
+these are just "implementation details" and you should really be using
+the objects in these modules only via the wx or wxPython.wx packages:
* _core
* _gdi
Use None instead of the ancient and should have been removed a long
time ago wx.NULL alias.
-wx.TreeCtrl no longer needs to be passed the cookie variable as the
-2nd parameter. It still returns it though, for use with GetNextChild.
+wx.TreeCtrl.GetFirstChild no longer needs to be passed the cookie
+variable as the 2nd parameter. It still returns it though, for use
+with GetNextChild.
The wx.NO_FULL_REPAINT_ON_RESIZE style is now the default style for
all windows. The name still exists for compatibility, but it is set
The wxWave class has been renamed to wxSound, and now has a slightly
different API.
-wx.TaskbarIcon works on wxGTK-based platforms now, however you have to
-manage it a little bit more than you did before. Basically, the app
-will treat it like a top-level frame in that if the wx.TaskBarIcon
-still exists when all the frames are closed then the app will still
-not exit. You need to ensure that the wx.TaskBarIcon is destroyed
-when your last Frame is closed. For wxPython apps it is usually
-enough if your main frame object holds the only reference to the
-wx.TaskBarIcon, then when the frame is closed Python reference
-counting takes care of the rest.
+wx.TaskbarIcon works on wxGTK-based platforms (for some window
+managers,) however you have to manage it a little bit more than you
+did before. Basically, the app will treat it like a top-level frame
+in that if the wx.TaskBarIcon still exists when all the frames are
+closed then the app will still not exit. You need to ensure that the
+wx.TaskBarIcon is destroyed when your last Frame is closed. For
+wxPython apps it is usually enough if your main frame object holds the
+only reference to the wx.TaskBarIcon, then when the frame is closed
+Python reference counting takes care of the rest.
Before Python 2.3 it was possible to pass a floating point object as a
parameter to a function that expected an integer, and the
integer by truncating the fractional portion of the number. With
Python 2.3 that behavior was deprecated and a deprecation warning is
raised when you pass a floating point value, (for example, calling
-wx.DC.DrawLineXY with floats for the position and size,) and lots of
+wx.DC.DrawLine with floats for the position and size,) and lots of
developers using wxPython had to scramble to change their code to call
int() before calling wxPython methods. Recent changes in SWIG have
moved the conversion out of PyArg_ParseTuple to custom code that SWIG
to their own sub-package, wx.lib.masked. See the docstrings and demo
for changes in capabilities, usage, etc.
+**[Changed in 2.5.1.6]** wx.MaskColour constructor has been deprecated
+and will raise a DeprecationWarning if used. The main wx.Mask
+constructor has been modified to be compatible with wx.MaskColour so
+you should use it instead.
# Other names that need to be reverse-renamed for the old namespace
-DC_old
-MemoryDC_old
-BufferedDC_old
-BufferedPaintDC_old
-ScreenDC_old
-ClientDC_old
-PaintDC_old
-WindowDC_old
-MirrorDC_old
-PostScriptDC_old
-MetaFileDC_old
-PrinterDC_old
-
MaskColour
Every application must have a ``wx.App`` instance, and all
creation of UI objects should be delayed until after the
- ``wx.App`` object has been created in order to ensure that the
- gui platform and wxWidgets have been fully initialized.
+ ``wx.App`` object has been created in order to ensure that the gui
+ platform and wxWidgets have been fully initialized.
Normally you would derive from this class and implement an
``OnInit`` method that creates a frame and then calls
``self.SetTopWindow(frame)``.
- :see: `wx.PySimpleApp` for a simpler app class that can be used directly.
+ :see: `wx.PySimpleApp` for a simpler app class that can be used
+ directly.
"""
outputWindowClass = PyOnDemandOutputWindow
- def __init__(self, redirect=_defRedirect, filename=None, useBestVisual=False):
+ def __init__(self, redirect=_defRedirect, filename=None,
+ useBestVisual=False, clearSigInt=True):
"""
Construct a ``wx.App`` object.
- :param redirect: Should ``sys.stdout`` and ``sys.stderr``
- be redirected? Defaults to True on Windows and Mac,
- False otherwise. If `filename` is None then output
- will be redirected to a window that pops up as
- needed. (You can control what kind of window is
- created for the output by resetting the class
- variable ``outputWindowClass`` to a class of your
- choosing.)
+ :param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
+ redirected? Defaults to True on Windows and Mac, False
+ otherwise. If `filename` is None then output will be
+ redirected to a window that pops up as needed. (You can
+ control what kind of window is created for the output by
+ resetting the class variable ``outputWindowClass`` to a
+ class of your choosing.)
- :param filename: The name of a file to redirect output
- to, if redirect is True.
+ :param filename: The name of a file to redirect output to, if
+ redirect is True.
:param useBestVisual: Should the app try to use the best
- available visual provided by the system (only
- relevant on systems that have more than one visual.)
- This parameter must be used instead of calling
- `SetUseBestVisual` later on because it must be set
- before the underlying GUI toolkit is initialized.
+ available visual provided by the system (only relevant on
+ systems that have more than one visual.) This parameter
+ must be used instead of calling `SetUseBestVisual` later
+ on because it must be set before the underlying GUI
+ toolkit is initialized.
+
+ :param clearSigInt: Should SIGINT be cleared? This allows the
+ app to terminate upon a Ctrl-C in the console like other
+ GUI apps will.
:note: You should override OnInit to do applicaition
initialization to ensure that the system, toolkit and
# KeyboardInterrupt???) but will later segfault on exit. By
# setting the default handler then the app will exit, as
# expected (depending on platform.)
- try:
- import signal
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- except:
- pass
+ if clearSigInt:
+ try:
+ import signal
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ except:
+ pass
# Save and redirect the stdio to a window?
self.stdioWin = None
:see: `wx.App`
"""
- def __init__(self, redirect=False, filename=None, useBestVisual=False):
+ def __init__(self, redirect=False, filename=None,
+ useBestVisual=False, clearSigInt=True):
"""
:see: `wx.App.__init__`
"""
- wx.App.__init__(self, redirect, filename, useBestVisual)
+ wx.App.__init__(self, redirect, filename, useBestVisual, clearSigInt)
def OnInit(self):
wx.InitAllImageHandlers()
-#if defined(wxUSE_DC_OLD_METHODS)
+#if 1 // The < 2.4 and > 2.5.1.5 way
bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
%name(FloodFillPoint) bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
%name(DrawCheckMarkRect) void DrawCheckMark(const wxRect& rect);
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea);
- %name(DrawEllipticArcPtSz) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea);
+ %name(DrawEllipticArcPointSize) void DrawEllipticArc(const wxPoint& pt, const wxSize& sz, double sa, double ea);
void DrawPoint(wxCoord x, wxCoord y);
%name(DrawPointPoint) void DrawPoint(const wxPoint& pt);
void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%name(DrawRectangleRect)void DrawRectangle(const wxRect& rect);
- %name(DrawRectanglePtSz) void DrawRectangle(const wxPoint& pt, const wxSize& sz);
+ %name(DrawRectanglePointSize) void DrawRectangle(const wxPoint& pt, const wxSize& sz);
void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
%name(DrawRoundedRectangleRect) void DrawRoundedRectangle(const wxRect& r, double radius);
- %name(DrawRoundedRectanglePtSz) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius);
+ %name(DrawRoundedRectanglePointSize) void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius);
void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
%name(DrawCirclePoint) void DrawCircle(const wxPoint& pt, wxCoord radius);
void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
%name(DrawEllipseRect) void DrawEllipse(const wxRect& rect);
- %name(DrawEllipsePtSz) void DrawEllipse(const wxPoint& pt, const wxSize& sz);
+ %name(DrawEllipsePointSize) void DrawEllipse(const wxPoint& pt, const wxSize& sz);
void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
%name(DrawIconPoint) void DrawIcon(const wxIcon& icon, const wxPoint& pt);
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = False,
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
- %name(BlitPtSz) bool Blit(const wxPoint& destPt, const wxSize& sz,
- wxDC *source, const wxPoint& srcPt,
- int rop = wxCOPY, bool useMask = False,
- const wxPoint& srcPtMask = wxDefaultPosition);
+ %name(BlitPointSize) bool Blit(const wxPoint& destPt, const wxSize& sz,
+ wxDC *source, const wxPoint& srcPt,
+ int rop = wxCOPY, bool useMask = False,
+ const wxPoint& srcPtMask = wxDefaultPosition);
+ void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
+ %name(SetClippingRegionPointSize) void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
+ %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
+ %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
-#else // The new way
+#else // The doomed 2.5.1.5
%name(FloodFillXY) bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE);
int rop = wxCOPY, bool useMask = False,
const wxPoint& srcPtMask = wxDefaultPosition);
+
+ %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
+ void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
+ %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
+ %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
+
#endif
void DrawLines(int points, wxPoint* points_array, wxCoord xoffset = 0, wxCoord yoffset = 0);
virtual void SetPalette(const wxPalette& palette);
- // clipping region
- // ---------------
-
- %name(SetClippingRegionXY)void SetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
- void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
- %name(SetClippingRect) void SetClippingRegion(const wxRect& rect);
- %name(SetClippingRegionAsRegion) void SetClippingRegion(const wxRegion& region);
-
virtual void DestroyClippingRegion();
DocDeclA(
GetLogicalOriginTuple);
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
+ %extend {
+ void SetLogicalOriginPoint(const wxPoint& point) {
+ self->SetLogicalOrigin(point.x, point.y);
+ }
+ }
-
+
wxPoint GetDeviceOrigin() const;
DocDeclAName(
void, GetDeviceOrigin(wxCoord *OUTPUT, wxCoord *OUTPUT) const,
GetDeviceOriginTuple);
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
+ %extend {
+ void SetDeviceOriginPoint(const wxPoint& point) {
+ self->SetDeviceOrigin(point.x, point.y);
+ }
+ }
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
// ------------
virtual void CalcBoundingBox(wxCoord x, wxCoord y);
+ %extend {
+ void CalcBoundingBoxPoint(const wxPoint& point) {
+ self->CalcBoundingBox(point.x, point.y);
+ }
+ }
+
void ResetBoundingBox();
// Get the final bounding box of the PostScript or Metafile picture.
// compatible with the DC Draw methods in 2.4. See also wxPython/_wx.py.
+#if 0
+
%define MAKE_OLD_DC_CLASS(classname)
%pythoncode {
class classname##_old(classname):
MAKE_OLD_DC_CLASS(MetaFileDC);
MAKE_OLD_DC_CLASS(PrinterDC);
+#endif
//---------------------------------------------------------------------------
self.currentTime=None
+ size = wx.Size(*size)
+ bestSize = self.GetBestSize()
+ size.x = max(size.x, bestSize.x)
+ size.y = max(size.y, bestSize.y)
+ self.SetSize(size)
+
# Make an initial bitmap for the face, it will be updated and
# painted at the first EVT_SIZE event.
W, H = size
self.faceBitmap = wx.EmptyBitmap(max(W,1), max(H,1))
-
+
# Set event handlers...
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
-
# Initialize the timer that drives the update of the clock
# face. Update every half second to ensure that there is at
# least one true update during each realtime second.
self.timer = wx.Timer(self)
self.timer.Start(500)
+
def DoGetBestSize(self):
return wx.Size(25,25)
+
def OnPaint(self, event):
- self._doDrawHands(wx.BufferedPaintDC(self), True)
+ dc = wx.BufferedPaintDC(self)
+ self._doDrawHands(dc, True)
def OnTimerExpire(self, event):
# The faceBitmap init is done here, to make sure the buffer is always
# the same size as the Window
size = self.GetClientSize()
+ if size.x < 1 or size.y < 1:
+ return
+
self.faceBitmap = wx.EmptyBitmap(size.width, size.height)
# Update drawing coordinates...
hour, minutes, seconds = currentTime
# Start by drawing the face bitmap
- drawDC.DrawBitmap(self.faceBitmap, (0,0))
+ drawDC.DrawBitmap(self.faceBitmap, 0,0)
# NOTE: All this hand drawing code below should be refactored into a helper function.
drawDC.SetPen(wx.Pen(self.shadowPenColour,
int(self.handHoursThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
- int(self.centerY + self.shadowDistance),
- int(x + self.shadowDistance),
- int(y + self.shadowDistance))
+ drawDC.DrawLine(self.centerX + self.shadowDistance,
+ self.centerY + self.shadowDistance,
+ x + self.shadowDistance,
+ y + self.shadowDistance)
# Draw minutes hand shadow
angle = minutes * 6
drawDC.SetPen(wx.Pen(self.shadowPenColour,
int(self.handMinutesThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
- int(self.centerY + self.shadowDistance),
- int(x + self.shadowDistance),
- int(y + self.shadowDistance))
+ drawDC.DrawLine(self.centerX + self.shadowDistance,
+ self.centerY + self.shadowDistance,
+ x + self.shadowDistance,
+ y + self.shadowDistance)
# Draw seconds hand shadow if required
if seconds >= 0:
drawDC.SetPen(wx.Pen(self.shadowPenColour,
int(self.handSecondsThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
- int(self.centerY + self.shadowDistance),
- int(x + self.shadowDistance),
- int(y + self.shadowDistance))
+ drawDC.DrawLine(self.centerX + self.shadowDistance,
+ self.centerY + self.shadowDistance,
+ x + self.shadowDistance,
+ y + self.shadowDistance)
# Draw hours hand
drawDC.SetPen(wx.Pen(self.handHoursColour,
int(self.handHoursThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
+ drawDC.DrawLine(self.centerX, self.centerY, x, y)
# Draw minutes hand
angle = minutes * 6
drawDC.SetPen(wx.Pen(self.handMinutesColour,
int(self.handMinutesThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
+ drawDC.DrawLine(self.centerX, self.centerY, x, y)
# Draw seconds hand if required
if seconds >= 0:
drawDC.SetPen(wx.Pen(self.handSecondsColour,
int(self.handSecondsThickness * self.scale),
wx.SOLID))
- drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
+ drawDC.DrawLine(self.centerX, self.centerY, x, y)
if style & TICKS_CIRCLE:
x, y = self._center2corner(x, y, tipo)
- drawDC.DrawEllipse((x, y), (int(size), int(size)))
+ drawDC.DrawEllipse(x, y, size, size)
elif style & TICKS_SQUARE:
x, y = self._center2corner(x, y, tipo)
- drawDC.DrawRectangle((x, y), (int(size), int(size)))
+ drawDC.DrawRectangle(x, y, size, size)
elif (style & TICKS_DECIMAL) or (style & TICKS_ROMAN):
self._draw_rotate_text(drawDC, x, y, tipo, angle)
y = int(y -
((math.cos((angle) * radiansPerDegree)*lY) -
(math.sin((angle) * radiansPerDegree)*lX)))
- drawDC.DrawRotatedText(text, (x,y), angle)
+ drawDC.DrawRotatedText(text, x,y, angle)
else:
x = x - lX
y = y - lY
- drawDC.DrawText(text, (x, y))
+ drawDC.DrawText(text, x, y)
def _draw_rotate_polygon(self, drawDC, x, y, tipo, angle):
drawDC.SetBrush(self.watchBrush)
else:
drawDC.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
- drawDC.DrawCircle((self.centerX, self.centerY), self.radius_watch)
+ drawDC.DrawCircle(self.centerX, self.centerY, self.radius_watch)
def _calcSteps(self):
f=False
coords["ticks_minutes"][3][i][2]=f
- self.coords=coords
+ self.coords = coords
def _getCoords(self, tipo, angle):
else:
dc.SetPen(self.shadowPen)
for i in range(self.bezelWidth):
- dc.DrawLine((x1+i, y1), (x1+i, y2-i))
- dc.DrawLine((x1, y1+i), (x2-i, y1+i))
+ dc.DrawLine(x1+i, y1, x1+i, y2-i)
+ dc.DrawLine(x1, y1+i, x2-i, y1+i)
# draw the lower right sides
if self.up:
else:
dc.SetPen(self.highlightPen)
for i in range(self.bezelWidth):
- dc.DrawLine((x1+i, y2-i), (x2+1, y2-i))
- dc.DrawLine((x2-i, y1+i), (x2-i, y2))
+ dc.DrawLine(x1+i, y2-i, x2+1, y2-i)
+ dc.DrawLine(x2-i, y1+i, x2-i, y2)
def DrawLabel(self, dc, width, height, dw=0, dy=0):
tw, th = dc.GetTextExtent(label)
if not self.up:
dw = dy = self.labelDelta
- dc.DrawText(label, ((width-tw)/2+dw, (height-th)/2+dy))
+ dc.DrawText(label, (width-tw)/2+dw, (height-th)/2+dy)
def DrawFocusIndicator(self, dc, w, h):
dc.SetLogicalFunction(wx.INVERT)
dc.SetPen(self.focusIndPen)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle((bw+2,bw+2), (w-bw*2-4, h-bw*2-4))
+ dc.DrawRectangle(bw+2,bw+2, w-bw*2-4, h-bw*2-4)
dc.SetLogicalFunction(wx.COPY)
if not self.up:
dw = dy = self.labelDelta
hasMask = bmp.GetMask() != None
- dc.DrawBitmap(bmp, ((width-bw)/2+dw, (height-bh)/2+dy), hasMask)
+ dc.DrawBitmap(bmp, (width-bw)/2+dw, (height-bh)/2+dy, hasMask)
#----------------------------------------------------------------------
pos_x = (width-bw-tw)/2+dw # adjust for bitmap and text to centre
if bmp !=None:
- dc.DrawBitmap(bmp, (pos_x, (height-bh)/2+dy), hasMask) # draw bitmap if available
+ dc.DrawBitmap(bmp, pos_x, (height-bh)/2+dy, hasMask) # draw bitmap if available
pos_x = pos_x + 2 # extra spacing from bitmap
- dc.DrawText(label, (pos_x + dw+bw, (height-th)/2+dy)) # draw the text
+ dc.DrawText(label, pos_x + dw+bw, (height-th)/2+dy) # draw the text
#----------------------------------------------------------------------
tw,th = DC.GetTextExtent(month)
adjust = self.cx_st + (self.sizew-tw)/2
- DC.DrawText(month, (adjust, self.cy_st + th))
+ DC.DrawText(month, adjust, self.cy_st + th)
year = str(self.year)
tw,th = DC.GetTextExtent(year)
f = wx.Font(sizef, self.font, wx.NORMAL, self.bold)
DC.SetFont(f)
- DC.DrawText(year, (self.cx_st + adjust, self.cy_st + th))
+ DC.DrawText(year, self.cx_st + adjust, self.cy_st + th)
def DrawWeek(self, DC): # draw the week days
# increase by 1 to include all gridlines
else:
pen = wx.Pen(MakeColor(self.GetColor(COLOR_BACKGROUND)), 1, wx.SOLID)
DC.SetPen(pen)
- DC.DrawRectangle( pointXY, pointWH)
+ DC.DrawRectanglePointSize( pointXY, pointWH)
old_pen = DC.GetPen()
# draw the horizontal hilight
startPoint = wx.Point(x + 1 , y + 1)
endPoint = wx.Point(x + width - 1, y + 1)
- DC.DrawLine(startPoint, endPoint )
+ DC.DrawLinePoint(startPoint, endPoint )
# draw the vertical hilight
startPoint = wx.Point(x + 1 , y + 1)
endPoint = wx.Point(x + 1, y + height - 2)
- DC.DrawLine(startPoint, endPoint )
+ DC.DrawLinePoint(startPoint, endPoint )
pen = wx.Pen(MakeColor(self.colors[COLOR_3D_DARK]), 1, wx.SOLID)
DC.SetPen(pen)
# draw the horizontal lowlight
startPoint = wx.Point(x + 1, y + height - 2)
endPoint = wx.Point(x + width - 1, y + height - 2)
- DC.DrawLine(startPoint, endPoint )
+ DC.DrawLinePoint(startPoint, endPoint )
# draw the vertical lowlight
startPoint = wx.Point(x + width - 2 , y + 2)
endPoint = wx.Point(x + width - 2, y + height - 2)
- DC.DrawLine(startPoint, endPoint )
+ DC.DrawLinePoint(startPoint, endPoint )
pen = wx.Pen(MakeColor(self.colors[COLOR_FONT]), 1, wx.SOLID)
DC.SetPen(pen)
point = (x+diffx, y+diffy)
- DC.DrawText(day, point)
+ DC.DrawTextPoint(day, point)
cnt_x = cnt_x + 1
def _CalcFontSize(self, DC, f):
adj_v = adj_v + self.num_indent_vert
- DC.DrawText(text, (x+adj_h, y+adj_v))
+ DC.DrawTextPoint(text, (x+adj_h, y+adj_v))
def DrawDayText(self, DC, key):
f = wx.Font(10, self.font, wx.NORMAL, self.bold) # initial font setting
nkey = key + self.st_pos -1
rect = self.rg[nkey]
- DC.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
+ DC.DrawRectangleRect(rect)
# calculate and draw the grid lines
def DrawGrid(self, DC):
x1 = x1 + self.restW
if self.hide_grid is False:
- DC.DrawLine((x1, y1), (x1, y2))
+ DC.DrawLinePoint((x1, y1), (x1, y2))
self.gridx.append(x1)
y1 = y1 + self.restH
if self.hide_grid is False:
- DC.DrawLine((x1, y1), (x2, y1))
+ DC.DrawLinePoint((x1, y1), (x2, y1))
self.gridy.append(y1)
DC.SetPen(wx.TRANSPARENT_PEN)
rect = self.rg[key]
- DC.DrawRectangle((rect.x+1, rect.y+1), (rect.width-2, rect.height-2))
+ DC.DrawRectangle(rect.x+1, rect.y+1, rect.width-2, rect.height-2)
self.caldraw.DrawDayText(DC,key)
DC.SetPen(wx.Pen(MakeColor(self.GetColor(COLOR_GRID_LINES)), width))
rect = self.rg[key]
- DC.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
+ DC.DrawRectangleRect(rect)
DC.EndDrawing()
"""Performs the blit of the buffer contents on-screen."""
width, height = self.buffer.GetSize()
dc.BeginDrawing()
- dc.Blit((0, 0), (width, height), self.buffer, (0, 0))
+ dc.Blit(0, 0, width, height, self.buffer, 0, 0)
dc.EndDrawing()
def GetBoundingRect(self):
"""Returns the colour value for a position on the slider. The position
must be within the valid height of the slider, or results can be
unpredictable."""
- return self.buffer.GetPixel((0, pos))
+ return self.buffer.GetPixel(0, pos)
def DrawBuffer(self):
"""Actual implementation of the widget's drawing. We simply draw
r,g,b = [c * 255.0 for c in colorsys.hsv_to_rgb(h,s,v)]
colour = wx.Colour(int(r), int(g), int(b))
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
- self.buffer.DrawRectangle((0, y_pos), (15, 1))
+ self.buffer.DrawRectangle(0, y_pos, 15, 1)
v = v - vstep
"""Returns a colour value at a specific x, y coordinate pair. This
is useful for determining the colour found a specific mouse click
in an external event handler."""
- return self.buffer.GetPixel((x, y))
+ return self.buffer.GetPixel(x, y)
def DrawBuffer(self):
"""Draws the palette XPM into the memory buffer."""
#self.GeneratePaletteBMP ("foo.bmp")
- self.buffer.DrawBitmap(self.palette, (0, 0), 0)
+ self.buffer.DrawBitmap(self.palette, 0, 0, 0)
def HighlightPoint(self, x, y):
"""Highlights an area of the palette with a little circle around
colour = wx.Colour(0, 0, 0)
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
self.buffer.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
- self.buffer.DrawCircle((x, y), 3)
+ self.buffer.DrawCircle(x, y, 3)
self.Refresh()
def GeneratePaletteBMP(self, file_name, granularity=1):
colour = wx.Colour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
self.buffer.SetBrush(wx.Brush(colour, wx.SOLID))
- self.buffer.DrawRectangle((x, y),
- (self.HORIZONTAL_STEP, self.vertical_step))
+ self.buffer.DrawRectangle(x, y,
+ self.HORIZONTAL_STEP, self.vertical_step)
# this code is now simpler (and works)
bitmap = self.buffer.GetBitmap()
+++ /dev/null
-#----------------------------------------------------------------------
-# Name: compatdc.py
-# Purpose: Make wxPython 2.4 DC classes compatible with the 2.5
-# DC classes
-#
-# Author: Robin Dunn
-#
-# Created: 21-Apr-2004
-# RCS-ID: $Id$
-# Copyright: (c) 2004 by Total Control Software
-# Licence: wxWindows license
-#----------------------------------------------------------------------
-
-import wx
-
-
-def MakeDCCompatible(klass, full=False):
- """
- Manipulate the DC class passed to this funciton such that it is
- more compatible with the DC classes used in wxPython 2.5. This
- should help with writing code that works with both versions. If
- full is True then in addition to creating the 'XY' versions of the
- methods, a 'point/size' version (which are the new defaults in
- 2.5) will also be created.
- """
- if wx.VERSION >= (2,5):
- return # Nothing to do
-
- # first create XY methods from the current ones.
- klass.FloodFillXY = klass.FloodFill
- klass.GetPixelXY = klass.GetPixel
- klass.DrawLineXY = klass.DrawLine
- klass.CrossHairXY = klass.CrossHair
- klass.DrawArcXY = klass.DrawArc
- klass.DrawEllipticArcXY = klass.DrawEllipticArc
- klass.DrawPointXY = klass.DrawPoint
- klass.DrawRectangleXY = klass.DrawRectangle
- klass.DrawRoundedRectangleXY = klass.DrawRoundedRectangle
- klass.DrawCircleXY = klass.DrawCircle
- klass.DrawEllipseXY = klass.DrawEllipse
- klass.DrawIconXY = klass.DrawIcon
- klass.DrawBitmapXY = klass.DrawBitmap
- klass.DrawTextXY = klass.DrawText
- klass.DrawRotatedTextXY = klass.DrawRotatedText
- klass.BlitXY = klass.Blit
-
- # now, make some functions that we can use as new methods
- if full:
- def FloodFill(self, pt, col, style=wx.FLOOD_SURFACE):
- pt = wx.Point(*pt)
- return self.FloodFillXY(pt.x, pt.y, col, style)
- klass.FloodFill = FloodFill
-
- def GetPixel(self, pt):
- pt = wx.Point(*pt)
- return self.GetPixelXY(pt.x, pt.y)
- klass.GetPixel = GetPixel
-
- def DrawLine(self, pt1, pt2):
- pt1 = wx.Point(*pt1)
- pt2 = wx.Point(*pt2)
- return self.DrawLineXY(pt1.x, pt1.y, pt2.x, pt2.y)
- klass.DrawLine = DrawLine
-
- def CrossHair(self, pt):
- pt = wx.Point(*pt)
- return self.CrossHairXY(pt.x, pt.y)
- klass.CrossHair = CrossHair
-
- def DrawArc(self, pt1, pt2, centre):
- pt1 = wx.Point(*pt1)
- pt2 = wx.Point(*pt2)
- return self.DrawArcXY(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y)
- klass.DrawArc = DrawArc
-
- def DrawEllipticArc(self, pt, sz, sa, ea):
- pt = wx.Point(*pt)
- sz = wx.Size(*sz)
- return self.DrawEllipticArcXY(pt.x, pt.y, sz.width, sz.height, sa, ea)
- klass.DrawEllipticArc = DrawEllipticArc
-
- def DrawPoint(self, pt):
- pt = wx.Point(*pt)
- return self.DrawPointXY(pt.x, pt.y)
- klass.DrawPoint = DrawPoint
-
- def DrawRectangle(self, pt, sz):
- pt = wx.Point(*pt)
- sz = wx.Size(*sz)
- return self.DrawRectangleXY(pt.x, pt.y, sz.width, sz.height)
- klass.DrawRectangle = DrawRectangle
-
- def DrawRoundedRectangle(self, pt, sz, radius):
- pt = wx.Point(*pt)
- sz = wx.Size(*sz)
- return self.DrawRoundedRectangleXY(pt.x, pt.y, sz.width, sz.height, radius)
- klass.DrawRoundedRectangle = DrawRoundedRectangle
-
- def DrawCircle(self, pt, radius):
- pt = wx.Point(*pt)
- return self.DrawCircleXY(pt.x, pt.y, radius)
- klass.DrawCircle = DrawCircle
-
- def DrawEllipse(self, pt, sz):
- pt = wx.Point(*pt)
- sz = wx.Size(*sz)
- return self.DrawEllipseXY(pt.x, pt.y, sz.width, sz.height)
- klass.DrawEllipse = DrawEllipse
-
- def DrawIcon(self, icon, pt):
- pt = wx.Point(*pt)
- return self.DrawIconXY(icon, pt.x, pt.y )
- klass.DrawIcon = DrawIcon
-
- def DrawBitmap(self, bmp, pt):
- pt = wx.Point(*pt)
- return self.DrawBitmapXY(bmp, pt.x, pt.y)
- klass.DrawBitmap = DrawBitmap
-
- def DrawText(self, text, pt):
- pt = wx.Point(*pt)
- return self.DrawTextXY(text, pt.x, pt.y)
- klass.DrawText = DrawText
-
- def DrawRotatedText(self, text, pt, angle):
- pt = wx.Point(*pt)
- return self.DrawRotatedTextXY(text, pt.x, pt.y, angle)
- klass.DrawRotatedText = DrawRotatedText
-
- def Blit(self, destPt, sz, source, srcPt,
- rop=wx.COPY, useMask=False, srcPtMask=wx.DefaultPosition):
- return self.BlitXY(destPt.x, destPt.y, sz.width, sz.height,
- source, srcPt.x, srcPt.y, rop, useMask,
- srcPtMask.x, srcPtMask.y)
- klass.Blit = Blit
-
-
-def MakeAllDCsCompatible(full=False):
- """
- Run MakeDCCompatible on all DC classes in wx.
- """
- MakeDCCompatible(wx.BufferedPaintDC, full)
- MakeDCCompatible(wx.BufferedDC, full)
- MakeDCCompatible(wx.MemoryDC, full)
- MakeDCCompatible(wx.ScreenDC, full)
- MakeDCCompatible(wx.ClientDC, full)
- MakeDCCompatible(wx.PaintDC, full)
- MakeDCCompatible(wx.WindowDC, full)
- MakeDCCompatible(wx.PostScriptDC, full)
- if hasattr(wx, "MetaFileDC"):
- MakeDCCompatible(wx.MetaFileDC, full)
- if hasattr(wx, "PrinterDC"):
- MakeDCCompatible(wx.PrinterDC, full)
- MakeDCCompatible(wx.DC, full)
-
pass
def DrawEditText(self, t, x, y, dc):
- dc.DrawText(t, (x * self.fw, y * self.fh))
+ dc.DrawText(t, x * self.fw, y * self.fh)
def DrawLine(self, line, dc):
if self.IsLine(line):
x = 0
y = (len(self.lines) - self.sy) * self.fh
hasTransparency = 1
- dc.DrawBitmap(self.eofMarker, (x, y), hasTransparency)
+ dc.DrawBitmap(self.eofMarker, x, y, hasTransparency)
##------------------ cursor-related functions
szy = self.fh
x = xp * szx
y = yp * szy
- dc.Blit((x,y), (szx,szy), dc, (x,y), wx.SRC_INVERT)
+ dc.Blit(x,y, szx,szy, dc, x,y, wx.SRC_INVERT)
self.sco_x = xp
self.sco_y = yp
def renderCharacterData(self, data, x, y):
self.dc.SetTextForeground(self.getCurrentColor())
- self.dc.DrawText(data, (x, y))
+ self.dc.DrawText(data, x, y)
def start_angle(self, attrs):
self.dc.SetFont(self.getCurrentFont())
self.dc.SetPen(self.getCurrentPen())
width, height, descent, leading = self.dc.GetFullTextExtent("M")
y = self.y + self.offsets[-1]
- self.dc.DrawLine((iround(self.x), iround(y)), (iround( self.x+width), iround(y)))
- self.dc.DrawLine((iround(self.x), iround(y)), (iround(self.x+width), iround(y-width)))
+ self.dc.DrawLine(iround(self.x), iround(y), iround( self.x+width), iround(y))
+ self.dc.DrawLine(iround(self.x), iround(y), iround(self.x+width), iround(y-width))
self.updateDims(width, height, descent, leading)
r = iround( 0.95 * width / 4)
xc = (2*self.x + width) / 2
yc = iround(y-1.5*r)
- self.dc.DrawCircle((xc - r, yc), r)
- self.dc.DrawCircle((xc + r, yc), r)
+ self.dc.DrawCircle(xc - r, yc, r)
+ self.dc.DrawCircle(xc + r, yc, r)
self.updateDims(width, height, 0, 0)
def start_times(self, attrs):
width *= 0.8
width = iround(width+.5)
self.dc.SetPen(wx.Pen(self.getCurrentColor(), 1))
- self.dc.DrawLine((iround(self.x), iround(y-width)), (iround(self.x+width-1), iround(y-1)))
- self.dc.DrawLine((iround(self.x), iround(y-2)), (iround(self.x+width-1), iround(y-width-1)))
+ self.dc.DrawLine(iround(self.x), iround(y-width), iround(self.x+width-1), iround(y-1))
+ self.dc.DrawLine(iround(self.x), iround(y-2), iround(self.x+width-1), iround(y-width-1))
self.updateDims(width, height, 0, 0)
dc.SetBrush(self.Brush)
radius = int(round(self.Diameter/2))
for (x,y) in Points:
- dc.DrawEllipse(((x - radius), (y - radius)), (self.Diameter, self.Diameter))
+ dc.DrawEllipse((x - radius), (y - radius), self.Diameter, self.Diameter)
dc.SetBrush(self.Brush)
radius = int(round(self.Diameter/2))
(X,Y) = WorldToPixel((self.X,self.Y))
- dc.DrawEllipse(((X - radius), (Y - radius)), (self.Diameter, self.Diameter))
+ dc.DrawEllipse((X - radius), (Y - radius), self.Diameter, self.Diameter)
class Rectangle(draw_object):
dc.SetPen(self.Pen)
dc.SetBrush(self.Brush)
- dc.DrawRectangle((X,Y), (Width,Height))
+ dc.DrawRectangle(X,Y, Width,Height)
class Ellipse(draw_object):
def __init__(self,x,y,width,height,LineColor,LineStyle,LineWidth,FillColor,FillStyle,Foreground = 0):
dc.SetPen(self.Pen)
dc.SetBrush(self.Brush)
- dc.DrawEllipse((X,Y), (Width,Height))
+ dc.DrawEllipse(X,Y, Width,Height)
class Circle(draw_object):
def __init__(self,x,y,Diameter,LineColor,LineStyle,LineWidth,FillColor,FillStyle,Foreground = 0):
dc.SetPen(self.Pen)
dc.SetBrush(self.Brush)
- dc.DrawEllipse((X-Diameter/2,Y-Diameter/2), (Diameter,Diameter))
+ dc.DrawEllipse(X-Diameter/2,Y-Diameter/2, Diameter,Diameter)
class Text(draw_object):
"""
raise "Invalid value for Text Object Position Attribute"
self.x_shift = x_shift
self.y_shift = y_shift
- dc.DrawText(self.String, (X-self.x_shift, Y-self.y_shift))
+ dc.DrawText(self.String, X-self.x_shift, Y-self.y_shift)
#---------------------------------------------------------------------------
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetLogicalFunction(wx.XOR)
if self.PrevRBBox:
- dc.DrawRectangleXY(*self.PrevRBBox)
- dc.DrawRectangleXY(x_c-w/2,y_c-h/2,w,h)
+ dc.DrawRectangle(*self.PrevRBBox)
+ dc.DrawRectangle(x_c-w/2,y_c-h/2,w,h)
self.PrevRBBox = (x_c-w/2,y_c-h/2,w,h)
dc.EndDrawing()
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetLogicalFunction(wx.XOR)
if self.PrevMoveBox:
- dc.DrawRectangleXY(*self.PrevMoveBox)
- dc.DrawRectangleXY(x_tl,y_tl,w,h)
+ dc.DrawRectangle(*self.PrevMoveBox)
+ dc.DrawRectangle(x_tl,y_tl,w,h)
self.PrevMoveBox = (x_tl,y_tl,w,h)
dc.EndDrawing()
def OnPaint(self, event):
#dc = wx.BufferedPaintDC(self.DrawPanel, self._Buffer)
dc = wx.PaintDC(self.DrawPanel)
- dc.DrawBitmap(self._Buffer, (0,0))
+ dc.DrawBitmap(self._Buffer, 0,0)
def Draw(self):
"""
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
- ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
+ w,h = self.PanelSize
+ ScreenDC.Blit(0, 0, w,h, dc, 0, 0)
dc.EndDrawing()
else:
dc.Clear()
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
- ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
+ w, h = self.PanelSize
+ ScreenDC.Blit(0, 0, w,h, dc, 0, 0)
dc.EndDrawing()
else: # not using a Background DC
dc = wx.MemoryDC()
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
- ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
+ w, h = self.PanelSize
+ ScreenDC.Blit(0, 0, w, h, dc, 0, 0)
dc.EndDrawing()
else:
dc.Clear()
# now refresh the screen
#ScreenDC.DrawBitmap(self._Buffer,0,0) #NOTE: uisng DrawBitmap didn't work right on MSW
- ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
+ w, h = self.PanelSize
+ ScreenDC.Blit(0, 0, w, h, dc, 0, 0)
# If the canvas is in the middle of a zoom or move, the Rubber Band box needs to be re-drawn
if self.PrevRBBox:
ScreenDC.SetPen(wx.Pen('WHITE', 2,wx.SHORT_DASH))
ScreenDC.SetBrush(wx.TRANSPARENT_BRUSH)
ScreenDC.SetLogicalFunction(wx.XOR)
- ScreenDC.DrawRectangleXY(*self.PrevRBBox)
+ ScreenDC.DrawRectangle(*self.PrevRBBox)
elif self.PrevMoveBox:
ScreenDC.SetPen(wx.Pen('WHITE', 1,))
ScreenDC.SetBrush(wx.TRANSPARENT_BRUSH)
ScreenDC.SetLogicalFunction(wx.XOR)
- ScreenDC.DrawRectangleXY(*self.PrevMoveBox)
+ ScreenDC.DrawRectangle(*self.PrevMoveBox)
if self.Debug: print "Drawing took %f seconds of CPU time"%(clock()-start)
def BBCheck(self, BB1, BB2):
def OnPaint(self,evt):
dc = wx.PaintDC(self)
w,h = self.GetSize()
- dc.DrawBitmap(self.image, (0,0))
+ dc.DrawBitmap(self.image, 0,0)
dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle((0,0), (w,h))
+ dc.DrawRectangle(0,0, w,h)
iPos = self.GetInsertionPos()
- dc.DrawLine((iPos,h - 10), (iPos,h))
+ dc.DrawLine(iPos,h - 10, iPos,h)
def OnPaint(self,evt):
dc = wx.PaintDC(self)
w,h = self.GetSize()
- dc.DrawBitmap(self.image, (0,0))
+ dc.DrawBitmap(self.image, 0,0)
dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle((0,0), (w,h))
+ dc.DrawRectangle(0,0, w,h)
iPos = self.GetInsertionPos()
- dc.DrawLine((w - 10,iPos), (w,iPos))
+ dc.DrawLine(w - 10,iPos, w,iPos)
#----------------------------------------------------------------------------
memdc = wx.MemoryDC()
memdc.SelectObject(bmp)
dc = wx.WindowDC(self.lwin)
- memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
+ memdc.Blit(0,0, rect.width, rect.height, dc, rect.x, rect.y)
memdc.SelectObject(wx.NullBitmap)
return bmp
memdc = wx.MemoryDC()
memdc.SelectObject(bmp)
dc = wx.WindowDC(self.lwin)
- memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
+ memdc.Blit(0,0, rect.width, rect.height, dc, rect.x, rect.y)
memdc.SelectObject(wx.NullBitmap)
return bmp
brush = wx.Brush(wx.NamedColour(self.back_color), wx.SOLID)
dc.SetBrush(brush)
dc.SetPen(wx.Pen(wx.NamedColour(self.border_color), 1))
- dc.DrawRectangle((0, 0), (self.image_sizex, self.image_sizey))
+ dc.DrawRectangle(0, 0, self.image_sizex, self.image_sizey)
def DrawImage(self, dc):
try:
image.Rescale(iwidth, iheight) # rescale to fit the window
image.ConvertToBitmap()
bmp = image.ConvertToBitmap()
- dc.DrawBitmap(bmp, (diffx, diffy)) # draw the image to window
+ dc.DrawBitmap(bmp, diffx, diffy) # draw the image to window
class ImageDialog(wx.Dialog):
# Draw outline
dc.SetPen(highlight)
- dc.DrawLine((0,0), (0,h))
- dc.DrawLine((0,0), (w,0))
+ dc.DrawLine(0,0, 0,h)
+ dc.DrawLine(0,0, w,0)
dc.SetPen(black)
- dc.DrawLine((0,h), (w+1,h))
- dc.DrawLine((w,0), (w,h))
+ dc.DrawLine(0,h, w+1,h)
+ dc.DrawLine(w,0, w,h)
dc.SetPen(shadow)
- dc.DrawLine((w-1,2), (w-1,h))
+ dc.DrawLine(w-1,2, w-1,h)
#----------------------------------------------------------------------
bmp = wx.EmptyBitmap(8,8)
bdc = wx.MemoryDC()
bdc.SelectObject(bmp)
- bdc.DrawRectangle((-1,-1), (10,10))
+ bdc.DrawRectangle(-1,-1, 10,10)
for i in range(8):
for j in range(8):
if ((i + j) & 1):
- bdc.DrawPoint((i,j))
+ bdc.DrawPoint(i,j)
brush = wx.Brush(wx.Colour(0,0,0))
brush.SetStipple(bmp)
h = body_h
if direction == MV_HOR:
- dc.DrawRectangle((x,y-2), (w,4))
+ dc.DrawRectangle(x,y-2, w,4)
else:
- dc.DrawRectangle((x-2,y), (4,h))
+ dc.DrawRectangle(x-2,y, 4,h)
dc.EndDrawingOnTop()
mem_dc.SelectObject(self.GetBuffer())
mem_dc.SetPen(self.GetBackgroundPen())
mem_dc.SetBrush(self.GetBackgroundBrush())
- mem_dc.DrawRectangle((0, 0), (size[0], size[1]))
+ mem_dc.DrawRectangle(0, 0, size[0], size[1])
mem_dc.SetFont(self.tree.GetFont())
self.paintWalk(node, mem_dc)
else:
mem_dc.SelectObject(self.GetBuffer())
xstart, ystart = self.tree.CalcUnscrolledPosition(0,0)
size = self.tree.GetClientSizeTuple()
- dc.Blit((xstart, ystart), (size[0], size[1]), mem_dc, (xstart, ystart))
+ dc.Blit(xstart, ystart, size[0], size[1], mem_dc, xstart, ystart)
else:
if node == self.tree.currentRoot:
self.knobs = []
dc.SetBrush(self.GetBackgroundBrush())
dc.SetFont(self.tree.GetFont())
if paintBackground:
- dc.DrawRectangle((0, 0), (size[0], size[1]))
+ dc.DrawRectangle(0, 0, size[0], size[1])
if node:
#Call with not paintBackground because if we are told not to paint the
#whole background, we have to paint in parts to undo selection coloring.
if (not self.tree.model.IsLeaf(kid.data)) or ((kid.expanded or self.tree._assumeChildren) and len(kid.kids)):
dc.SetPen(self.linepen)
dc.SetBrush(self.bgbrush)
- dc.DrawRectangle((px -4, py-4), (9, 9))
+ dc.DrawRectangle(px -4, py-4, 9, 9)
self.knobs.append( (kid, Rect(px -4, py -4, 9, 9)) )
dc.SetPen(self.textpen)
if not kid.expanded:
- dc.DrawLine((px, py -2), (px, py + 3))
- dc.DrawLine((px -2, py), (px + 3, py))
+ dc.DrawLine(px, py -2, px, py + 3)
+ dc.DrawLine(px -2, py, px + 3, py)
if node == self.tree.currentRoot:
px = (node.projx - self.tree.layout.NODE_STEP) + 5
py = node.projy + node.height/2
dc.SetPen(self.linepen)
dc.SetBrush(self.bgbrush)
- dc.DrawRectangle((px -4, py-4), (9, 9))
+ dc.DrawRectangle(px -4, py-4, 9, 9)
self.knobs.append( (node, Rect(px -4, py -4, 9, 9)) )
dc.SetPen(self.textpen)
if not node.expanded:
- dc.DrawLine((px, py -2), (px, py + 3))
- dc.DrawLine((px -2, py), (px + 3, py))
+ dc.DrawLine(px, py -2, px, py + 3)
+ dc.DrawLine(px -2, py, px + 3, py)
return True
def OnMouse(self, evt):
dc.SetPen(self.painter.GetLinePen())
dc.SetBrush(self.painter.GetForegroundBrush())
dc.SetTextForeground(wx.NamedColour("WHITE"))
- dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
+ dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
else:
if drawRects:
dc.SetBrush(self.painter.GetBackgroundBrush())
dc.SetPen(self.painter.GetBackgroundPen())
- dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
+ dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
dc.SetTextForeground(self.painter.GetTextColour())
- dc.DrawText(text, (node.projx, node.projy))
+ dc.DrawText(text, node.projx, node.projy)
self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
class TreeLinePainter(LinePainter):
py = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -2
cx = child.projx
cy = py
- dc.DrawLine((px, py), (cx, cy))
+ dc.DrawLine(px, py, cx, cy)
else:
px = parent.projx + 5
py = parent.projy + parent.height
cx = child.projx -5
cy = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -3
- dc.DrawLine((px, py), (px, cy))
- dc.DrawLine((px, cy), (cx, cy))
+ dc.DrawLine(px, py, px, cy)
+ dc.DrawLine(px, cy, cx, cy)
#>> Event defs
wxEVT_MVCTREE_BEGIN_EDIT = wx.NewEventType() #Start editing. Vetoable.
dc.SetPen(wx.Pen(wx.BLACK))
dc.SetBrush(wx.Brush( wx.WHITE, wx.TRANSPARENT ) )
dc.SetLogicalFunction(wx.INVERT)
- dc.DrawRectangle( (ptx,pty), (rectWidth,rectHeight))
+ dc.DrawRectangle( ptx,pty, rectWidth,rectHeight)
dc.SetLogicalFunction(wx.COPY)
dc.EndDrawing()
self.theDC = aDC
def DrawLine(self, x1,y1,x2,y2):
- self.theDC.DrawLine((int(x1),int(y1)),(int(x2),int(y2)))
+ self.theDC.DrawLine(int(x1),int(y1), int(x2),int(y2))
def DrawText(self, txt, x, y):
- self.theDC.DrawText(txt, (int(x), int(y)))
+ self.theDC.DrawText(txt, int(x), int(y))
def DrawRotatedText(self, txt, x, y, angle):
- self.theDC.DrawRotatedText(txt, (int(x), int(y)), angle)
+ self.theDC.DrawRotatedText(txt, int(x), int(y), angle)
def SetClippingRegion(self, x, y, width, height):
- self.theDC.SetClippingRegion((int(x), int(y)), (int(width), int(height)))
+ self.theDC.SetClippingRegion(int(x), int(y), int(width), int(height))
def SetDeviceOrigin(self, x, y):
self.theDC.SetDeviceOrigin(int(x), int(y))
else:
dc.SetPen(self.shadowPen)
for i in range(2):
- dc.DrawLine((x1+i, y1), (x1+i, y2-i))
- dc.DrawLine((x1, y1+i), (x2-i, y1+i))
+ dc.DrawLine(x1+i, y1, x1+i, y2-i)
+ dc.DrawLine(x1, y1+i, x2-i, y1+i)
# draw the lower right sides
if self.up:
else:
dc.SetPen(self.highlightPen)
for i in range(2):
- dc.DrawLine((x1+i, y2-i), (x2+1, y2-i))
- dc.DrawLine((x2-i, y1+i), (x2-i, y2))
+ dc.DrawLine(x1+i, y2-i, x2+1, y2-i)
+ dc.DrawLine(x2-i, y1+i, x2-i, y2)
def DrawArrow(self,dc):
w, h = self.GetSize()
mx = w / 2
my = h / 2
dc.SetPen(self.highlightPen)
- dc.DrawLine((mx-5,my-5), (mx+5,my-5))
- dc.DrawLine((mx-5,my-5), (mx,my+5))
+ dc.DrawLine(mx-5,my-5, mx+5,my-5)
+ dc.DrawLine(mx-5,my-5, mx,my+5)
dc.SetPen(self.shadowPen)
- dc.DrawLine((mx+4,my-5), (mx,my+5))
+ dc.DrawLine(mx+4,my-5, mx,my+5)
dc.SetPen(self.blackPen)
- dc.DrawLine((mx+5,my-5), (mx,my+5))
+ dc.DrawLine(mx+5,my-5, mx,my+5)
def OnPaint(self, event):
width, height = self.GetClientSize()
if self.draw == True and txtdraw == True:
test_out = self.TestFull(vout)
if self.align == wx.ALIGN_LEFT:
- self.DC.DrawText(test_out, (self.indent+self.pcell_left_margin, y))
+ self.DC.DrawText(test_out, self.indent+self.pcell_left_margin, y)
elif self.align == wx.ALIGN_CENTRE:
diff = self.GetCellDiff(test_out, self.region)
- self.DC.DrawText(test_out, (self.indent+diff/2, y))
+ self.DC.DrawText(test_out, self.indent+diff/2, y)
elif self.align == wx.ALIGN_RIGHT:
diff = self.GetCellDiff(test_out, self.region)
- self.DC.DrawText(test_out, (self.indent+diff, y))
+ self.DC.DrawText(test_out, self.indent+diff, y)
else:
- self.DC.DrawText(test_out, (self.indent+self.pcell_left_margin, y))
+ self.DC.DrawText(test_out, self.indent+self.pcell_left_margin, y)
text = remain
y = y + self.space
return y - self.space + self.pt_space_after
if self.draw == True and txtdraw == True:
test_out = vout
if align == wx.ALIGN_LEFT:
- self.DC.DrawText(test_out, (indent, y))
+ self.DC.DrawText(test_out, indent, y)
elif align == wx.ALIGN_CENTRE:
diff = self.GetCellDiff(test_out, pagew)
- self.DC.DrawText(test_out, (indent+diff/2, y))
+ self.DC.DrawText(test_out, indent+diff/2, y)
elif align == wx.ALIGN_RIGHT:
diff = self.GetCellDiff(test_out, pagew)
- self.DC.DrawText(test_out, (indent+diff, y))
+ self.DC.DrawText(test_out, indent+diff, y)
else:
- self.DC.DrawText(test_out, (indent, y_out))
+ self.DC.DrawText(test_out, indent, y_out)
text = remain
y = y + y_line
return y - y_line
brush = wx.Brush(colour, wx.SOLID)
self.DC.SetBrush(brush)
height = self.label_space + self.label_pt_space_before + self.label_pt_space_after
- self.DC.DrawRectangle((self.column[0], self.y),
- (self.end_x-self.column[0]+1, height))
+ self.DC.DrawRectangle(self.column[0], self.y,
+ self.end_x-self.column[0]+1, height)
def ColourRowCells(self, height):
if self.draw == False:
start_x = self.column[col]
width = self.column[col+1] - start_x + 2
- self.DC.DrawRectangle((start_x, self.y), (width, height))
+ self.DC.DrawRectangle(start_x, self.y, width, height)
col = col + 1
def PrintRow(self, row_val, draw = True, align = wx.ALIGN_LEFT):
y_out = self.y
# y_out = self.y + self.pt_space_before + self.pt_space_after # adjust for extra spacing
- self.DC.DrawLine((self.column[0], y_out), (self.end_x, y_out))
+ self.DC.DrawLine(self.column[0], y_out, self.end_x, y_out)
def DrawColumns(self):
if self.draw == True:
indent = val
self.DC.SetPen(wx.Pen(colour, size))
- self.DC.DrawLine((indent, self.y_start), (indent, self.y))
+ self.DC.DrawLine(indent, self.y_start, indent, self.y)
col = col + 1
def DrawText(self):
assert row != -1, "Row must be specified"
assert col != -1, "Column must be specified"
- wx.PySizer.AddSpacer(self, (width, height), option, flag, border,
- userData=(row, col, row+rowspan, col+colspan))
+ wx.PySizer.Add(self, (width, height), option, flag, border,
+ userData=(row, col, row+rowspan, col+colspan))
#--------------------------------------------------
def _add( self, size, dim ):
dc.SetTextForeground(fclr)
dc.SetClippingRegion((0, 0), (dcwidth, dcheight))
- dc.DrawText(text, (x, y))
+ dc.DrawText(text, x, y)
if x < 0:
toofat = '...'
markwidth = dc.GetTextExtent(toofat)[0]
dc.SetPen(wx.Pen(dc.GetBackground().GetColour(), 1, wx.SOLID ))
- dc.DrawRectangle((0,0), (markwidth, dcheight))
+ dc.DrawRectangle(0,0, markwidth, dcheight)
dc.SetPen(wx.Pen(wx.RED, 1, wx.SOLID ))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle((1, 1), (dcwidth-2, dcheight-2))
- dc.DrawText(toofat, (1, y))
+ dc.DrawRectangle(1, 1, dcwidth-2, dcheight-2)
+ dc.DrawText(toofat, 1, y)
def OnKillFocus(self, event):
def OnPaint(self, event):
dc = wx.PaintDC(self)
- dc.DrawBitmap(self.bitmap, (0,0), False)
+ dc.DrawBitmap(self.bitmap, 0,0, False)
def OnEraseBG(self, event):
pass
x = width - w
if style & wx.ALIGN_CENTER:
x = (width - w)/2
- dc.DrawText(line, (x, y))
+ dc.DrawText(line, x, y)
y += h
def Draw(self, dc):
- dc.DrawBitmap(self.submaps[self.sequence[self.current]], (0, 0), True)
+ dc.DrawBitmap(self.submaps[self.sequence[self.current]], 0, 0, True)
if self.overlay and self.showOverlay:
- dc.DrawBitmap(self.overlay, (self.overlayX, self.overlayY), True)
+ dc.DrawBitmap(self.overlay, self.overlayX, self.overlayY, True)
if self.label and self.showLabel:
- dc.DrawText(self.label, (self.labelX, self.labelY))
+ dc.DrawText(self.label, self.labelX, self.labelY)
dc.SetTextForeground(wx.WHITE)
- dc.DrawText(self.label, (self.labelX-1, self.labelY-1))
+ dc.DrawText(self.label, self.labelX-1, self.labelY-1)
def OnPaint(self, event):
f(dc, xc, yc, size)
def _circle(self, dc, xc, yc, size=1):
- dc.DrawEllipse((xc-2.5*size,yc-2.5*size), (5.*size,5.*size))
+ dc.DrawEllipse(xc-2.5*size,yc-2.5*size, 5.*size,5.*size)
def _dot(self, dc, xc, yc, size=1):
dc.DrawPoint(xc,yc)
(0.0,0.577350*size*5)],xc,yc)
def _cross(self, dc, xc, yc, size=1):
- dc.DrawLine((xc-2.5*size, yc-2.5*size), (xc+2.5*size,yc+2.5*size))
- dc.DrawLine((xc-2.5*size,yc+2.5*size), (xc+2.5*size,yc-2.5*size))
+ dc.DrawLine(xc-2.5*size, yc-2.5*size, xc+2.5*size,yc+2.5*size)
+ dc.DrawLine(xc-2.5*size,yc+2.5*size, xc+2.5*size,yc-2.5*size)
def _plus(self, dc, xc, yc, size=1):
- dc.DrawLine((xc-2.5*size,yc), (xc+2.5*size,yc))
- dc.DrawLine((xc,yc-2.5*size,xc), (yc+2.5*size))
+ dc.DrawLine(xc-2.5*size,yc, xc+2.5*size,yc)
+ dc.DrawLine(xc,yc-2.5*size,xc, yc+2.5*size)
class PlotGraphics:
for y, d in [(bb1[1], -3), (bb2[1], 3)]:
p1 = scale*Numeric.array([lower, y])+shift
p2 = scale*Numeric.array([upper, y])+shift
- dc.DrawLine((p1[0],p1[1]), (p2[0],p2[1]))
+ dc.DrawLine(p1[0],p1[1], p2[0],p2[1])
for x, label in xticks:
p = scale*Numeric.array([x, y])+shift
- dc.DrawLine((p[0],p[1]), (p[0],p[1]+d))
+ dc.DrawLine(p[0],p[1], p[0],p[1]+d)
if text:
- dc.DrawText(label, (p[0],p[1]))
+ dc.DrawText(label, p[0],p[1])
text = 0
if yaxis is not None:
for x, d in [(bb1[0], -3), (bb2[0], 3)]:
p1 = scale*Numeric.array([x, lower])+shift
p2 = scale*Numeric.array([x, upper])+shift
- dc.DrawLine((p1[0],p1[1]), (p2[0],p2[1]))
+ dc.DrawLine(p1[0],p1[1], p2[0],p2[1])
for y, label in yticks:
p = scale*Numeric.array([x, y])+shift
- dc.DrawLine((p[0],p[1]), (p[0]-d,p[1]))
+ dc.DrawLine(p[0],p[1], p[0]-d,p[1])
if text:
dc.DrawText(label,
- (p[0]-dc.GetTextExtent(label)[0], p[1]-0.5*h))
+ p[0]-dc.GetTextExtent(label)[0], p[1]-0.5*h)
text = 0
def _ticks(self, lower, upper):
wxImageFromStream = wx._core.ImageFromStream
wxImageFromStreamMime = wx._core.ImageFromStreamMime
wxEmptyImage = wx._core.EmptyImage
-wxEmptyImage = wx._core.EmptyImage
wxImageFromBitmap = wx._core.ImageFromBitmap
wxImageFromData = wx._core.ImageFromData
wxImage_CanRead = wx._core.Image_CanRead
wxBrushPtr = wx._gdi.BrushPtr
wxBitmap = wx._gdi.Bitmap
wxBitmapPtr = wx._gdi.BitmapPtr
+wxEmptyBitmap = wx._gdi.EmptyBitmap
wxBitmapFromIcon = wx._gdi.BitmapFromIcon
wxBitmapFromImage = wx._gdi.BitmapFromImage
wxBitmapFromXPMData = wx._gdi.BitmapFromXPMData
wxBitmapFromBits = wx._gdi.BitmapFromBits
-wxEmptyBitmap = wx._gdi.EmptyBitmap
-wxEmptyBitmap = wx._gdi.EmptyBitmap
wxMask = wx._gdi.Mask
wxMaskPtr = wx._gdi.MaskPtr
wxIcon = wx._gdi.Icon
wxTheColourDatabase = wx._gdi.TheColourDatabase
wxEffects = wx._gdi.Effects
wxEffectsPtr = wx._gdi.EffectsPtr
-wxDC_old = wx._gdi.DC_old
-wxMemoryDC_old = wx._gdi.MemoryDC_old
-wxBufferedDC_old = wx._gdi.BufferedDC_old
-wxBufferedPaintDC_old = wx._gdi.BufferedPaintDC_old
-wxScreenDC_old = wx._gdi.ScreenDC_old
-wxClientDC_old = wx._gdi.ClientDC_old
-wxPaintDC_old = wx._gdi.PaintDC_old
-wxWindowDC_old = wx._gdi.WindowDC_old
-wxMirrorDC_old = wx._gdi.MirrorDC_old
-wxPostScriptDC_old = wx._gdi.PostScriptDC_old
-wxMetaFileDC_old = wx._gdi.MetaFileDC_old
-wxPrinterDC_old = wx._gdi.PrinterDC_old
wxMaskColour = wx._gdi.MaskColour
wxPy_isinstance = isinstance
-
-# The wx*DC_old classes have Draw* method signatures that are mostly
-# compatible with 2.4, so assign the new classes to wx*DC_new and make
-# the _old classes be the defaults with the normal names.
-
-wxDC_new = wxDC; wxDC = wxDC_old
-wxMemoryDC_new = wxMemoryDC; wxMemoryDC = wxMemoryDC_old
-wxBufferedDC_new = wxBufferedDC; wxBufferedDC = wxBufferedDC_old
-wxBufferedPaintDC_new = wxBufferedPaintDC; wxBufferedPaintDC = wxBufferedPaintDC_old
-wxScreenDC_new = wxScreenDC; wxScreenDC = wxScreenDC_old
-wxClientDC_new = wxClientDC; wxClientDC = wxClientDC_old
-wxPaintDC_new = wxPaintDC; wxPaintDC = wxPaintDC_old
-wxWindowDC_new = wxWindowDC; wxWindowDC = wxWindowDC_old
-wxMirrorDC_new = wxMirrorDC; wxMirrorDC = wxMirrorDC_old
-wxPostScriptDC_new = wxPostScriptDC; wxPostScriptDC = wxPostScriptDC_old
-wxMetaFileDC_new = wxMetaFileDC; wxMetaFileDC = wxMetaFileDC_old
-wxPrinterDC_new = wxPrinterDC; wxPrinterDC = wxPrinterDC_old
-