1

以下のようなクラスを作成します。しかし、「ファイルを保存」ボタンでイベントをバインドすると、wx.filelog がセットアップされません。本当に変です。SuperClass を wx.Frame に変更すると、成功します。理由を教えてもらえますか? ありがとう。

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)      

`

4

1 に答える 1

0

このタラを使用して、wx.Dialogで動作する必要があります

def OnCompressToFileButton(self, event):
    dlg = wx.FileDialog(self, "Choose a file",os.getcwd(), "", "*.*", wx.SAVE | wx.OVERWRITE_PROMPT)
    if dlg.ShowModal() == wx.ID_OK:
        self.filename=dlg.GetFilename()
        self.dirname=dlg.GetDirectory()
于 2013-04-03T13:33:09.403 に答える