Forum: GNU Radio WX Problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bfbfb259508d87c987ba0024d8eeef5e?d=identicon&s=25 Matthew Dolloff (Guest)
on 2009-04-22 16:55
(Received via mailing list)
I'm having a problem creating a GUI.  I'm trying to bind an event to a
button but when i bind the event, the callback is called immediately.
I'm not sure what the heck is happening.  Any help would be greatly
appreciated.  if you look at the code below you can see that the
callback is getting called immediately.

#Code Snippet

    def _create_Gui (self, vbox):
        self.myform = myform = form.form()

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add((5,0),0)

        self.b1 = wx.ToggleButton(self.panel,wx.ID_ANY,"button 1")
        print "1"
        self.b1.Bind(wx.EVT_LEFT_DCLICK, self._setText())
        print "2"
        hbox.Add(self.b1,1,wx.LEFT | wx.RIGHT ,2)

        self.b2 = wx.Button(self.panel,wx.ID_ANY,"button 2")
        hbox.Add(self.b2,1,wx.LEFT | wx.RIGHT ,2)
        vbox.Add(hbox, 0, wx.EXPAND)
        return

    def _setText(self):
        print "button pressed"
        self.b1.Show(False)
        return

# Terminal Window Output
1
button pressed
2
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-04-22 19:54
(Received via mailing list)
On Wed, Apr 22, 2009 at 10:54:12AM -0400, Matthew Dolloff wrote:
>
>         hbox = wx.BoxSizer(wx.HORIZONTAL)
>         hbox.Add((5,0),0)
>
>         self.b1 = wx.ToggleButton(self.panel,wx.ID_ANY,"button 1")
>         print "1"
>         self.b1.Bind(wx.EVT_LEFT_DCLICK, self._setText())

self.setText() is a call, that's why it's getting called right away.
Try self.setText [no parens].
Bfbfb259508d87c987ba0024d8eeef5e?d=identicon&s=25 Matthew Dolloff (Guest)
on 2009-04-22 21:02
(Received via mailing list)
Yeah I figured that out just after I sent the email.  Thanks for the
feedback though!
This topic is locked and can not be replied to.