Use instance variables (self.) instead of global variables. Also, you can clean the program up by combining all of the number buttons into one for() loop and pass the number to a common function.
import wx
from functools import partial
class jake(wx.Frame):
def __init__(self,parent,id):
self.foo=""
self.outp=0
wx.Frame.__init__(self,parent,id,'Virtual Bank', size=(500,550))
panel=wx.Panel(self)
## you can add in 4-->decimal buttons
for button in (("1", 10, 100), ("2", 110, 100), ("3", 210,100)):
this_button=wx.Button(panel,label=button[0],
pos=(button[1],button[2]),size=(75,75))
self.Bind(wx.EVT_BUTTON, partial(self.func1, num=button[0]),
this_button)
info=wx.Button(panel,label="INFO",pos=(210,400),size=(75,75))
withdraw=wx.Button(panel,label="WITHDRAW",pos=(330,100),size=(130,75))
deposit=wx.Button(panel,label="DEPOSIT",pos=(330,200),size=(130,75))
balance=wx.Button(panel,label="BALANCE",pos=(330,300),size=(130,75))
status=wx.Button(panel,label="STATUS",pos=(330,400),size=(130,75))
self.Bind(wx.EVT_BUTTON, self.decimalfunc, decimal)
self.Bind(wx.EVT_BUTTON, self.infofunc, info)
self.Bind(wx.EVT_BUTTON, self.withdraw, withdraw)
self.Bind(wx.EVT_BUTTON, self.deposit, deposit)
self.Bind(wx.EVT_BUTTON, self.showbalance, balance)
self.Bind(wx.EVT_BUTTON, self.showstatus, status)
wx.StaticText(panel,-1,str(self.outp),(10,45))
wx.StaticText(panel,-1,"Welcome To VirtualBank!",(180,20))
wx.StaticText(panel,-1,"$",(10,40))
def func1(self, event, num):
self.foo+=num
self.outp+=1
print num, "button pressed and total input is now", self.foo
def decimalfunc(self,event):
pass
def infofunc(self,event):
pass
def withdraw(self,event):
pass
def deposit(self,event):
pass
def showbalance(self,event):
pass
def showstatus(self,event):
pass
if __name__=='__main__':
app=wx.PySimpleApp()
frame=jake(parent=None,id=-1)
frame.Show()
app.MainLoop()