I only made an on and addition button with actual functions

#!/usr/bin/python

# gridsizer.py

import wx
app = wx.App()
class GridSizer(wx.Frame):
    def __init__(self, parent, id, title):
               wx.Frame.__init__(self, parent, id, title, size=(300, 250))
def On(self, event):
    x=input("")
def add(self,event):
    return x
    y=input("")
    print x + y
menubar = wx.MenuBar()
file = wx.Menu()
file.Append(0, '&Quit', 'Exit Calculator')
menubar.Append(file, '&File')
self.SetMenuBar(menubar)

sizer = wx.BoxSizer(wx.VERTICAL)
self.display = wx.TextCtrl(self, -1, '',  style=wx.TE_RIGHT)
sizer.Add(self.display, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4)
gs = wx.GridSizer(4, 4, 3, 3)

gs.AddMany([
    (wx.Button(self, 3, '='), 0, wx.EXPAND),
                self.Bind(wx.EVT_BUTTON, on, id=3),         
    (wx.Button(self, 2, '+'), 0, wx.EXPAND),
                self.Bind(wx.EVT_BUTTON, self.add, id=2)
                ])

sizer.Add(gs, 1, wx.EXPAND)
self.SetSizer(sizer)
self.Centre()
self.Show(True)
     
   
   
app = wx.App()
GridSizer(None, -1, 'GridSizer')
app.MainLoop()

Basically I made a gridsizer for the buttons, then binded on and add to their buttons I was just running two buttons to check for functionality and, I get a self undefined on line 20 Help, please!
_________________
I'm new, don't eat me... please, PLEASE, AHHHH!

You have a lot of errors your code. First of all let me say that you can really only use self when you are in a class. A lot of your code in your program should be in the __init__ method.

Also in you Add method you have return x as the first thing you say. This will stop the rest of the code from running. Instead it should be like:

def Add(self,event):
        
        y=input("")
        print x + y

Just dont worry about returning anything. You need not.

For your events you want wx.EVT_LEFT_DOWN to stimulate on a mouse click.

If fiddled around and this is what i got. It isnt perfect but it will help you along:

#!/usr/bin/python

# gridsizer.py

import wx

class GridSizer(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(300, 250))
        menubar = wx.MenuBar()
        file = wx.Menu()
        file.Append(0, '&Quit', 'Exit Calculator')
        menubar.Append(file, '&File')
        self.SetMenuBar(menubar)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.display = wx.TextCtrl(self, -1, '',  style=wx.TE_RIGHT)
        sizer.Add(self.display, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4)
        gs = wx.GridSizer(4, 4, 3, 3)
        self.e_but = wx.Button(self, 3, '=')
        self.e_but.Bind(wx.EVT_LEFT_DOWN, self.On)
        self.a_but = wx.Button(self, 2, '+')
        self.a_but.Bind(wx.EVT_LEFT_DOWN,self.Add)
    
        gs.AddMany([(self.e_but, 0, wx.EXPAND),(self.a_but, 0, wx.EXPAND)])
                       
                     
        sizer.Add(gs, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.Centre()
        self.Show(True)
    def On(self, event):
        x=input("")
        
    def Add(self,event):
        
        y=input("")
        print x + y



     
   
   
app = wx.App(False)
GridSizer(None, -1, 'GridSizer')
app.MainLoop()

Note that your program is not getting input from the GUI the input is still coming from the python console.

well is there anyway to integrate an input to the GUI? And I ran the program and it doesnt allow me to input y bec. (I'm assuming) I never returned x

Okay, you have to use your TextCtrl and then you have use something like:

t = wx.TextCtrl(arguments)
#... later
t.GetValue()

the GetValue() method fetches the current value of the textCtrl

TYVVVM

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.