GenStaticText
is a generic implementation of wx.StaticText
.
GenStaticText
is a generic implementation of wx.StaticText
.
Some of the platforms supported by wxPython (most notably GTK), do not
consider wx.StaticText
as a separate widget; instead, the label is
just drawn directly on its parent window. This essentially bars the use of
almost all mouse events (such as detection of mouse motions, mouse clicks and
so on) on that widget.
Moreover, these platforms do not allow the developer to change the widget’s background colour.
Using GenStaticText
will overcome all the problems described above,
as it is a generic widget and a real window on its own.
Sample usage:
import wx
import wx.lib.stattext as ST
app = wx.App(0)
frame = wx.Frame(None, -1, "wx.lib.stattext Test")
panel = wx.Panel(frame)
st1 = ST.GenStaticText(panel, -1, "This is an example of static text", (20, 10))
st2 = ST.GenStaticText(panel, -1, "Is this yellow?", (20, 70), (120, -1))
st2.SetBackgroundColour('Yellow')
ST.GenStaticText(panel, -1, "align center", (160, 70), (120, -1), wx.ALIGN_CENTER)
ST.GenStaticText(panel, -1, "align right", (300, 70), (120, -1), wx.ALIGN_RIGHT)
frame.Show()
app.MainLoop()