#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()
时间: 2024-10-16 10:40:00