Пример #1
0
    def call(self):
        '''show a file dialog'''
        from wx_loader import wx

        # remap flags to wx descriptors
        flag_map = {
            'open': wx.FD_OPEN,
            'save': wx.FD_SAVE,
            'overwrite_prompt': wx.FD_OVERWRITE_PROMPT,
        }
        flagsMapped = map(lambda x: flag_map[x], self.flags)

        #need to OR together the elements of the flagsMapped tuple
        if len(flagsMapped) == 1:
            dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flagsMapped[0])
        else:
            dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flagsMapped[0]|flagsMapped[1])
        if dlg.ShowModal() != wx.ID_OK:
            return None
        return dlg.GetPath()
Пример #2
0
 def on_load(self, event):
     '''called on load button'''
     dlg = wx.FileDialog(None, self.settings.get_title(), '', "", '*.*',
                         wx.FD_OPEN)
     if dlg.ShowModal() == wx.ID_OK:
         self.settings.load(dlg.GetPath())
     # update the controls with new values
     for label in self.setting_map.keys():
         setting = self.setting_map[label]
         ctrl = self.controls[label]
         value = ctrl.GetValue()
         if isinstance(value, str) or isinstance(value, unicode):
             ctrl.SetValue(str(setting.value))
         else:
             ctrl.SetValue(setting.value)
Пример #3
0
    def call(self):
        '''show a file dialog'''
        from wx_loader import wx

        # remap flags to wx descriptors
        flag_map = {
            'open': wx.FD_OPEN,
            'save': wx.FD_SAVE,
            'overwrite_prompt': wx.FD_OVERWRITE_PROMPT,
        }
        flags = map(lambda x: flag_map[x], self.flags)

        dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flags)
        if dlg.ShowModal() != wx.ID_OK:
            return None
        return dlg.GetPath()
Пример #4
0
 def OnSelectPath(self, event):
     option, ctrl = self.browse_option_map[event.GetId()]
     path = os.path.abspath(ctrl.Value)
     if option.type == 'file':
         dlg = wx.FileDialog(self,
                             message='Select file for %s' % (option.dest),
                             defaultDir=os.path.dirname(path),
                             defaultFile=path)
     elif option.type == 'directory':
         if os.path.isfile(path):
             path = os.path.dirname(path)
         dlg = wx.DirDialog(self,
                            message='Select directory for %s' %
                            (option.dest),
                            defaultPath=path)
     else:
         raise NotImplementedError( ` option.type `)
     dlg_result = dlg.ShowModal()
     if wx.ID_OK != dlg_result:
         return
     ctrl.Value = dlg.GetPath()
Пример #5
0
 def on_save(self, event):
     '''called on save button'''
     dlg = wx.FileDialog(None, self.settings.get_title(), '', "", '*.*',
                         wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
     if dlg.ShowModal() == wx.ID_OK:
         self.settings.save(dlg.GetPath())