您的位置:首页 > 编程语言 > Python开发

Python GUI编程——wxPython学习(1)

2014-07-03 22:14 555 查看
静态文本显示:

# -*- coding: cp936 -*-
# stxt.py

"""
stxt.py 2014/7/3 简单静态文本显示
"""

import wx

class StaticTextFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Static Text Example',size=(400, 800))

panel = wx.Panel(self,-1)

self.textlabel = [#"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)"]
styles = {"默认样式":0,
"wxALIGN_LEFT":wx.ALIGN_LEFT,
"wxALIGN_RIGHT":wx.ALIGN_RIGHT,
"wxALIGN_CENTRE_HORIZONTAL":wx.ALIGN_CENTRE_HORIZONTAL,
"wxST_NO_AUTORESIZE":wx.ST_NO_AUTORESIZE,
"wxST_ELLIPSIZE_START":wx.ST_ELLIPSIZE_START,
"wxST_ELLIPSIZE_MIDDLE":wx.ST_ELLIPSIZE_MIDDLE,
"wxST_ELLIPSIZE_END":wx.ST_ELLIPSIZE_END}
i=0
for stylename in styles.keys():
st = wx.StaticText(self,-1,stylename,pos=(10,20+i*30))
st.SetForegroundColour("blue")
for tb in self.textlabel:
i=i+1
wx.StaticText(self,-1,tb,pos=(10,20+i*30),style=0 | styles[stylename],size=(300,30))
i=i+1

def main():
app=wx.App()
Frame=StaticTextFrame()
Frame.SetBackgroundColour("white") #设置背景颜色
Frame.Show()
app.MainLoop()

if __name__=="__main__":
main()


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: