界面实例1

1.首先先介绍一款工具(亿图图示专家)

   作为一个开发人员,我们都知道,在写代码之前,我们得先把界面草图绘制出画,通过凭空想像是万万不行的,如果你不想通过笔在草稿纸上画,那我们可以使用"亿图图示专家"这款软件来绘制草图,对于这个软件的使用,大家可以去百度,软件功能很强大,可以绘制各种流程图

   绘制草图如下:

 

 

2.接下来可以用代码实现上面的界面

# coding: utf-8
import wx
import os
import sys
from itertools import *

class SocialTool(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,size=(450,350))
        self.InitUI()
        self.Centre()

    def InitUI(self):
        panel=wx.Panel(self,-1)
        panel.SetBackgroundColour('gray')
        hbox=wx.BoxSizer(wx.HORIZONTAL)
        fg=wx.FlexGridSizer(7,2,9,25)
        self.name=wx.StaticText(panel,label=u'姓  名:')
        self.birth=wx.StaticText(panel,label=u'生  日:')
        self.phone=wx.StaticText(panel,label=u'手  机:')
        self.id=wx.StaticText(panel,label=u'身份证:')
        self.company=wx.StaticText(panel,label=u'公司名:')
        self.qq=wx.StaticText(panel,label=u'Q   Q:')
        self.other=wx.StaticText(panel,label=u'其  它:')

        self.tc1=wx.TextCtrl(panel)
        self.tc2=wx.TextCtrl(panel)
        self.tc3=wx.TextCtrl(panel)
        self.tc4=wx.TextCtrl(panel)
        self.tc5=wx.TextCtrl(panel)
        self.tc6=wx.TextCtrl(panel)
        self.tc7=wx.TextCtrl(panel)
        fg.AddMany([(self.name),(self.tc1,1,wx.EXPAND),
                    (self.birth),(self.tc2,1,wx.EXPAND),
                    (self.phone),(self.tc3,1,wx.EXPAND),
                    (self.id),(self.tc4,1,wx.EXPAND),
                    (self.company),(self.tc5,1,wx.EXPAND),
                    (self.qq),(self.tc6,1,wx.EXPAND),
                    (self.other),(self.tc7,1,wx.EXPAND),
                    ])

        fg.AddGrowableCol(1,1)
        hbox.Add(fg,proportion=1,flag=wx.ALL|wx.EXPAND,border=15)
        panel.SetSizer(hbox)
        wx.Button(panel,201,u'生  成',(90,260),(70,28))
        wx.Button(panel,202,u'取  消',(290,260),(70,28))

        wx.EVT_BUTTON(self,201,self.onSave)

    def onProDic(self,file_name):
        nv=self.tc1.GetValue()
        bv=self.tc2.GetValue()
        pv=self.tc3.GetValue()
        idv=self.tc4.GetValue()
        cv=self.tc5.GetValue()
        qv=self.tc6.GetValue()
        ov=self.tc7.GetValue()
        li=[nv,bv,pv,idv,cv,qv,ov]
        f=open(file_name,'w+')
        for i in list(product(li,repeat=7)):
            f.write(i)
        f.flush()
        f.close()




    def onSave(self,event):
        file_wildcard="Paint files(*.txt)|*.txt|All files(*.*)|*.*"
        dlg=wx.FileDialog(self,
                          u'另存为',
                          os.getcwd(),
                          style=wx.SAVE|wx.OVERWRITE_PROMPT,
                          wildcard=file_wildcard
                          )
        if dlg.ShowModal()==wx.ID_OK:
            filename=dlg.GetPath()
            print filename
            self.onProDic(filename)
        dlg.Destroy()




if __name__=='__main__':
    app=wx.App()
    frame=SocialTool(None,-1,u'字典生成器1.0')
    frame.Show()
    app.MainLoop()
View Code

3.效果

posted @ 2016-03-26 12:07  kennyhip  阅读(138)  评论(0)    收藏  举报