Hey all,
I have been wrestling with this for about a week and wanted to get some insight into what i may be doing wrong. I have a genericDirCtrl that i am changing the path to with a browse button. After the path is changed, I want the path to be selected. I have tried to do several things with the treectrl selections, but i cant seem to get it to work. Below is the code i have so far, that is not auto-selecting the folder like i would like. Any help would be greatly appreciated. Thanks!
here is the GenericDirCtrl and assignments. I did a crazy filter (.?a?) so that i could get to filters at once
self.dir = wx.GenericDirCtrl(self.caseTab, -1, style=wx.DIRCTRL_SHOW_FILTERS|wx.DIRCTRL_MULTIPLE,
filter="Sav and Raw files (.sav, .raw)|.?a?|Raw Files (.raw)|.raw |Sav Files (.sav)|*.sav ", size = (300,200))
self.tree = self.dir.GetTreeCtrl()
wx.EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.OnSelect)
def OnSelect(self, event):
filters = [’.SAV’, ‘.RAW’]
try:
list = os.listdir(self.dir.GetPath())
for i in range(len(list)):
if list[i][0] != ‘.’:
for filter in filters:
if list[i][-4:].upper() == filter:
pass
except WindowsError:
pass
The actual path is set in the highlighted line
def onBrowse(self, event):
widget = event.GetEventObject()
name = widget.GetName()
if name == “saveDirBtn”:
mess = “Specify Local Directory”
dlg = wx.DirDialog(self,
message=mess,
defaultPath=self.local_dir,
style=wx.DD_DEFAULT_STYLE|wx.DD_DIR_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
if name == “saveDirBtn”:
self.saveDir.SetValue(path)
else:
self.log(“error browsing”)
self.local_dir = path
change the directory’s path in the Cases tab
self.dir.SetPath(path)
dlg.Destroy()