|
@@ -1384,15 +1384,23 @@ class cmdPanel(wx.Panel):
|
|
|
f = open(p['value'])
|
|
|
ifbb.SetValue(''.join(f.readlines()))
|
|
|
f.close()
|
|
|
-
|
|
|
+
|
|
|
ifbb.Bind(wx.EVT_TEXT, self.OnFileText)
|
|
|
+
|
|
|
+ btnSave = wx.Button(parent = which_panel, id = wx.ID_SAVE)
|
|
|
+ btnSave.Bind(wx.EVT_BUTTON, self.OnFileSave)
|
|
|
+
|
|
|
which_sizer.Add(item = wx.StaticText(parent = which_panel, id = wx.ID_ANY,
|
|
|
label = _('or enter values interactively')),
|
|
|
proportion = 0,
|
|
|
flag = wx.EXPAND | wx.RIGHT | wx.LEFT | wx.BOTTOM, border = 5)
|
|
|
which_sizer.Add(item = ifbb, proportion = 1,
|
|
|
flag = wx.EXPAND | wx.RIGHT | wx.LEFT, border = 5)
|
|
|
+ which_sizer.Add(item = btnSave, proportion = 0,
|
|
|
+ flag = wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, border = 5)
|
|
|
+
|
|
|
p['wxId'].append(ifbb.GetId())
|
|
|
+ p['wxId'].append(btnSave.GetId())
|
|
|
|
|
|
# directory selector
|
|
|
elif p.get('prompt','') != 'color' and p.get('element', '') == 'dir':
|
|
@@ -1576,6 +1584,42 @@ class cmdPanel(wx.Panel):
|
|
|
return p['value']
|
|
|
return p.get('default', '')
|
|
|
|
|
|
+ def OnFileSave(self, event):
|
|
|
+ """!Save interactive input to the file"""
|
|
|
+ wId = event.GetId()
|
|
|
+ win = {}
|
|
|
+ for p in self.task.params:
|
|
|
+ if wId in p.get('wxId', []):
|
|
|
+ win['file'] = self.FindWindowById(p['wxId'][0])
|
|
|
+ win['text'] = self.FindWindowById(p['wxId'][1])
|
|
|
+ break
|
|
|
+
|
|
|
+ if not win:
|
|
|
+ return
|
|
|
+
|
|
|
+ text = win['text'].GetValue()
|
|
|
+ if not text:
|
|
|
+ gcmd.GMessage(parent = self,
|
|
|
+ message = _("Nothing to save."))
|
|
|
+ return
|
|
|
+
|
|
|
+ dlg = wx.FileDialog(parent = self,
|
|
|
+ message = _("Save input as..."),
|
|
|
+ defaultDir = os.getcwd(),
|
|
|
+ style = wx.SAVE | wx.FD_OVERWRITE_PROMPT)
|
|
|
+
|
|
|
+ if dlg.ShowModal() == wx.ID_OK:
|
|
|
+ path = dlg.GetPath()
|
|
|
+ f = open(path, "w")
|
|
|
+ try:
|
|
|
+ f.write(text + os.linesep)
|
|
|
+ finally:
|
|
|
+ f.close()
|
|
|
+
|
|
|
+ win['file'].SetValue(path)
|
|
|
+
|
|
|
+ dlg.Destroy()
|
|
|
+
|
|
|
def OnFileText(self, event):
|
|
|
"""File input interactively entered"""
|
|
|
text = event.GetString()
|