Can not create wx.filedialog in an dialog class?

Some things are obviously missing from the code above, like dlg.ShowModal, but I can't tell if it's really missing or you just didn't copy/paste enough of the code to your email. Please send a small but complete runnable sample that shows what you are trying to do that is not working. MakingSampleApps - wxPyWiki

···

On 8/19/12 5:09 PM, JauRung Tang wrote:

I create a class like this below. But when I bind an event with the "save file" button, the wx.filelog is not going to setup. It's really weird. So I change the SuperClass to be wx.Frame, then it succeeds.Can anybody tell me why? Thanks.(This is a question in stackoverflow.com python - Can not create wx.filedialog in an dialog class? - Stack Overflow)

class TestDialog(wx.Dialog):
     def __init__(
         self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
         style=wx.DEFAULT_DIALOG_STYLE,
         useMetal=False,):
         self.pre = wx.PreDialog()
         self.pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
         self.pre.Create(parent, ID, title, pos, size, style)
         self.PostCreate(self.pre)
         self.fileButton = wx.Button(self , -1, "save file!")
         self.Bind(wx.EVT_BUTTON, self.OnCompressToFileButton, self.fileButton)
     def OnCompressToFileButton(self, event):
         wildcard = "compress file(*.cof)|*.cof|Lempel-Zivsliding window compressfile(*.lz)|*.lz"
         dlg = wx.FileDialog(self, message="Save file as ...", defaultDir=os.getcwd(), defaultFile="", wildcard=wildcard, style=wx.SAVE)

--
Robin Dunn
Software Craftsman