学python的第十二天

今天学习了常用的控件
StaticText文本类:
对于所有的UI工具来说,最基本的任务就是在屏幕上绘制纯文本。在wxPython中,可以使用wx.StaticText类完成。使用wx.StaticText能够改变文本的对齐方式,字体和颜色等。wx.StaticText类的构造函数的语法如下:

wx.StaticText(parent,id,label,pos=wx.DefaultPosition,size=wx.DefaultSize,
				style=0,name="staticText")
参数说明
parent父窗口部件
id标识符。使用-1可以自动创建一个唯一的标识
label显示在静态控件中的文本内容
pos一个wx.Point或一个Python元组,它是窗口部件的位置
size一个wx.Size或一个Python元组,它是窗口部件的尺寸
style样式标记
name对象的名字

事例:
用wx.StaticText输出Python之禅

import wx
class one(wx.Frame):
    def __init__(self,parent,id):
        wx.frame.__init__(self,parent,id,label='Python',pos=(100,100),size=(600,400))
        panel=wx.Panel(self)        #创建画板
        #创建标题,并设置字体
        title=wx.StaticText(panel,label='The Zen of Python, by Tim Peters',pos=(100,20))
        font=wx.Font(16,wx.DEFAULT,wx.FONTSTYLE_NORMAL,wx.NORMAL)
        title.SetFont(font)
        #创建文本
        wx.StaricText(panel, label='Beautiful is better than ugly.',pos=(50,50))
        wx.StaricText(panel, label='Explicit is better than implicit.',pos=(50,70))
        wx.StaricText(panel, label='Simple is better than complex.',pos=(50,90))
        wx.StaricText(panel, label='Complex is better than complicated.',pos=(50,110))
        wx.StaricText(panel, label='Flat is better than nested.',pos=(50,130))
        wx.StaricText(panel, label='Sparse is better than dense.',pos=(50,150))
        wx.StaricText(panel, label='Readability counts.',pos=(50,170))
        wx.StaricText(panel, label='Special cases are not special enough to break the rules.',pos=(50,190))
        wx.StaricText(panel, label='Although practicality beats purity.',pos=(50,210))
        wx.StaricText(panel, label='Errors should never pass silently.',pos=(50,230))
        wx.StaricText(panel, label='Unless explicitly silenced.',pos=(50,250))
        wx.StaricText(panel, label='In the face of ambiguity, refuse the temptation to guess.',pos=(50,270))
        wx.StaricText(panel, label='There should be one-- and preferably only one --obvious way to do it.',pos=(50,290))
        wx.StaricText(panel, label='Although that way may not be obvious at first unless you are Dutch.',pos=(50,310))
        wx.StaricText(panel, label='Now is better than never.',pos=(50,330))
        wx.StaricText(panel, label='Although never is often better than *right* now.',pos=(50,350))
        wx.StaricText(panel, label='If the implementation is hard to explain, it is a bad idea.',pos=(50,370))
        wx.StaricText(panel, label='If the implementation is easy to explain, it may be a good idea.',pos=(50,390))
        wx.StaricText(panel, label='Namespaces are one honking great idea -- let us do more of those!',pos=(50,410))

if __name__=='__main__':
    app=wx.App()            #初始化应用
    frame=one(parent=None,id=-1)
    frame.Show()
    app.MainLoop()

但是这个好像不能输出结果。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值