使用StaticText类输出Python之禅
import wx
class MyFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,title="创建StaticText类",pos=(100,100),size=(500,900))
panel=wx.Panel(self)
title=wx.StaticText(panel,label='Python之禅——Tim Peters',pos=(100,10))
font=wx.Font(16,wx.DEFAULT,wx.FONTSTYLE_NORMAL,wx.NORMAL)
title.SetFont(font)
wx.StaticText(panel,label='Beautiful is better than ugly.',pos=(50,50))
wx.StaticText(panel, label='优美胜于丑陋.', pos=(50, 70))
wx.StaticText(panel, label='Explicit is better than implicit.', pos=(50, 90))
wx.StaticText(panel, label='明了胜于晦涩', pos=(50, 110))
wx.StaticText(panel, label='Simple is better than complex.', pos=(50, 130))
wx.StaticText(panel, label='简洁胜于复杂', pos=(50, 150))
wx.StaticText(panel, label='Complex is better than complicated.', pos=(50, 170))
wx.StaticText(panel, label='复杂胜于凌乱', pos=(50, 190))
wx.StaticText(panel, label='Flat is better than nested.', pos=(50, 210))
wx.StaticText(panel, label='扁平胜于嵌套', pos=(50, 230))
wx.StaticText(panel, label='Sparse is better than dense.', pos=(50, 250))
wx.StaticText(panel, label='间隔胜于紧凑', pos=(50, 270))
wx.StaticText(panel, label='Readability counts.', pos=(50, 290))
wx.StaticText(panel, label='可读性很重要', pos=(50, 310))
wx.StaticText(panel, label="Special cases aren't special enough to break the rules.", pos=(50, 330))
wx.StaticText(panel, label='即便假借特例的实用性之名,也不可违背这些规则', pos=(50, 350))
wx.StaticText(panel, label='Although practicality beats purity.', pos=(50, 370))
wx.StaticText(panel, label='不要包容所有错误,除非你确定需要这样做', pos=(50, 390))
wx.StaticText(panel, label='Errors should never pass silently.', pos=(50, 410))
wx.StaticText(panel, label='所有错误都不应该被直接忽略,除非能够被精确的捕获之后', pos=(50, 430))
wx.StaticText(panel, label='Unless explicitly silenced.', pos=(50, 450))
wx.StaticText(panel, label='除非能够被精确的捕获', pos=(50, 470))
wx.StaticText(panel, label='In the face of ambiguity, refuse the temptation to guess.', pos=(50, 490))
wx.StaticText(panel, label='当面对不明确的情况时,不要尝试去猜测', pos=(50, 510))
wx.StaticText(panel, label="There should be one-- and preferably only one --obvious way to do it.", pos=(50, 530))
wx.StaticText(panel, label='而是尽量找一种,最好是唯一一种明显的解决方案', pos=(50, 550))
wx.StaticText(panel, label="Although that way may not be obvious at first unless you're Dutch.", pos=(50, 570))
wx.StaticText(panel, label='虽然起初这并不那么显而易见,因为你不是 Python 之父', pos=(50, 590))
wx.StaticText(panel, label='Now is better than never.', pos=(50, 610))
wx.StaticText(panel, label='做也许好过不做', pos=(50, 630))
wx.StaticText(panel, label='Although never is often better than right now.', pos=(50, 650))
wx.StaticText(panel, label='但是不假思索就动手还不如不做', pos=(50, 670))
wx.StaticText(panel, label="If the implementation is hard to explain, it's a bad idea.", pos=(50, 690))
wx.StaticText(panel, label='如果你的实现很难向别人解释,这往往不是一个好的方案', pos=(50, 710))
wx.StaticText(panel, label='If the implementation is easy to explain, it may be a good idea.', pos=(50, 730))
wx.StaticText(panel, label='如果你的实现很容易向别人解释,这可能是个好的方案', pos=(50, 750))
wx.StaticText(panel, label="Namespaces are one honking great idea -- let's do more of those!", pos=(50, 770))
wx.StaticText(panel, label='命名空间是一种绝妙的理念,我们应当多加利用', pos=(50, 790))
if __name__=='__main__':
app = wx.App()
frame = MyFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()
代码效果 :