I have a class called WxFrame which creates a wxPython frame. I added a method called createRunButton which receives self and pydepp, which is the object of a PyDEPP class
import wx
class WxFrame(wx.Frame):
def __init__(self, parent, title):
super(WxFrame, self).__init__(parent, title=title)
self.Maximize()
self.Show()
def createRunButton(self,pydepp):
#pydepp.run()
self.runButton = wx.Button(self, label="Run")
self.Bind(wx.EVT_BUTTON, pydepp.run, self.runButton
This is the PyDEPP class:
class PyDEPP:
def run(self):
print "running"
I instantiate and run it with:
import wx
from gui.gui import WxFrame
from Depp.Depp import PyDEPP
class PyDEPPgui():
"""PyDEPPgui create doc string here ...."""
def __init__(self,pydepp):
self.app = wx.App(False)
##Create a wxframe and show it
self.frame = WxFrame(None, "Cyclic Depp Data Collector - Ver. 0.1")
self.frame.createRunButton(pydepp)
self.frame.SetStatusText('wxPython GUI successfully initialised')
if __name__=='__main__':
#Launch the program by calling the PyDEPPgui __init__ constructor
pydepp = PyDEPP()
pydeppgui = PyDEPPgui(pydepp)
pydeppgui.app.MainLoop()
The error I get when running the above code is: TypeError: run() takes exactly 1 argument (2 given)
However, if I comment out the bind and uncomment the line pydepp.run(), then it works fine.
The answer is obvious I'm sure, but I have never studied CompSci or OO coding.