text - wxpython: StaticText on transparent background -
I am trying to create a subclass of wx.StaticText
that does not have a background I tried to set the alpha component of background with SetBackgroundColor
, or with no luck using SetTransparent
on different objects, but maybe it only Because I'm a noobie :)
Anyway, I ended up subclassing wx.StaticText
, modify the OnPaint
method Received to no background paint, and EVT_PAINT
to force new method.
It works very well most of the time (when the application starts or is repainted after it is hidden from any other window), but whenever I use SetLabel
On a method of my subclass of method static text
, this is not my OnPaint
method that is said to refresh the window, and I default gray background Ends with.
Below is a "small" work example, it shows the text with the background for the first time, wait 1.5 seconds, and then changes the label of the text, which also paints the background. (And does not call my homemade painting method).
import wx, time class MyStaticText (wx.StaticText): def __init __ (self, guardian, id, label, position = wx.DefaultPosition, size = wx.DefaultSize, style = 0) : Wx.StaticText .__ init __ (self, guardian, id, label, position, size, style) self Bund (wx.EVT_PAINT, self.OnPaint) Def OnPant (self, incident): DC = wx.PaintDC (self) dc.DrawText ('Test 3', 40, 0) Class MyFrame (wx.Frame): def __init __ (Self, width = 150, height = 80): wx.frame .__ init __ (self, none, size = (width, height)) self.test_text = Mystatic text (self, -1, 'test1' Size = wx.Size (width, height)) self. Show () self. Timer = wx.Timer (self, -1) self Timer Start (1500) self Bine (wx.EVT_TIMER, self- antimatter) Def Ointime er (self, incident): self.test_text.SetLabel ('Test2') app = wx.App () myFrame () app.MainLoop ()
< / Pre>I think I'm just missing something, but my understanding of wxpython is not enough to find out. If someone can understand me then it would be greatly appreciated :) And if there is an easy way to text with any background in wxpython, then it would be great.
Thank you in advance!
Comments
Post a Comment