Beispiel #1
0
    def on_save_as(self, event=None):
        scenario = self.get_scenario()
        wildcards_all = "All files (*.*)|*.*"
        wildcards_obj = "Python binary files (*.obj)|*.obj"
        wildcards = wildcards_obj + "|" + wildcards_all

        # Finally, if the directory is changed in the process of getting files, this
        # dialog is set up to change the current working directory to the path
        # chosen.
        dlg = wx.FileDialog(self._mainframe,
                            message="Save scenario to file",
                            defaultDir=scenario.get_workdirpath(),
                            defaultFile=scenario.get_rootfilepath() + '.obj',
                            wildcard=wildcards,
                            style=wx.SAVE | wx.CHANGE_DIR)

        # Show the dialog and retrieve the user response. If it is the OK response,
        # process the data.
        if dlg.ShowModal() == wx.ID_OK:
            # This returns a Python list of files that were selected.
            filepath = dlg.GetPath()
            if len(filepath) > 0:
                # now set new filename and workdir

                scenario.save(filepath)
                self._mainframe.refresh_moduleguis()

        # Destroy the dialog. Don't do this until you are done with it!
        # BAD things can happen otherwise!
        dlg.Destroy()
Beispiel #2
0
    def on_save_as(self, event=None):
        scenario = self.get_scenario()
        wildcards_all = "All files (*.*)|*.*"
        wildcards_obj = "Python binary files (*.obj)|*.obj"
        wildcards = wildcards_obj+"|"+wildcards_all

        # Finally, if the directory is changed in the process of getting files, this
        # dialog is set up to change the current working directory to the path chosen.
        dlg = wx.FileDialog(
            self._mainframe, message="Save scenario to file",
            defaultDir=scenario.get_workdirpath(),
            defaultFile=scenario.get_rootfilepath()+'.obj',
            wildcard=wildcards,
            style=wx.SAVE | wx.CHANGE_DIR
        )

        # Show the dialog and retrieve the user response. If it is the OK response,
        # process the data.
        if dlg.ShowModal() == wx.ID_OK:
            # This returns a Python list of files that were selected.
            filepath = dlg.GetPath()
            if len(filepath) > 0:
                # now set new filename and workdir

                scenario.save(filepath)
                self._mainframe.refresh_moduleguis()

        # Destroy the dialog. Don't do this until you are done with it!
        # BAD things can happen otherwise!
        dlg.Destroy()
Beispiel #3
0
    def on_exit(self, event):
        """Called when the application is to be finished"""
        dlg = wx.MessageDialog(
            self._mainframe,
            'SUMOPy is about to close.\nDo you want to SAVE the current scenario before closing?',
            'Closing SUMOPy', wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
        ans = dlg.ShowModal()
        dlg.Destroy()
        # print '
        # ans,wx.ID_CANCEL,wx.ID_YES,wx.ID_NO',ans,wx.ID_CANCEL,wx.ID_YES,wx.ID_NO
        if ans == wx.ID_CANCEL:
            # print ' do not quit!'
            pass

        elif ans == wx.ID_YES:
            # print ' save and quit'
            scenario = self.get_scenario()
            cm.save_obj(scenario,
                        scenario.get_rootfilepath() + '.obj',
                        is_not_save_parent=False)
            self._mainframe.destroy()

        elif ans == wx.ID_NO:
            # print 'quit immediately'
            self._mainframe.destroy()
Beispiel #4
0
    def on_exit(self, event):
        """Called when the application is to be finished"""
        dlg = wx.MessageDialog(self._mainframe,
                               'SUMOPy is about to close.\nDo you want to SAVE the current scenario before closing?',
                               'Closing SUMOPy',
                               wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
        ans = dlg.ShowModal()
        dlg.Destroy()
        # print '  ans,wx.ID_CANCEL,wx.ID_YES,wx.ID_NO',ans,wx.ID_CANCEL,wx.ID_YES,wx.ID_NO
        if ans == wx.ID_CANCEL:
            # print ' do not quit!'
            pass

        elif ans == wx.ID_YES:
            # print ' save and quit'
            scenario = self.get_scenario()
            cm.save_obj(scenario, scenario.get_rootfilepath()+'.obj',
                        is_not_save_parent=False)
            self._mainframe.destroy()

        elif ans == wx.ID_NO:
            # print 'quit immediately'
            self._mainframe.destroy()