Reverted to old method names/signatures for wx.DC, updated lib and

demo to match.  Also fixed some deprecation warnings.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27049 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-05-02 02:41:33 +00:00
parent 019fd9d379
commit d7403ad2d1
61 changed files with 536 additions and 702 deletions

View File

@@ -155,7 +155,7 @@ class TestPanel(wx.Panel):
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)

View File

@@ -19,14 +19,14 @@ class TestPanel(wx.Panel):
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),

View File

@@ -73,7 +73,7 @@ class TestWindow(wx.ScrolledWindow):
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
@@ -121,13 +121,12 @@ class TestWindow(wx.ScrolledWindow):
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()

View File

@@ -109,7 +109,8 @@ class TestPanel(wx.Panel):
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)
#----------------------------------------------------------------------

View File

@@ -69,7 +69,7 @@ class DoodlePad(wx.Window):
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()

View File

@@ -25,9 +25,9 @@ class DragShape:
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:
@@ -73,9 +73,9 @@ class DragCanvas(wx.ScrolledWindow):
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)
@@ -122,7 +122,7 @@ class DragCanvas(wx.ScrolledWindow):
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

@@ -22,12 +22,12 @@ class TestPanel(wx.Panel):
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):
@@ -39,8 +39,10 @@ class TestPanel(wx.Panel):
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):

View File

@@ -26,8 +26,8 @@ You can get it at:
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()
@@ -369,8 +369,8 @@ else:
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))
@@ -438,8 +438,8 @@ else:
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))

View File

@@ -67,11 +67,11 @@ class TestPanel(wx.Panel):
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()
@@ -86,11 +86,11 @@ class TestPanel(wx.Panel):
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)
@@ -101,11 +101,11 @@ class TestPanel(wx.Panel):
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)

View File

@@ -26,7 +26,7 @@ class MyCustomRenderer(gridlib.PyGridCellRenderer):
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:

View File

@@ -219,7 +219,6 @@ class MegaImageRenderer(Grid.PyGridCellRenderer):
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()
@@ -230,9 +229,9 @@ class MegaImageRenderer(Grid.PyGridCellRenderer):
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):
@@ -265,8 +264,6 @@ 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)
@@ -281,7 +278,7 @@ class MegaFontRenderer(Grid.PyGridCellRenderer):
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 "..."
@@ -293,8 +290,8 @@ class MegaFontRenderer(Grid.PyGridCellRenderer):
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()

View File

@@ -22,21 +22,21 @@ class TestPanel(wx.Panel):
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)

View File

@@ -47,7 +47,7 @@ class TestPanel( wx.Panel ):
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 )

View File

@@ -95,18 +95,18 @@ class JoyGauge(wx.Panel):
# 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
@@ -239,14 +239,14 @@ class POVGauge(wx.Panel):
# 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:
@@ -284,11 +284,11 @@ class POVGauge(wx.Panel):
# 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()
@@ -462,7 +462,7 @@ class LED(wx.Panel):
else:
dc.SetBrush(wx.Brush(wx.BLACK))
dc.DrawCircle((center, center), bw/2)
dc.DrawCircle(center, center, bw/2)
txt = str(self.number)
@@ -483,7 +483,7 @@ class LED(wx.Panel):
# 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()
@@ -709,10 +709,10 @@ class AxisBar(wx.Gauge):
# 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)
#----------------------------------------------------------------------------

View File

@@ -66,7 +66,7 @@ class MyParentFrame(wx.MDIParentFrame):
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

@@ -221,7 +221,7 @@ _treeList = [
]),
# need libs not coming with the demo
('Objects using an external library', [
('Samples using an external library', [
'GLCanvas',
]),

View File

@@ -49,7 +49,7 @@ class TestMaskWindow(wx.ScrolledWindow):
# 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)
@@ -66,17 +66,17 @@ class TestMaskWindow(wx.ScrolledWindow):
# 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()
@@ -86,9 +86,9 @@ class TestMaskWindow(wx.ScrolledWindow):
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

View File

@@ -5,8 +5,9 @@ import wx
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()
@@ -15,16 +16,14 @@ def runTest(frame, nb, log):
overview = """\
This class represents a dialog that shows a single or multi-line message, with a
choice of OK, Yes, No and Cancel buttons.
<html><body>
<h2>wx.MessageDialog</h2>
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.
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.
"""

View File

@@ -214,7 +214,7 @@ class TestWindow(ogl.ShapeCanvas):
)
bmp = images.getTest2Bitmap()
mask = wx.MaskColour(bmp, wx.BLUE)
mask = wx.Mask(bmp, wx.BLUE)
bmp.SetMask(mask)
s = ogl.BitmapShape()

View File

@@ -84,7 +84,7 @@ class MyPrintout(wx.Printout):
#-------------------------------------------
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

View File

@@ -30,11 +30,11 @@ class TestPanel( wx.Panel ):
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 )
@@ -53,11 +53,11 @@ class TestPanel( wx.Panel ):
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 )

View File

@@ -84,7 +84,7 @@ class TestPanel(scrolled.ScrolledPanel):
vbox2.Add((20, 10))
hbox.Add(vbox2)
vbox.AddSizer(hbox, 0)
vbox.Add(hbox, 0)
self.SetSizer(vbox)
self.SetAutoLayout(1)
self.SetupScrolling()

View File

@@ -20,7 +20,7 @@ class MyCanvas(wx.ScrolledWindow):
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
@@ -65,19 +65,19 @@ class MyCanvas(wx.ScrolledWindow):
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)
@@ -86,13 +86,13 @@ class MyCanvas(wx.ScrolledWindow):
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)
@@ -100,15 +100,15 @@ class MyCanvas(wx.ScrolledWindow):
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,
@@ -123,18 +123,18 @@ class MyCanvas(wx.ScrolledWindow):
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()
@@ -178,9 +178,9 @@ class MyCanvas(wx.ScrolledWindow):
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()

View File

@@ -44,7 +44,7 @@ class TestFrame(wx.Frame):
self.SetWindowShape()
dc = wx.ClientDC(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(wx.Frame):
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()

View File

@@ -43,7 +43,7 @@ class SampleWindow(wx.PyWindow):
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()

View File

@@ -73,13 +73,13 @@ class TestValueWindow(gizmos.TreeCompanionWindow):
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)

View File

@@ -13,7 +13,7 @@ class TestPanel(wx.Panel):
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()))

View File

@@ -1,35 +1,43 @@
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)
#---------------------------------------------------------------------------

View File

@@ -97,18 +97,18 @@ class GraphWindow(wx.Window):
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:
@@ -127,7 +127,7 @@ class GraphWindow(wx.Window):
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)

View File

@@ -117,7 +117,8 @@ command_lines = [
]
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)