Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将wx.Treectrl项添加到另一个wx。特雷克特_Python_Python 2.7_Wxpython - Fatal编程技术网

Python 如何将wx.Treectrl项添加到另一个wx。特雷克特

Python 如何将wx.Treectrl项添加到另一个wx。特雷克特,python,python-2.7,wxpython,Python,Python 2.7,Wxpython,我有两个Treectrl框,可以看到treectrl1文件夹中的文本文件。点击按钮[添加]时,需要从一个TreeCtrl框中选择并添加项目[文本文件]到另一个TreeCtrl框中。请帮助我编写代码,因为我是Wx python新手。提前谢谢 def onclick(self, event): item = self.testtree.GetSelections() print self.testtree.GetPyData(item) 使用上面的代码行试图访问所选项目以移动到

我有两个Treectrl框,可以看到treectrl1文件夹中的文本文件。点击按钮[添加]时,需要从一个TreeCtrl框中选择并添加项目[文本文件]到另一个TreeCtrl框中。请帮助我编写代码,因为我是Wx python新手。提前谢谢

def onclick(self, event):
     item = self.testtree.GetSelections()
     print self.testtree.GetPyData(item)

使用上面的代码行试图访问所选项目以移动到另一个treectrl。但无法检索项目,而是打印了所选项目的id,但看不到您的代码,我不得不猜测

item = self.testtree.GetSelections()
返回当前所选项目的
列表
,而不是单个实例。
注意:
GetSelections
只能在
TreeCtrl
样式为
wx.tru MULTIPLE

item = self.testtree.GetSelection()
另一方面,返回单个项目

我想你需要的是:

items = self.tree.GetSelections()
for item in items:
    print(self.tree.GetItemText(item))

发布你尝试过的代码,编辑我的代码。请帮忙