Using variables declared in functions and use them in another function in a different class
Question: 
    #!/usr/bin/python
    import MainPanel
    import wx
    
    ########################################################################
    class OtherFrame(wx.Frame):##open PDB frame
        """"""
    
        #----------------------------------------------------------------------
        def __init__(self):
            """Constructor"""
            wx.Frame.__init__(self, None, wx.ID_ANY, "Secondary Frame")
            panel = wx.Panel(self)##create panel
    
            chain = wx.Button(panel, label = "OK", pos=(100,80),size=(53,25))##button create
            self.Bind(wx.EVT_BUTTON,self.getchain,chain)##bind event to button go to getchain method
    
    
        def getchain(self,event):
        global flag
        flag = 1
    
    
    import OtherFrame
    
    #######
    class MainPanel(wx.Panel):##main frame
        """"""
    
         #----------------------------------------------------------------------
        def __init__(self, parent, size = (5000,5000)):
            """Constructor"""
            wx.Panel.__init__(self, parent=parent, size = (5000,5000))
            self.frame = parent
    
            Publisher().subscribe(self.showFrame, ("show.mainframe"))
    
        def showFrame(self, msg):
    
        #------------------------------------------------------------------
            def createfigure():
    
           OtherF = OtherFrame.OtherFrame()
           OtherF.getchain()
           print flag
    

First of all I have shortened down my code massively due to it being over 1000
lines of code. What I am wanting to do is get the variables declared in
`getchain` and use them in the `def createfigure`. They are from different
classes. At the moment I am getting the error `getchain() takes exactly 2
arguments (1 given)` Could someone tell me where I am going wrong, and how to
get the variables I use in `def getchain(self,event)` and use them in `def
createfigure`


Answer: You shouldn't do that. If you really, really want to, then it's better to make
the variables class properties by pre-pending them with "self.". So if you
want to access the "flag" variable in the other class, make it "self.flag".

Then you can access it using OtherF.flag. However, I think if you need to get
something from another class, I recommend using pubsub to pass it around.
Here's a tutorial:

  * <http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/>

