calling an event from within a program

JDevine justin__devine at hotmail.com
Wed Aug 11 10:29:36 EDT 2004


Can someone tell me the proper syntax to create an event from within a
program

here is my example code.  I have Checkboxes and Radioboxes operating
on the same Text Control.  What I want is when the Checkbox is
unchecked for the EVT_RADIOBOX evt to run therefore populating the
text control with the value that was left on it when it was disabled. 
So what I really want to do is run a EVT_RADIOBOX from a checkbox. 
any suggestions?



def EvtCheckBox3(event):
            print ck3.GetValue()
            
            if ck3.GetValue() == True:
                t2.Clear()
                t2.SetValue("blah blah")
                t2.SetEditable(False)
                ck1.SetValue(False)
                ck2.SetValue(False)
                rb.Enable(False)
                
            else:
                t2.Clear()
                t2.SetValue("blah blah blah")
                t2.SetEditable(True)
                rb.Enable(True)
                
              
        
        ck3 = wx.CheckBox(self, -1, "blah blah blah", (255, 60), (170,
20), wx.NO_BORDER)
        self.Bind(wx.EVT_CHECKBOX, EvtCheckBox3, ck3)
        
        #Create a radio box 
        def EvtRadioBox(event):
            print event.GetInt()
            if event.GetInt() == 0:
                 t2.Clear()
                 t2.SetValue("Blah Blah Blah")
                 t2.SetEditable(True)
                 
            elif event.GetInt() == 1:
                 t2.Clear()
                 t2.SetValue("blah blah blah")
                 t2.SetEditable(False)
                 
            elif event.GetInt() == 2:
                 t2.Clear()
                 t2.SetValue("blah blah blah")
                 t2.SetEditable(False)

............and elif for each position in the radiobox and finally
creating the radiobox and the binding

        sitelist = ['blah', 'ying', 'yang']

        sizer = wx.BoxSizer(wx.HORIZONTAL)

        rb = wx.RadioBox(
                self, -1, "My Radiobox", (10, 215), (425, 70),
                sitelist, 5, wx.RA_SPECIFY_COLS
                )
        
        self.Bind(wx.EVT_RADIOBOX, EvtRadioBox, rb)



More information about the Python-list mailing list