how to call a button function under another function

i am making an GUI for plotting graph and embedding software . But i cannot link a browse button with that run button function. i am writing the whole path at the backend of the run button while i am also read the file path at the browse button too .
forexample
def OnButtonBrowse(self, event):
self.dirname = ‘/home’
dlg = wx.FileDialog(self, “Choose a file”, self.dirname, “”,“CSV files (.csv)|.csv”, wx.FD_OPEN)
if dlg.ShowModal() == wx.ID_OK:

        self.filename = dlg.GetFilename()
        print self.filename
        self.dirname=dlg.GetDirectory()
       # if self.filename[-3:]=='csv':
        f = open(os.path.join(self.dirname, self.filename), 'r')
        self.csvText.SetValue('u'+self.dirname+self.filename)
        x=wx.BusyInfo("                  Please wait,Loading File.\n\n 'Adopt the Pace of Nature, Her Secret is Patience...'")
        wx.Yield()
        self.csv_data=f.read()
        f.close()

def OnGraphitButton(self, event):
global p
global Line
global Data
p = GracePlot() # A grace session opens

    l1=Line(type="2")
    x1=[]
    y1=[]
    fr=open("/home/ayesha/Documents/Source_code/b.csv","r").readlines()
    parts = fr[-1].split(",")[0]
    print(parts)
    for line in fr:
            if not line.startswith('DEL') and not line.startswith('Fr'):
                    ab=line.replace('\n', '').split(',')
                    x1.append(float(ab[0]))
                    y1.append(float(ab[1]))
    d2=Data(x=x1,y=y1,line=l1)
    g=p[0]

    g.plot([d2])

    g.xaxis(label=Label('X axis',font=5,charsize=1.5),
    tick=Tick(majorgrid=True,majorlinestyle=lines.none,majorcolor=colors.blue,
              minorgrid=True,minorlinestyle=lines.none,minorcolor=colors.blue))
    g.yaxis(tick=Tick(majorgrid=True,majorlinestyle=lines.none,majorcolor=colors.blue,
              minorgrid=True,minorlinestyle=lines.none,minorcolor=colors.blue))

how can i join first button function under second button so that the uploaded file can read and all the work done at the ther button

what you want, but can offer some things to think about that may help. (It
seems to me this is mostly programming-in-general help and not wxPython per
se.)

I think you want to plot stuff based on a chosen CSV file. Right now you
have that broken into two user actions: 1) choose the file via a browse
button, and then 2) request the plot be generated via the Graphit button.

From how you have it written above, it seems like every CSV file results in
a one and *only* one plot (because there are no parameters passed to the
graphing function that could change the resultant plot). So that means
every time the user requests a new plot, s/he needs to specify a CSV file.
So you might as well have that all built into the GraphIt() function.

I would therefore just move the code that presents the FileDialogue under
the GraphIt function.

But--even better--I would suggest that you think in terms of decoupling GUI
code from business logic more. If it were me, I'd make the event handler
functions (that is, any function that has (self, event) as parameters) very
short and just have them call the appropriate other functions. So, for
example:

def OnGraphButton(self,event):
    self.ShowGraph()

def ShowGraph(self):
    file = self.GetFile()
    etc...

def GetFile(self):
    call FileDialogue, clean up, etc...

···

On Sat, Apr 9, 2016 at 10:40 AM, Muhammad Bilal Khan < textilianbilal@gmail.com> wrote:

i am making an GUI for plotting graph and embedding software . But i
cannot link a browse button with that run button function. i am writing the
whole path at the backend of the run button while i am also read the file
path at the browse button too .
forexample
def OnButtonBrowse(self, event):
        self.dirname = '/home'
        dlg = wx.FileDialog(self, "Choose a file", self.dirname, "","CSV
files (*.csv)|*.csv", wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:

            self.filename = dlg.GetFilename()
            print self.filename
            self.dirname=dlg.GetDirectory()
           # if self.filename[-3:]=='csv':
            f = open(os.path.join(self.dirname, self.filename), 'r')
            self.csvText.SetValue('u'+self.dirname+self.filename)
            x=wx.BusyInfo(" Please wait,Loading File.\n\n
'Adopt the Pace of Nature, Her Secret is Patience...'")
            wx.Yield()
            self.csv_data=f.read()
            f.close()
def OnGraphitButton(self, event):
        global p
        global Line
        global Data
        p = GracePlot() # A grace session opens

        l1=Line(type="2")
        x1=
        y1=
        fr=open("/home/ayesha/Documents/Source_code/b.csv","r").readlines()
        parts = fr[-1].split(",")[0]
        print(parts)
        for line in fr:
                if not line.startswith('DEL') and not
line.startswith('Fr'):
                        ab=line.replace('\n', '').split(',')
                        x1.append(float(ab[0]))
                        y1.append(float(ab[1]))
        d2=Data(x=x1,y=y1,line=l1)
        g=p[0]

        g.plot([d2])

        g.xaxis(label=Label('X axis',font=5,charsize=1.5),

tick=Tick(majorgrid=True,majorlinestyle=lines.none,majorcolor=colors.blue,

minorgrid=True,minorlinestyle=lines.none,minorcolor=colors.blue))

g.yaxis(tick=Tick(majorgrid=True,majorlinestyle=lines.none,majorcolor=colors.blue,

minorgrid=True,minorlinestyle=lines.none,minorcolor=colors.blue))
how can i join first button function under second button so that the
uploaded file can read and all the work done at the ther button

I'm not 100% clear on exactly what you want to do, so I will partly guess