IronPython - Transparent Label 2 Permalink

A little while ago I blogged a little bit of code to create a transparent label control for IronPython. I reused it recently and realised that it did not work too well if the text was changed. Here is the updated version, possibly a bit wasteful but works fine for the current application.

Update : I've seen a few funnies with this version. Use with care! Cool

class TransLabel(Control):
    def __init__(self):
        self.Font = Font("Microsoft Sans Serif", 32)

    def CreateParams(self):
        cp = Label().CreateParams
        cp.ExStyle = cp.ExStyle | 0x20
        return cp
    CreateParams = property(fget=CreateParams)

    def OnPaintBackground(self,e):
        pass

    def OnPaint(self,e):
        grfx = e.Graphics
        grfx.DrawString(self.Text, self.Font, Brushes.Black, 0, 0)

    def SetText(self,Text):
        self.Parent.Invalidate()
        self.Parent.Update()
        self.Text = Text
        self.Invalidate()
        self.Update()

Posted by Davy Mitchell on 2007-08-10 13:26:12.
Categories: Python, IronPython
Like this post? Digg it or Del.icio.us it. |



Films Permalink

Perhaps watching films with children changes the way you look at them or my suspended disbelief is getting harder to maintain. Today I was really annoyed about the bunch of adventurers who visited the forest moon in camouflaged uniforms on a critical mission to get the bad guys... BUT yes let's take the shiny gold robot without a spot of mud on him to dampen the shine. I am glad I got that off my chest. Thank you.

Posted by Davy Mitchell on 2007-08-06 22:42:53.
Categories: Fun, General, Personal Tags :
Like this post? Digg it or Del.icio.us it. |




Locations of visitors to this page