Hey everyone, I decided I didn't want to use Tkinter, so now I'm using wxPython, and I'm having some problems, such as getting values from a function to another. I know, it's a bit hard to understand, and I don't even know if this is possible.

import wx


class Example(wx.Frame):

    def __init__(self,parent,id):

        wx.Frame.__init__(self,parent,id,'Example', size=(312,130))
        panel=wx.Panel(self)

        ntext=wx.StaticText(panel, -1, "Name: ", pos=(3,6))
        name=wx.TextCtrl(panel, -1, "Your name", size=(220, -1), pos=(60,2))
        name.SetInsertionPoint(0)

        Namo=wx.Button(panel, -1, "Namo", pos=(100,50), size=(60,30))
        self.Bind(wx.EVT_BUTTON, self.GetName, Namo)

    def GetName(self, evt):

        print(name.GetValue())

if __name__ == '__main__':
    app=wx.PySimpleApp()
    frame=Example(parent=None,id=-1)
    frame.Show()
    app.MainLoop()

But I'm getting some errors, and I have modified the code a couple of times, but I still wasn't able to get it to work. I also, don't want to use that Text Box, that pops up and asks you for an input, because I want to add more TextCrtls in it, and maybe some check boxes. Thank you.

Recommended Answers

All 2 Replies

You have left out self:
self.name =

Thank you very much. That did it ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.