Ejemplo n.º 1
0
    def open_app(self, event_unused):
        """loads a wxGlade project from an xml file
        NOTE: this is very slow and needs optimisation efforts
        NOTE2: the note above should not be True anymore :) """
        if not self.ask_save():
            return
        default_path = os.path.dirname(common.app_tree.app.filename
                                       or "") or self.cur_dir
        infile = wx.FileSelector(_("Open file"),
                                 wildcard="wxGlade files (*.wxg)|*.wxg|"
                                 "wxGlade Template files (*.wgt)|*.wgt|"
                                 "XML files (*.xml)|*.xml|All files|*",
                                 flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
                                 default_path=default_path)
        if not infile: return
        if common.check_autosaved(infile):
            if wx.MessageBox(_(
                    "There seems to be auto saved data for this file: do you want to restore it?"
            ),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION | wx.YES_NO) == wx.YES:
                common.restore_from_autosaved(infile)
            else:
                common.remove_autosaved(infile)
        if infile == common.app_tree.app.filename:
            # if we are re-loading the file, go the the previous position
            path = common.app_tree.get_selected_path()
        else:
            path = None
        self._open_app(infile)
        self.cur_dir = os.path.dirname(infile)

        if path is not None:
            common.app_tree.select_path(
                path)  # re-loaded file -> go to previous position
Ejemplo n.º 2
0
 def open_app(self, event_unused):
     """\
     loads a wxGlade project from an xml file
     NOTE: this is very slow and needs optimisation efforts
     NOTE2: the note above should not be True anymore :)
     """
     if not self.ask_save(): return
     from xml_parse import XmlWidgetBuilder, ProgressXmlWidgetBuilder
     infile = misc.FileSelector(_("Open file"),
                                wildcard="wxGlade files (*.wxg)|*.wxg|"
                                "wxGlade Template files (*.wgt)|*.wgt|"
                                "XML files (*.xml)|*.xml|All files|*",
                                flags=wx.OPEN | wx.FILE_MUST_EXIST,
                                default_path=self.cur_dir)
     if infile:
         # ALB 2004-10-15 try to restore possible autosave content...
         if common.check_autosaved(infile) and \
                wx.MessageBox(_("There seems to be auto saved data for "
                             "this file: do you want to restore it?"),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
             common.restore_from_autosaved(infile)
         else:
             common.remove_autosaved(infile)
         self._open_app(infile)
         self.cur_dir = os.path.dirname(infile)
Ejemplo n.º 3
0
 def open_from_history(self, event):
     if not self.ask_save():
         return
     pos = event.GetId() - wx.ID_FILE1
     filename = self.file_history.GetHistoryFile(pos)
     if not os.path.exists(filename):
         wx.MessageBox(_("The file %s doesn't exist.") % filename,
                       _('Information'),
                       style=wx.CENTER | wx.ICON_INFORMATION | wx.OK)
         self.file_history.RemoveFileFromHistory(pos)
         common.remove_autosaved(filename)
         return
     if common.check_autosaved(filename):
         res = wx.MessageBox(_(
             'There seems to be auto saved data for this file: do you want to restore it?'
         ),
                             _('Auto save detected'),
                             style=wx.ICON_QUESTION | wx.YES_NO)
         if res == wx.YES:
             common.restore_from_autosaved(filename)
         else:
             common.remove_autosaved(filename)
     else:
         common.remove_autosaved(filename)
     self._open_app(filename)
     self.cur_dir = os.path.dirname(filename)
Ejemplo n.º 4
0
 def open_app(self, event_unused):
     """\
     loads a wxGlade project from an xml file
     NOTE: this is very slow and needs optimisation efforts
     NOTE2: the note above should not be True anymore :)
     """
     if not self.ask_save(): return
     from xml_parse import XmlWidgetBuilder, ProgressXmlWidgetBuilder
     infile = misc.FileSelector(_("Open file"),
                                wildcard="wxGlade files (*.wxg)|*.wxg|"
                                "wxGlade Template files (*.wgt)|*.wgt|"
                                "XML files (*.xml)|*.xml|All files|*",
                                flags=wx.OPEN|wx.FILE_MUST_EXIST,
                                default_path=self.cur_dir)
     if infile:
         # ALB 2004-10-15 try to restore possible autosave content...
         if common.check_autosaved(infile) and \
                wx.MessageBox(_("There seems to be auto saved data for "
                             "this file: do you want to restore it?"),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
             common.restore_from_autosaved(infile)
         else:
             common.remove_autosaved(infile)
         self._open_app(infile)
         self.cur_dir = os.path.dirname(infile)
Ejemplo n.º 5
0
 def open_from_history(event):
     if not self.ask_save(): return
     infile = self.file_history.GetHistoryFile(event.GetId() -
                                               wx.ID_FILE1)
     # ALB 2004-10-15 try to restore possible autosave content...
     if common.check_autosaved(infile) and \
            wx.MessageBox(_("There seems to be auto saved data for "
                         "this file: do you want to restore it?"),
                         _("Auto save detected"),
                         style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
         common.restore_from_autosaved(infile)
     else:
         common.remove_autosaved(infile)
     self._open_app(infile)
Ejemplo n.º 6
0
 def open_from_history(event):
     if not self.ask_save(): return
     infile = self.file_history.GetHistoryFile(
         event.GetId() - wx.ID_FILE1)
     # ALB 2004-10-15 try to restore possible autosave content...
     if common.check_autosaved(infile) and \
            wx.MessageBox(_("There seems to be auto saved data for "
                         "this file: do you want to restore it?"),
                         _("Auto save detected"),
                         style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
         common.restore_from_autosaved(infile)
     else:
         common.remove_autosaved(infile)
     self._open_app(infile)
Ejemplo n.º 7
0
    def open_from_history(self, event):
        if not self.ask_save():
            return
        pos = event.GetId() - wx.ID_FILE1
        filename = self.file_history.GetHistoryFile(pos)
        if not os.path.exists(filename):
            wx.MessageBox(_("The file %s doesn't exist.") % filename,
                          _('Information'),
                          style=wx.CENTER | wx.ICON_INFORMATION | wx.OK)
            self.file_history.RemoveFileFromHistory(pos)
            common.remove_autosaved(filename)
            return
        if common.check_autosaved(filename):
            res = wx.MessageBox(_(
                'There seems to be auto saved data for this file: do you want to restore it?'
            ),
                                _('Auto save detected'),
                                style=wx.ICON_QUESTION | wx.YES_NO)
            if res == wx.YES:
                common.restore_from_autosaved(filename)
            else:
                common.remove_autosaved(filename)
        else:
            common.remove_autosaved(filename)

        if filename == common.app_tree.app.filename:
            # if we are re-loading the file, go the the previous position
            path = common.app_tree.get_selected_path()
        else:
            path = None

        self._open_app(filename)
        self.cur_dir = os.path.dirname(filename)
        if path is not None:
            common.app_tree.select_path(
                path)  # re-loaded file -> go to previous position