从 TextCtrl 框中获取字符串

发布于 2024-08-18 01:27:37 字数 2294 浏览 6 评论 0原文

如何从 TextCtrl 框中获取字符串?下面是练习代码:

import wx



class citPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)


        wx.StaticText(self, -1, "Choose put you would like:", (45, 15))

        self.quote = wx.StaticText(self, -1, "1:", wx.Point(275, 180), wx.Size(200, -1))
        self.quote = wx.StaticText(self, -1, "2:", wx.Point(275, 230), wx.Size(200, -1))
        self.quote = wx.StaticText(self, -1, "3:", wx.Point(275, 280), wx.Size(200, -1))




class nextButton(wx.Button):
    def __init__(self, parent, id, label, pos):
        wx.Button.__init__(self, parent, id, label, pos)

class cancelButton(wx.Button):
    def __init__(self, parent, id, label, pos):
        wx.Button.__init__(self, parent, id, label, pos)

class searchBox(wx.TextCtrl):
def __init__(self, parent, id, name, pos):
    wx.TextCtrl.__init__(self, parent, id, name, pos)



class minBox(wx.TextCtrl):
    def __init__(self, parent, id, name, pos):
        wx.TextCtrl.__init__(self, parent, id, name, pos)

class maxBox(wx.TextCtrl):
    def __init__(self, parent, id, name, pos):
        wx.TextCtrl.__init__(self, parent, id, name, pos)


class checkList(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 600))

        self.panel = citPanel(self, -1)

        self.searchCtrl = searchBox(self.panel, -1, '', (275, 200))
        self.Bind(wx.EVT_TEXT, self.EvtText)
        self.minCtrl = minBox(self.panel, -1, '', (275, 250))
        self.Bind(wx.EVT_TEXT, self.EvtText1)
        self.maxCtrl = maxBox(self.panel, -1, '', (275, 300))
        self.Bind(wx.EVT_TEXT, self.EvtText2)
        nextButton(self.panel, 30, 'Ok', (275, 50))
        cancelButton(self.panel, -1, 'Exit', (275, 75))
        self.Bind(wx.EVT_BUTTON, self.Clicked)



        self.Centre()
        self.Show(True)

    def EvtText(self, event):
        num1 = event.GetString()

    def EvtText1(self, event):
        num2 = event.GetString()


    def EvtText2(self, event):
        num3 = event.GetString()


    def Clicked(self, event):

        combo = num1 + num2 + num3

        print combo


        event.Skip()




app = wx.App()
checkList(None, -1, 'Charlie')
app.MainLoop()

How to get the strings from a TextCtrl box? Here is the practice code:

import wx



class citPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)


        wx.StaticText(self, -1, "Choose put you would like:", (45, 15))

        self.quote = wx.StaticText(self, -1, "1:", wx.Point(275, 180), wx.Size(200, -1))
        self.quote = wx.StaticText(self, -1, "2:", wx.Point(275, 230), wx.Size(200, -1))
        self.quote = wx.StaticText(self, -1, "3:", wx.Point(275, 280), wx.Size(200, -1))




class nextButton(wx.Button):
    def __init__(self, parent, id, label, pos):
        wx.Button.__init__(self, parent, id, label, pos)

class cancelButton(wx.Button):
    def __init__(self, parent, id, label, pos):
        wx.Button.__init__(self, parent, id, label, pos)

class searchBox(wx.TextCtrl):
def __init__(self, parent, id, name, pos):
    wx.TextCtrl.__init__(self, parent, id, name, pos)



class minBox(wx.TextCtrl):
    def __init__(self, parent, id, name, pos):
        wx.TextCtrl.__init__(self, parent, id, name, pos)

class maxBox(wx.TextCtrl):
    def __init__(self, parent, id, name, pos):
        wx.TextCtrl.__init__(self, parent, id, name, pos)


class checkList(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 600))

        self.panel = citPanel(self, -1)

        self.searchCtrl = searchBox(self.panel, -1, '', (275, 200))
        self.Bind(wx.EVT_TEXT, self.EvtText)
        self.minCtrl = minBox(self.panel, -1, '', (275, 250))
        self.Bind(wx.EVT_TEXT, self.EvtText1)
        self.maxCtrl = maxBox(self.panel, -1, '', (275, 300))
        self.Bind(wx.EVT_TEXT, self.EvtText2)
        nextButton(self.panel, 30, 'Ok', (275, 50))
        cancelButton(self.panel, -1, 'Exit', (275, 75))
        self.Bind(wx.EVT_BUTTON, self.Clicked)



        self.Centre()
        self.Show(True)

    def EvtText(self, event):
        num1 = event.GetString()

    def EvtText1(self, event):
        num2 = event.GetString()


    def EvtText2(self, event):
        num3 = event.GetString()


    def Clicked(self, event):

        combo = num1 + num2 + num3

        print combo


        event.Skip()




app = wx.App()
checkList(None, -1, 'Charlie')
app.MainLoop()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶茶白久 2024-08-25 01:27:37
TextCtrlInstance.GetValue()
TextCtrlInstance.GetValue()
韬韬不绝 2024-08-25 01:27:37

使用 GetValue(),而不是 GetString()

查看 API:
http://docs.wxwidgets.org/stable/wx_wxtextctrl.html

Use GetValue(), not GetString()

Look at the API:
http://docs.wxwidgets.org/stable/wx_wxtextctrl.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文