wxPythonの使い方

だんだんわかってきた。

#!/usr/bin/env python
#-*- coding:utf-8 -*-

import wx
import os
import commands

class MyFrame(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title,wx.DefaultPosition,wx.DefaultSize)
        lyrics2 = ''' push the button1 please '''
        panel = wx.Panel(self,-1)
        box = wx.BoxSizer(wx.HORIZONTAL)
        btn1 = wx.Button(panel,1,'Button1')
        box.Add(btn1, 1,wx.ALL,15)
        box.Add(wx.Button(panel, 2, 'Button2'), 1,wx.ALL,15)
        box.Add(wx.Button(panel, 3, 'Button3'), 1,wx.ALL,15)
        panel.SetSizer(box)

        printer_names = self.getPrinters()
        combo = wx.ComboBox(panel, 4,pos=(50,170),size=wx.DefaultSize, choices=printer_names, style=wx.CB_READONLY)

        self.text1 = wx.StaticText(panel,-1,lyrics2, (45,100),style=wx.ALIGN_CENTRE)
        self.Centre()
        self.Bind(wx.EVT_BUTTON,self.OnButton1,id=1)
        self.Bind(wx.EVT_BUTTON,self.OnButton2,id=2)
        self.Bind(wx.EVT_BUTTON,self.OnButton3,id=3)

    def getPrinters(self):
        status, output = commands.getstatusoutput("lpstat -s")
        printers = output.split("\n")
        printer_names = [printer.split("device for")[1].split(":")[0].strip() for printer in printers if "device for" in printer]        
        return printer_names

    def OnButton1(self,event):
        self.text1.SetLabel("button1 was pushed")

    def OnButton2(self,event):
        self.text1.SetLabel("button2 was pushed")

    def OnButton3(self,event):
        self.text1.SetLabel("button3 was pushed")
        
    def OnClose(self,event):
        return True
    

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None,-1,"hoge")
        frame.Show()
        return True

app = MyApp(0)
app.MainLoop()