Strange problem with FileBrowseButtonWithHistory

Strange problem with FileBrowseButtonWithHistory
I have encounter a strange problem with FileBrowseButtonWithHistory in combination with wxRadioButtons. The attached self-explanatory program is a small wxPython application for demonstrating the problem. Is this a bug in my application or wxPython?

I have used FileBrowseButtonWithHistory before but this problem occured when I added wxRadioButtons to the app.

(I’m using python2.2.2 & wxpython2.3.3.1 on win2k/winxp)

Thanks for any help!

Jens

wxPython newbee

from wxPython.wx import *

from wxPython.lib.filebrowsebutton import FileBrowseButtonWithHistory

class MainFrame(wxFrame):

ID_METHOD_REL = wxNewId()

ID_METHOD_ABS = wxNewId()



def __init__(self):

    wxFrame.__init__(self,NULL,-1,"bug demo")

    self.panel = wxPanel(self,-1)

    meth1 = wxRadioButton( self.panel, self.ID_METHOD_REL, "rel" )

    meth2 = wxRadioButton( self.panel, self.ID_METHOD_ABS, "abs" )

    buggy = raw_input('Do you want to freeze the app when touching the radio buttons? (y/n): ')

    if buggy=='y':

        file = FileBrowseButtonWithHistory(self.panel, -1, changeCallback=self.getFile)

    else:

        file = wxTextCtrl( self.panel, -1, "dummy.dat" )

    sizer = wxBoxSizer(wxVERTICAL)

    sizer.Add( file,  0, wxEXPAND )

    sizer.Add( meth1, 0, wxEXPAND )

    sizer.Add( meth2, 0, wxEXPAND )

    self.panel.SetAutoLayout(true)

    self.panel.SetSizer(sizer)

    self.panel.Layout()

    # Tie button clicks to some event handlers

    EVT_RADIOBUTTON( self, self.ID_METHOD_REL, self.getMethodRel )

    EVT_RADIOBUTTON( self, self.ID_METHOD_ABS, self.getMethodAbs )

def getFile(self, event):

    print "File evt: ", event.GetString()

def getMethodRel(self, event):

    print "hi rel"

def getMethodAbs(self, event):

    print "hi abs"

class MyApp(wxApp):

def OnInit(self):

    frame = MainFrame()

    frame.Show(true)

    self.SetTopWindow(frame)

    return true

app = MyApp(0)

app.MainLoop()

`

···

Neither the confidentiality nor the integrity of this message

can be guaranteed following transmission on the Internet.

This message has been swept by MAILsweeper at DNV for

the presence of computer viruses.


`

I can't see a reason for this to fail. I worked a little at debugging it, and whittled out a smaller demonstration of the problem. This eliminates all the events-handlers and the change callback. It also eliminates the intermediary panel from the equation.

Enjoy,
Mike

from wxPython.wx import *
from wxPython.lib.filebrowsebutton import FileBrowseButtonWithHistory

class MainFrame(wxFrame):
    def __init__(self):
        wxFrame.__init__(self,NULL,-1,"bug demo")
        meth1 = wxRadioButton( self, wxNewId(), "rel" )
        f = FileBrowseButtonWithHistory(
            self, wxNewId(),
        )
        sizer = wxBoxSizer(wxVERTICAL)
        sizer.Add( f, 0, wxEXPAND )
        sizer.Add( meth1, 0, wxEXPAND )
        self.SetAutoLayout(true)
        self.SetSizer(sizer)
        self.Layout()

class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame()
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

···

Jens.Bloch.Helmers@dnv.com wrote:

I have encounter a strange problem with FileBrowseButtonWithHistory in combination with wxRadioButtons. The attached self-explanatory program is a small wxPython application for demonstrating the problem. Is this a bug in my application or wxPython?

I have used FileBrowseButtonWithHistory before but this problem occured when I added wxRadioButtons to the app.

(I'm using python2.2.2 & wxpython2.3.3.1 on win2k/winxp)

Thanks for any help!

Jens
wxPython newbe

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

Would a wxRadioBox work better for you. Try this:

···

--- Jens.Bloch.Helmers@dnv.com wrote:

I have used FileBrowseButtonWithHistory before but this problem
occured when I added wxRadioButtons to the app.

============================================================
from wxPython.wx import *
from wxPython.lib.filebrowsebutton import \
     FileBrowseButtonWithHistory

class MainFrame(wxFrame):

    def __init__(self):
        wxFrame.__init__(self,NULL,-1,"bug demo")
        self.panel = wxPanel(self,-1)
        rb = wxRadioBox(self.panel, wxNewId(), "wxRadioBox",
                        choices=['rel', 'abs'])
        file = FileBrowseButtonWithHistory(self.panel, -1,
changeCallback=self.getFile)
        sizer = wxBoxSizer(wxVERTICAL)
        sizer.Add( file, 0, wxEXPAND )
        sizer.Add( rb, 0, wxEXPAND )
        self.panel.SetAutoLayout(true)
        self.panel.SetSizer(sizer)
        self.panel.Layout()
        # Tie button clicks to some event handlers
        EVT_RADIOBOX(self, rb.GetId(), self.EvtRadioBox)

    def EvtRadioBox(self, event):
        x = event.GetInt()
        print 'EvtRadioBox: %d\n' % x

    def getFile(self, event):
        print "File evt: ", event.GetString()

class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame()
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.