这是一个python pgm。它包含一个文本控制按钮和一个按钮。请帮我修改,以便在按下按钮时我需要在textctrl中输入的字符串用户存储到变量中。
#! /usr/bin/env python
#Boa:Frame:Frame1
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1, wxID_FRAME1TEXT1,
] = [wx.NewId() for _init_ctrls in range(4)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(249, 224), size=wx.Size(683, 445),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(683, 445))
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(683, 445),
style=wx.TAB_TRAVERSAL)
self.text1 = wx.TextCtrl(id=wxID_FRAME1TEXT1, name=u'text1',
parent=self.panel1, pos=wx.Point(268, 139), size=wx.Size(103, 25),
style=0, value=u'enter')
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label=u'click',
name='button1', parent=self.panel1, pos=wx.Point(279, 272),
size=wx.Size(85, 27), style=0)
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
id=wxID_FRAME1BUTTON1)
def __init__(self, parent):
self._init_ctrls(parent)
def OnButton1Button(self, event):
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()
app.MainLoop()
答案 0 :(得分:4)