Hi.
I am having a problem in creating of one simple program in Python.
Here is code.
import wx
class bucky(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "Testing erea", size=(280,400))
panel = wx.Panel(self)
food = wx.Button(panel,label='Food',pos=(10,10),size=(80,40))
pets = wx.Button(panel, label='Pets', pos=(100,10), size=(80,40))
self.Bind(wx.EVT_BUTTON, self.food, food
)
def food(self, event):
wx.StaticText(parent, -1, 'Bacon, apples, tuna', (10,30))
self.Bind(wx.EVT_CLOSE,self.closewindow)
def closewindow(self,event):
self.Destroy()
if __name__=='__main__':
app=wx.PySimpleApp()
frame=bucky(parent=None,id=-1)
frame.Show()
app.MainLoop()
1.What my program does is it has two buttons: "Food" and "Pets".
When I click "Food" button I want line of a text on a screen to appear.
("Pets" button does not do nothing yet).
2.The result of my program. I get two buttons on a screen,
but when I click "Food" button the error message in "Python Shell" window appears.
It says "NameError: global name 'parent' is not defined".
3.I want text on a screen to change depends on what button I clicked.
When I click on "Food" I want list of food to appear.
When I click on "Pets" I want list of my pets to appear.
Thank you for help. I am hopping to understand the concept,
so I can add more complex stuff instead of just printing lines out.
Thank you again, whoever will respond.