专题教程:wxpython中文教程
wx.StaticText 部件显示一行或多行的只读文本.
wx.StaticText 的样式有:
例子:
#!/usr/bin/python
#coding=utf-8
#statictext.py
# www.plcxue.com
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.Size(400, 350))
lyrics1 = '''I'm giving up the ghost of love
in the shadows cast on devotion
She is the one that I adore
creed of my silent suffocation
break this bittersweet spell on me
lost in the arms of destiny'''
lyrics2 = '''There is something in the way
You're always somewhere else
Feelings have deserted me
To a point of no return
I don't believe in God
But I pray for you'''
panel = wx.Panel(self, -1)
wx.StaticText(panel, -1, lyrics1, (45, 25), style=wx.ALIGN_LEFT)
wx.StaticText(panel, -1, lyrics2, (45, 190), style=wx.ALIGN_CENTER)
self.Center()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'statictext.py')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
如图:
图:statictext.py