# wx position of items in list

M. Clift noone at here.com
Mon Oct 25 17:36:25 CEST 2004

```Hi Cliff,

Thankyou for your help. I know that you can't divide a string by an integer
and true to form I didn't check with 'print' to see what was going on.
Yesterday I tried len, but without the range attached...

Looking at demos and examples it is easy (most of the time) to see how
things work. It is another thing to be creative and cook up some code (even
the most basic) when you are trying to run before you can walk. I do need to
just play around with loads of basic stuff, but like a child in a sweet shop
I get carried away. Saying that I do think that it is sometimes easier to
learn by applying all the help I can get to problems for my project. Getting
something to work for some problem of your own is less dry than some
tutorial example and seems to spot-light.the language.

But before I go to look up some more tutorials I would like to ask something
else
regarding this problem. I can see how  this works, but what it does is to
move the
whole text to the new position. Basically I was hoping for a simplified word
wrap.
This is the code (slightly altered) from the wx DragImage demo that I'm
using.

# 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[0], textExtent[1])

# 'draw' the text onto the bitmap
dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.SetBackground(wx.Brush(bg_colour, wx.SOLID))
dc.Clear()
dc.SetTextForeground(wx.RED)
dc.SetFont(font)
dc.DrawText(text, 0, 0)
dc.SelectObject(wx.NullBitmap)
shape = DragShape(bmp)
for i in range(len(text)):
shape.pos = (145, 170 + (i//12)*100)
shape.text = "Some dragging text"
self.shapes.append(shape)

I think that I need to have something further back in the code, before,
the text is drawn. I've tried  \ n in the text, but I can't get that to
work.
Any ideas?

Thanks for your time and patience,

Malcolm

```