Re: wx position of items in list

From: M. Clift (noone_at_here.com)
Date: 10/25/04


Date: Mon, 25 Oct 2004 16:36:25 +0100

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)
        mask = wx.Mask(bmp, bg_colour)
        bmp.SetMask(mask)
        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



Relevant Pages

  • Re: Insert values into Table
    ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... string in code, and let me ask you a question as well. ... Is this column a date data type or a text string? ...
    (microsoft.public.access.modulesdaovba)
  • Re: Identifier expected error.
    ... return a String. ... do as Lew suggests and read the tutorials. ... University of Leicester, Leicester, LE1 7RH, UK ...
    (comp.lang.java.help)
  • Re: Horribly noobful string question
    ... I have all the noobie confused questions, but as I work thru the tutorials I'm sure I'll find most my answers. ... enters a string value instead of a int value. ... and they can be changed to an int equivalent, but I just want the script to ...
    (comp.lang.python)
  • Re: int to string - without using stringstream.
    ... >> string. ... but I continually read newsgroups and read a couple ... of tutorials here and there. ... loop, and in basically every loop - but that is neither here nor there. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: How do I set up multiple values in a pie chart
    ... Tutorials and Custom Solutions ... Peltier Technical Services, Inc. - http://PeltierTech.com ... Then divide the 25% section like this; ...
    (microsoft.public.excel.charting)