[Tutor] \ n in list\ string
mail at mjclift.freeserve.co.uk
Mon Oct 25 18:16:00 CEST 2004
This is partly a wx problem, but I'm not convinced the answer is related to wx hence my posting to this group.
I have been experimenting with the DragImage demo in wx. I'm trying to have a simple word wrap based on the number of items in the l1 list. Someone suggested the 'for i in range' line, but this just alters the y value for the whole text. I think that something like this 'for i in range...' needs to go before the image is drawn. I have also tried putting \ n in the text, which would seem to be the easiest thing to do, but I couldn't get this to work.
# Make a shape from some text
l1 = ['a','b','c','d','a','b','c','d','a','b','c','d','a','b','c','d',]
text = " "+"".join(l1)
bg_colour = wx.Colour(57, 115, 57) # matches the bg image
font = wx.Font(36, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Arial")
textExtent = self.GetFullTextExtent(text, font)
# create a bitmap the same size as our text
bmp = wx.EmptyBitmap(textExtent, textExtent)
# 'draw' the text onto the bitmap
dc = wx.MemoryDC()
dc.DrawText(text, 0, 0)
mask = wx.Mask(bmp, bg_colour)
shape = DragShape(bmp)
for i in range(len(text)):
shape.pos = (145, 170 + (i//12)*100)
shape.text = "Some dragging text"
Thanks for any help,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor