我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用wx.FilePickerCtrl()。
def __init__(self, parent, rate=None, out_dir=None, in_dir=None): super(FFmpegConvertDialog, self).__init__(parent=parent, title="pyjam Audio Converter", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.in_dir = in_dir self.game_rate = intctrl.IntCtrl(self) game_rate_text = wx.StaticText(self, label="Audio rate") if rate is not None: self.game_rate.SetValue(rate) self.volume = wx.SpinCtrl(self, initial=85) volume_text = wx.StaticText(self, label="Volume %") self.in_picker = wx.FilePickerCtrl(self, style=wx.FLP_USE_TEXTCTRL) in_picker_text = wx.StaticText(self, label="Input file names (manually changing them has no effect)") self.in_files = [] # the dumbest thing i've done all year (i'm overriding the controls of the PickerBase) for child in self.in_picker.GetChildren(): if isinstance(child, wx.Button): child.Bind(wx.EVT_BUTTON, self.browse) self.out_dir = wx.DirPickerCtrl(self, name="Output directory") out_dir_text = wx.StaticText(self, label="Output directory") if out_dir is not None: self.out_dir.SetPath(out_dir) top_sizer = wx.BoxSizer(wx.VERTICAL) top_row = wx.BoxSizer(wx.HORIZONTAL) rate_sizer = wx.BoxSizer(wx.VERTICAL) vol_sizer = wx.BoxSizer(wx.VERTICAL) dir_sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) rate_sizer.Add(game_rate_text, 0, wx.ALL ^ wx.BOTTOM | wx.ALIGN_LEFT, 5) rate_sizer.Add(self.game_rate, 0, wx.ALL | wx.ALIGN_LEFT, 5) vol_sizer.Add(volume_text, 0, wx.ALL ^ wx.BOTTOM | wx.ALIGN_LEFT, 5) vol_sizer.Add(self.volume, 0, wx.ALL | wx.ALIGN_LEFT, 5) top_row.Add(rate_sizer) top_row.Add(vol_sizer) dir_sizer.Add(in_picker_text, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 3) dir_sizer.Add(self.in_picker, 0, wx.ALL ^ wx.LEFT ^ wx.TOP | wx.ALIGN_LEFT | wx.EXPAND, 5) dir_sizer.Add(out_dir_text, 0, wx.ALL ^ wx.LEFT | wx.ALIGN_LEFT, 3) dir_sizer.Add(self.out_dir, 0, wx.ALL ^ wx.LEFT ^ wx.TOP | wx.ALIGN_LEFT | wx.EXPAND, 5) top_sizer.Add(top_row) top_sizer.Add(dir_sizer, 1, wx.ALL | wx.EXPAND | wx.ALIGN_TOP, 5) top_sizer.Add(button_sizer, 0, wx.ALL | wx.ALIGN_CENTER, 5) self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK) self.Bind(wx.EVT_BUTTON, self.on_cancel, id=wx.ID_CANCEL) self.converter = None self.progress_dialog = None self.num_songs = 0 self.SetSizer(top_sizer) # self.SetSize(400, 250) self.Center() self.ShowModal()