0

I want to be able to call my third function into play from within the other two functions in the example below whenever you press the buttons. How can I do this while keeping the value for s?

import wx

class MyDialog(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(350, 100))


        wx.Button(self, 1, '1', (100, 10))
        wx.Button(self, 2, '2', (185, 10))

        self.Bind(wx.EVT_BUTTON, self.one, id=1)
        self.Bind(wx.EVT_BUTTON, self.two, id=2)


    def one(self,event):
        s=1



    def two(self,event):
        s=2

    def three(self,event):
        print s

class MyApp(wx.App):
    def OnInit(self):
        dlg = MyDialog(None, -1, 'Example')

        dlg.Show(True)
        dlg.Centre()

        return True

app = MyApp(0)

app.MainLoop()

1 Answer 1

1

Just call thee as self.three(value):

def one(self, event):
    self.three(1)

def two(self, event):
    self.three(2)

def three(self, s):
    print s
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.