Changeset 68396


Ignore:
Timestamp:
May 7, 2016, 11:52:46 AM (8 years ago)
Author:
wenzeslaus
Message:

pyedit: do not use onDone because it is not executed when GUI is invoked (fixes #2997)

Now you can run again even if it is already running
which is the same behavior as for normal module calls.

It also uses the same temporary file once it was created
to avoid the need to delete it all the time. It is deleted
when file is actually saved.

Also remove suppression of the GUI interface because we
actually want to get GUI (the parameter does not work, r68395).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/gui/wxpython/gui_core/pyedit.py

    r68394 r68396  
    260260        self.filename = None
    261261        self.tempfile = None  # bool, make them strings for better code
    262         self.running = False
    263262
    264263    def OnRun(self, event):
    265264        """Run Python script"""
    266         if self.running:
    267             # ignore when already running
    268             return
    269 
    270265        if not self.filename:
    271266            self.filename = gscript.tempfile() + '.py'
     
    295290        # run in console as other modules, avoid Python shell which
    296291        # carries variables over to the next execution
    297         self.giface.RunCmd([fd.name], skipInterface=True, onDone=self.OnDone)
    298         self.running = True
    299 
    300     def OnDone(self, event):
    301         """Python script finished"""
     292        self.giface.RunCmd([fd.name])
     293
     294    def SaveAs(self):
     295        """Save python script to file"""
    302296        if self.tempfile:
    303297            try_remove(self.filename)
    304             self.filename = None
    305         self.running = False
    306 
    307     def SaveAs(self):
    308         """Save python script to file"""
    309         filename = ''
     298            self.tempfile = False
     299
     300        filename = None
    310301        dlg = wx.FileDialog(parent=self.guiparent,
    311302                            message=_("Choose file to save"),
     
    358349        Just save if file already specified, save as action otherwise.
    359350        """
    360         if self.filename:
     351        if self.filename and not self.tempfile:
    361352            self.Save()
    362353        else:
Note: See TracChangeset for help on using the changeset viewer.