evertime I save the output file in working directory, the
customtreectrl cannot be automatically display the generated items of
working directory so I decided to call the OnExpanding function from
generating output file function in other class. but I got an error.
how can I do this?
Instead of calling the event handler why not just call Expand? If the item is already expanded then you could collapse it first.
Or another approach would be to refactor OnExpanding and move most of the code to another method, and then call that method from OnExpanding and also from your other location that needs to do the same thing.
if files is None:
self.SetItemImage(item, FileBrowser.ERROR)
self.SetItemHasChildren(item, False)
return
for fname in files:
fullpath = os.path.join(path, fname)
if os.path.isdir(fullpath):
self.AppendDir(item, fullpath)
else:
self.AppendFile(item, fullpath)
···
On 2/24/12 12:25 AM, Wonjun, Choi wrote:
hello
evertime I save the output file in working directory, the
customtreectrl cannot be automatically display the generated items of
working directory so I decided to call the OnExpanding function from
generating output file function in other class. but I got an error.
how can I do this?
The error was from [item = event.GetItem()] of FileBrower class so making
self.addItemChildren method will not solve this issue I think. and just calling Expand method works not well. but I will retry.
item = event.GetItem()
AttributeError: 'CommandEvent' object has no attribute 'GetItem'
I assume that you would want to get the currently selected item and pass that to the method. Or perhaps use some item that you've saved from somewhere else in your code.
···
On 2/26/12 4:30 PM, 최원준 wrote:
ah, now I see what you mean, but how can I pass the item in other location?
As I said before, that depends on which item you want the function to operate upon in that case. My guess is that you want it to be for the currently selected item, if so you can call the tree's GetSelection method to get it. If you want it to operate upon a different tree item then save the item object from some place where you have access to it and then pass that one to your method.
···
On 3/2/12 1:24 AM, 최원준 wrote:
I pass the path but I use self.AppendItem function in addItemChildren.
it requires item.