Exemple #1
0
    def call(self):
        '''show a file dialog'''
        from MAVProxy.modules.lib.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 = list(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() + "\""
Exemple #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)
Exemple #3
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()

            # Python 2 compatiblility - alternative is:
            # import six
            # isinstance(value, six.string_types)
            if isinstance(value, str) \
                or isinstance(value, str if sys.version_info[0] >= 3 else unicode):
                ctrl.SetValue(str(setting.value))
            else:
                ctrl.SetValue(setting.value)
Exemple #4
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())