我通过 wx.DirDialog 框中的 GetPath 创建了一个变量(snowDIR),我想在函数之外使用 snowDIR。我的代码有一个示例:
for file in os.listdir(snowDIR):
if fnmatch.fnmatch(file, '*.hdf'):
if file[9:16] == a:
inputhdf = (snowDIR + '\\' + file)
print 'input hdf is: ', inputhdf
tmod = 1
def OnDownload(self, e):
modisPathFile = 'MODIS_data_directory_path.txt'
dlg = wx.DirDialog(self, "Choose a directory:",
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
print "You chose %s" % dlg.GetPath()
snowDIR = dlg.GetPath()
print 'snowDIR : ', snowDIR
dlg.Destroy()
more code ....
return snowDIR
任何帮助将不胜感激,因为我已经在没有锁定的情况下搜索网络并且我已经没有时间了。