wxpython基本控件-靜態文本控件

#coding=utf-8
import wx
class StaticTextFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,None,-1,'Static Text Example',size=(400,300))
        panel = wx.Panel(self,-1)
        #靜態文本 前景色和背景色的靜態文本
        wx.StaticText(panel,-1,"This is an example of static text",(100,10))
        rev = wx.StaticText(panel,-1,'Static Text With Reversed Colors',(100,30))
        rev.SetForegroundColour('white')
        rev.SetBackgroundColour('black')
        #居中的文本
        center = wx.StaticText(panel,-1,'align center',(100,50),(160,-1),wx.ALIGN_CENTER)
        #指定新字體的靜態文本
        str = "you can also change the font"
        text = wx.StaticText(panel,-1,str,(20,100))
        font = wx.Font(18,wx.DECORATIVE,wx.ITALIC,wx.NORMAL)
        text.SetFont(font)
        #顯示多行文本 tyle=wx.ALIGN_RIGHT 爲對齊
        wx.StaticText(panel,-1,'multi-line text \n can also \n be right aligned \n \n even with a blank',(220,150),style=wx.ALIGN_RIGHT)
        
        
app = wx.PySimpleApp()
StaticTextFrame().Show()
app.MainLoop()


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章