Python 학습 노트(wx:인터페이스 미화)

준비
자료
응용
준비 하 다.
다운로드:python wx.다운로드 주소:http://www.wxpython.org/
http://www.360doc.com/content/13/0204/13/3046928_264181084.shtml
자료.
wx 의 응용 은 다음 과 같다.
http://lihf198628.blog.163.com/blog/static/1138145201122102452894/ http://justcoding.iteye.com/blog/904219
활용 단어 참조
Python之学习笔记(wx:界面美化)_第1张图片
Python之学习笔记(wx:界面美化)_第2张图片
Python之学习笔记(wx:界面美化)_第3张图片
부분 코드:
import wx
import socket
import thread
from keyboard import *

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Nao Presentation", size = (290, 160))
        self.initUI()
        self.Centre()
        self.Show()

    def initUI(self):
        self.panel = wx.Panel(self, -1)
        vbox = wx.BoxSizer(wx.VERTICAL)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)

        self.ip = socket.gethostbyname(socket.gethostname())
        iptext = wx.StaticText(self.panel,label='  IP address:  ')
        hbox1.Add(iptext, flag=wx.RIGHT, border=8)
        tc = wx.TextCtrl(self.panel, value=self.ip, style=wx.TE_READONLY)
        hbox1.Add(tc, proportion=1)
        vbox.Add(hbox1,flag=wx.LEFT|wx.RIGHT|wx.TOP,border=10)
        vbox.Add((-1, 10))

        iptext2 = wx.StaticText(self.panel, label='Port address: ')
        hbox2.Add(iptext2, flag=wx.RIGHT, border=8)
        self.porttext = wx.TextCtrl(self.panel, value="1990")
        hbox2.Add(self.porttext, proportion=1)
        vbox.Add(hbox2,flag=wx.LEFT|wx.RIGHT|wx.TOP,border=10)

        btnstart = wx.Button(self.panel, -1, "Start")
        self.Bind(wx.EVT_BUTTON, self.OnStart, btnstart)
        btnstart.SetDefault()
        vbox.Add(btnstart, 0, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT|wx.RIGHT|wx.TOP, border=10)

        self.panel.SetSizer(vbox)

    def OnStart(self, event):
        self.port = int(self.porttext.GetValue())
        wx.MessageBox("Server is ready for Nao :)", "Hint")

        self.panel.Destroy()
        #self.panel2 = wx.Panel(self, -1, pos=(60, 60), size=(140, 20))

        self.panel2 = wx.Panel(self, -1, pos=(0, 0), size=(290, 160))

        pic = wx.Image('naopre2.bmp', wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        btnpic = wx.BitmapButton(self.panel2, -1, pic, pos=(0,0))
        btnpic.SetDefault()

        thread.start_new_thread(self.TCPServer, ())

좋은 웹페이지 즐겨찾기