This wiki page <https://wxpython.org/Phoenix/docs/html/wx.FileDialog.html>
has an example of an OnSaveAs() method:
def OnSaveAs(self, event):
with wx.FileDialog(self, "Save XYZ file", wildcard="XYZ files (*.xyz)|*.xyz",
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return # the user changed their mind
# save the current contents in the file
pathname = fileDialog.GetPath()
try:
with open(pathname, 'w') as file:
self.doSaveData(file)
except IOError:
wx.LogError("Cannot save current data in file '%s'." % pathname)
When that method is invoked there is a text entry widget on the top of the
dialog box with the label, Name. I don't see where that widget and label are
specified. What am I missing here?
On a related method, OnOpen(), the wx.FileDialog() is called,
with wx.FileDialog(self, "Open XYZ file", wildcard="XYZ files (*.xyz)|*.xyz",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog:
If I want to save the file handle of the open file to a variable, e.g.,
fh, where to I make that the left side of the expression? Prepending 'with'
using 'fh = ' throws an error.
Rich